def testreadSimulationHIVGraph(self): 
     
     hivReader = HIVGraphReader()
     graph = hivReader.readSimulationHIVGraph()
     
     
     self.assertEquals(graph.getNumVertices(), 5389)
     self.assertEquals(graph.getNumEdges(), 4097)
     #Check the edges of the first few vertices 
     nptst.assert_array_equal(graph.neighbours(0), numpy.array([50]))
     nptst.assert_array_equal(graph.neighbours(1), numpy.array([1380]))
     nptst.assert_array_equal(graph.neighbours(2), numpy.array([]))
     nptst.assert_array_equal(graph.neighbours(3), numpy.array([]))
     nptst.assert_array_equal(graph.neighbours(30), numpy.array([43, 51, 57, 151, 304, 386,913]))
     
     #Check vertex values 
     v = graph.getVertex(0)
     self.assertEquals(v[HIVVertices.dobIndex], 19602)
     self.assertEquals(v[HIVVertices.genderIndex], HIVVertices.male)
     self.assertEquals(v[HIVVertices.orientationIndex], HIVVertices.hetero)
     self.assertEquals(v[HIVVertices.stateIndex], HIVVertices.removed)
     self.assertEquals(v[HIVVertices.infectionTimeIndex], -1)
     self.assertEquals(v[HIVVertices.detectionTimeIndex], 31563)
     self.assertEquals(v[HIVVertices.detectionTypeIndex], HIVVertices.randomDetect)
     self.assertEquals(v[HIVVertices.hiddenDegreeIndex], 3)
     
     v = graph.getVertex(1)
     self.assertEquals(v[HIVVertices.dobIndex], 21508)
     self.assertEquals(v[HIVVertices.genderIndex], HIVVertices.male)
     self.assertEquals(v[HIVVertices.orientationIndex], HIVVertices.hetero)
     self.assertEquals(v[HIVVertices.stateIndex], HIVVertices.removed)
     self.assertEquals(v[HIVVertices.infectionTimeIndex], -1)
     self.assertEquals(v[HIVVertices.detectionTimeIndex], 31563)
     self.assertEquals(v[HIVVertices.detectionTypeIndex], HIVVertices.randomDetect)
     self.assertEquals(v[HIVVertices.hiddenDegreeIndex], 4)
     
     v = graph.getVertex(6)
     self.assertEquals(v[HIVVertices.dobIndex], 21676)
     self.assertEquals(v[HIVVertices.genderIndex], HIVVertices.female)
     self.assertEquals(v[HIVVertices.orientationIndex], HIVVertices.hetero)
     self.assertEquals(v[HIVVertices.stateIndex], HIVVertices.removed)
     self.assertEquals(v[HIVVertices.infectionTimeIndex], -1)
     self.assertEquals(v[HIVVertices.detectionTimeIndex], 31472)
     self.assertEquals(v[HIVVertices.detectionTypeIndex], HIVVertices.contactTrace)
     self.assertEquals(v[HIVVertices.hiddenDegreeIndex], 1)
     
     v = graph.getVertex(5381)
     self.assertEquals(v[HIVVertices.dobIndex], 25307)
     self.assertEquals(v[HIVVertices.genderIndex], HIVVertices.male)
     self.assertEquals(v[HIVVertices.orientationIndex], HIVVertices.bi)
     self.assertEquals(v[HIVVertices.stateIndex], HIVVertices.removed)
     self.assertEquals(v[HIVVertices.infectionTimeIndex], -1)
     self.assertEquals(v[HIVVertices.detectionTimeIndex], 38231)
     self.assertEquals(v[HIVVertices.detectionTypeIndex], HIVVertices.randomDetect)
     self.assertEquals(v[HIVVertices.hiddenDegreeIndex], 0)
Beispiel #2
0
 def realSimulationParams(): 
     hivReader = HIVGraphReader()
     targetGraph = hivReader.readSimulationHIVGraph()
     
     numRecordSteps = 10 
     #Note that 5% of the population is bi 
     M = targetGraph.size * 4
     #This needs to be from 1986 to 2004 
     startDate = CsvConverters.dateConv("01/01/1986")
     endDates = [CsvConverters.dateConv("01/01/1987"), CsvConverters.dateConv("01/01/1989"), CsvConverters.dateConv("01/01/1991"), CsvConverters.dateConv("01/01/1993"), CsvConverters.dateConv("01/01/1995"), CsvConverters.dateConv("01/01/1997")]
     endDates = [float(i) for i in endDates]
     
     return float(startDate), endDates, numRecordSteps, M, targetGraph