本文整理匯總了Python中exp.viroscopy.model.HIVGraph.HIVGraph.outDegreeSequence方法的典型用法代碼示例。如果您正苦於以下問題:Python HIVGraph.outDegreeSequence方法的具體用法?Python HIVGraph.outDegreeSequence怎麽用?Python HIVGraph.outDegreeSequence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類exp.viroscopy.model.HIVGraph.HIVGraph
的用法示例。
在下文中一共展示了HIVGraph.outDegreeSequence方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testContactEvent
# 需要導入模塊: from exp.viroscopy.model.HIVGraph import HIVGraph [as 別名]
# 或者: from exp.viroscopy.model.HIVGraph.HIVGraph import outDegreeSequence [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)