本文整理匯總了Python中exp.viroscopy.model.HIVGraph.HIVGraph.endTime方法的典型用法代碼示例。如果您正苦於以下問題:Python HIVGraph.endTime方法的具體用法?Python HIVGraph.endTime怎麽用?Python HIVGraph.endTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類exp.viroscopy.model.HIVGraph.HIVGraph
的用法示例。
在下文中一共展示了HIVGraph.endTime方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testAddGraph
# 需要導入模塊: from exp.viroscopy.model.HIVGraph import HIVGraph [as 別名]
# 或者: from exp.viroscopy.model.HIVGraph.HIVGraph import endTime [as 別名]
def testAddGraph(self):
epsilon = 0.12
metrics = HIVGraphMetrics2(self.graph, epsilon)
metrics.addGraph(self.graph)
self.assertEquals(metrics.dists[0], 0.0)
self.assertEquals(metrics.meanDistance(), 0.0)
#Start a new graph
#Compute distances directly
matcher = GraphMatch("U")
graph = HIVGraph(self.graph.size)
dists = []
metrics = HIVGraphMetrics2(self.graph, epsilon)
graph.vlist.setInfected(1, 0.0)
graph.vlist.setDetected(1, 0.1, 0)
metrics.addGraph(graph)
t = graph.endTime()
subgraph1 = graph.subgraph(graph.removedIndsAt(t))
subgraph2 = self.graph.subgraph(graph.removedIndsAt(t))
permutation, distance, time = matcher.match(subgraph1, subgraph2)
lastDist = matcher.distance(subgraph1, subgraph2, permutation, True, True)
self.assertEquals(metrics.dists[-1], lastDist)
self.assertTrue(metrics.shouldBreak())
graph.vlist.setInfected(2, 2.0)
graph.vlist.setDetected(2, 2.0, 0)
metrics.addGraph(graph)
t = graph.endTime()
subgraph1 = graph.subgraph(graph.removedIndsAt(t))
subgraph2 = self.graph.subgraph(graph.removedIndsAt(t))
permutation, distance, time = matcher.match(subgraph1, subgraph2)
lastDist = matcher.distance(subgraph1, subgraph2, permutation, True, True)
self.assertEquals(metrics.dists[-1], lastDist)
self.assertTrue(metrics.shouldBreak())
graph.vlist.setInfected(7, 3.0)
graph.vlist.setDetected(7, 3.0, 0)
metrics.addGraph(graph)
t = graph.endTime()
subgraph1 = graph.subgraph(graph.removedIndsAt(t))
subgraph2 = self.graph.subgraph(graph.removedIndsAt(t))
permutation, distance, time = matcher.match(subgraph1, subgraph2)
lastDist = matcher.distance(subgraph1, subgraph2, permutation, True, True)
self.assertEquals(metrics.dists[-1], lastDist)
self.assertFalse(metrics.shouldBreak())
#Test case where one graph has zero size
graph1 = HIVGraph(10)
graph2 = HIVGraph(10)
graph1.vlist[:, HIVVertices.stateIndex] = HIVVertices.removed
metrics = HIVGraphMetrics2(graph2, epsilon)
metrics.addGraph(graph1)
#Problem is that distance is 1 when one graph is zero
self.assertEquals(len(metrics.dists), 0)