本文整理汇总了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())
示例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])]
示例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