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


Python HIVGraph.outDegreeSequence方法代码示例

本文整理汇总了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)
开发者ID:charanpald,项目名称:wallhack,代码行数:46,代码来源:HIVRatesTest.py


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