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


Python HIVGraph.infectedIndsAt方法代码示例

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


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

示例1: testUpperDetectionRates

# 需要导入模块: from exp.viroscopy.model.HIVGraph import HIVGraph [as 别名]
# 或者: from exp.viroscopy.model.HIVGraph.HIVGraph import infectedIndsAt [as 别名]
    def testUpperDetectionRates(self): 
        """
        See if the upper bound on detection rates is correct 
        """
        undirected = True
        numVertices = 10
        graph = HIVGraph(numVertices, undirected)
        hiddenDegSeq = self.gen.rvs(size=graph.getNumVertices())
        rates = HIVRates(graph, hiddenDegSeq)
        t = 0.1
        
        graph.getVertexList().setInfected(0, t)
        graph.getVertexList().setInfected(1, t)
        graph.getVertexList().setInfected(8, t)
        
        t = 0.2
        rates.removeEvent(8, HIVVertices.randomDetect, t)
        rates.infectionProbability = 1.0
        
        infectedList = graph.infectedIndsAt(t)
        removedList = graph.removedIndsAt(t)
        n = graph.size-removedList
        self.assertEquals(rates.upperDetectionRates(infectedList, n), rates.randomDetectionRates(infectedList, n, seed=21).sum()) 
        
        t = 0.3
        rates.contactEvent(0, 2, t)
        graph.vlist.setInfected(2, t)
        
        t = 0.4
        rates.removeEvent(0, HIVVertices.randomDetect, t)
        
        infectedList = graph.infectedIndsAt(t)
        removedSet = graph.removedIndsAt(t)
        removedSet = set(removedSet.tolist())

        nptst.assert_array_almost_equal(rates.contactTracingRates(infectedList, removedSet, t + rates.ctStartTime + 1), numpy.array([0, rates.ctRatePerPerson]))
        
        upperDetectionRates = rates.ctRatePerPerson + rates.randomDetectionRates(infectedList, n, seed=21).sum()
        self.assertEquals(rates.upperDetectionRates(infectedList, n), upperDetectionRates) 
开发者ID:charanpald,项目名称:wallhack,代码行数:41,代码来源:HIVRatesTest.py

示例2: testInfectedIndsAt

# 需要导入模块: from exp.viroscopy.model.HIVGraph import HIVGraph [as 别名]
# 或者: from exp.viroscopy.model.HIVGraph.HIVGraph import infectedIndsAt [as 别名]
    def testInfectedIndsAt(self): 
        numVertices = 10
        graph = HIVGraph(numVertices)

        self.assertTrue(graph.getRemovedSet() == set([]))

        graph.getVertexList().setInfected(1, 0.0)
        graph.getVertexList().setInfected(2, 2.0)
        graph.getVertexList().setInfected(7, 3.0)
        
        
        inds = graph.infectedIndsAt(10)
        nptst.assert_array_equal(inds, numpy.array([1, 2, 7]))
        
        graph.getVertexList().setInfected(5, 12.0)
        nptst.assert_array_equal(inds, numpy.array([1, 2, 7]))
开发者ID:charanpald,项目名称:wallhack,代码行数:18,代码来源:HIVGraphTest.py

示例3: testContactRates3

# 需要导入模块: from exp.viroscopy.model.HIVGraph import HIVGraph [as 别名]
# 或者: from exp.viroscopy.model.HIVGraph.HIVGraph import infectedIndsAt [as 别名]
 def testContactRates3(self): 
     #Figure out why infection does not explode when we set infection probability 
     #to a high value and do not detect 
     
     undirected = True
     numVertices = 20
     graph = HIVGraph(numVertices, undirected)
     hiddenDegSeq = self.gen.rvs(size=graph.getNumVertices())
     rates = HIVRates(graph, hiddenDegSeq)
     t = 0.1
     
     for i in range(10): 
         graph.getVertexList().setInfected(i, t)
     
     t = 0.2
     infectedList = graph.infectedIndsAt(t)
     contactList = range(0, numVertices)
     contactRateInds, contactRates = rates.contactRates(infectedList, contactList, t)
     
     print(contactRateInds, contactRates)
开发者ID:charanpald,项目名称:wallhack,代码行数:22,代码来源:HIVRatesTest.py


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