本文整理汇总了Python中exp.viroscopy.model.HIVGraph.HIVGraph.neighbours方法的典型用法代码示例。如果您正苦于以下问题:Python HIVGraph.neighbours方法的具体用法?Python HIVGraph.neighbours怎么用?Python HIVGraph.neighbours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exp.viroscopy.model.HIVGraph.HIVGraph
的用法示例。
在下文中一共展示了HIVGraph.neighbours方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testContactEvent
# 需要导入模块: from exp.viroscopy.model.HIVGraph import HIVGraph [as 别名]
# 或者: from exp.viroscopy.model.HIVGraph.HIVGraph import neighbours [as 别名]
def testContactEvent(self):
undirected = True
numVertices = 10
graph = HIVGraph(numVertices, undirected)
#for i in range(numVertices):
# logging.debug(graph.getVertex(i))
t = 0.2
hiddenDegSeq = self.gen.rvs(size=graph.getNumVertices())
rates = HIVRates(graph, hiddenDegSeq)
V = graph.getVertexList().getVertices()
femaleInds = V[:, HIVVertices.genderIndex]==HIVVertices.female
maleInds = V[:, HIVVertices.genderIndex]==HIVVertices.male
biMaleInds = numpy.logical_and(maleInds, V[:, HIVVertices.orientationIndex]==HIVVertices.bi)
self.assertEquals(rates.expandedDegSeqFemales.shape[0], hiddenDegSeq[femaleInds].sum()*rates.p)
self.assertEquals(rates.expandedDegSeqMales.shape[0], hiddenDegSeq[maleInds].sum()*rates.p)
self.assertEquals(rates.expandedDegSeqBiMales.shape[0], hiddenDegSeq[biMaleInds].sum()*rates.p)
for i in range(numVertices):
self.assertEquals(rates.contactTimesArr[i], -1)
rates.contactEvent(0, 9, 0.1)
rates.contactEvent(0, 3, 0.2)
self.assertEquals(graph.getEdge(0, 3), 0.2)
self.assertEquals(graph.getEdge(0, 9), 0.1)
self.assertTrue((rates.contactTimesArr[0] == numpy.array([3])).all())
self.assertTrue((rates.contactTimesArr[9] == numpy.array([0])).all())
self.assertTrue((rates.contactTimesArr[3] == numpy.array([0])).all())
for i in range(numVertices):
self.assertTrue((rates.neighboursList[i] == graph.neighbours(i)).all())
#Check that the degree sequence is correct
degSequence = graph.outDegreeSequence()
r = rates.q-rates.p
self.assertEquals(rates.expandedDegSeqFemales.shape[0], hiddenDegSeq[femaleInds].sum()*rates.p + degSequence[femaleInds].sum()*r)
self.assertEquals(rates.expandedDegSeqMales.shape[0], hiddenDegSeq[maleInds].sum()*rates.p + degSequence[maleInds].sum()*r)
self.assertEquals(rates.expandedDegSeqBiMales.shape[0], hiddenDegSeq[biMaleInds].sum()*rates.p + degSequence[biMaleInds].sum()*r)