当前位置: 首页>>代码示例>>Python>>正文


Python Util.expandIntArray方法代码示例

本文整理汇总了Python中sandbox.util.Util.Util.expandIntArray方法的典型用法代码示例。如果您正苦于以下问题:Python Util.expandIntArray方法的具体用法?Python Util.expandIntArray怎么用?Python Util.expandIntArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sandbox.util.Util.Util的用法示例。


在下文中一共展示了Util.expandIntArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testExpandIntArray

# 需要导入模块: from sandbox.util.Util import Util [as 别名]
# 或者: from sandbox.util.Util.Util import expandIntArray [as 别名]
    def testExpandIntArray(self):
        v = numpy.array([1, 3, 2, 4], numpy.int)
        w = Util.expandIntArray(v)

        self.assertTrue((w == numpy.array([0,1,1,1,2,2,3,3,3,3], numpy.int)).all())

        v = numpy.array([], numpy.int)
        w = Util.expandIntArray(v)
        self.assertTrue((w == numpy.array([], numpy.int)).all())
开发者ID:charanpald,项目名称:sandbox,代码行数:11,代码来源:UtilTest.py

示例2: runRandomChoice

# 需要导入模块: from sandbox.util.Util import Util [as 别名]
# 或者: from sandbox.util.Util.Util import expandIntArray [as 别名]
        def runRandomChoice():
            #can just do non-zero entries
            w = Util.expandIntArray(v)

            reps = 10000
            for i in range(reps):
                w[numpy.random.randint(0, w.shape[0])]
开发者ID:charanpald,项目名称:sandbox,代码行数:9,代码来源:UtilProfile.py

示例3: HIVGraph

# 需要导入模块: from sandbox.util.Util import Util [as 别名]
# 或者: from sandbox.util.Util.Util import expandIntArray [as 别名]
We simulate a network of sexual contacts and see if we can approximate the degree
using a subset of the edges. 
"""
import numpy 
from apgl.viroscopy.model.HIVGraph import HIVGraph
from sandbox.util.Util import Util

numpy.set_printoptions(linewidth=200, threshold=10000)

numVertices = 500
graph = HIVGraph(numVertices)

T = 100
t = 0

expandedDegreeSeq = Util.expandIntArray(graph.outDegreeSequence())
expandedDegreeSeq = numpy.arange(numVertices)
contactRate = 0.01

tau = 1.0
infectedList = range(10)
#infectedList = range(numVertices)

while (t < T):
    contactRatesMatrix = numpy.zeros((len(infectedList), numVertices))

    #Select a random contact based on the degree
    edsInds = numpy.random.randint(0, expandedDegreeSeq.shape[0], len(infectedList))
    #Choose between a contact sampled from those with edges and one from random

开发者ID:charanpald,项目名称:sandbox,代码行数:31,代码来源:ContactModel.py


注:本文中的sandbox.util.Util.Util.expandIntArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。