def NOtest_rounding(self): """ This method writes histograms of the input demand and can be used to check the differences of the row and column sums for two matrices """ projectFolder = "/Users/michalis/Documents/sfcta/testNetworks" projectFolder = "/Users/michalis/Documents/sfcta/05252012/" prefix = "sfCounty_lisa" prefix = "SF_Test_wSig_5_100pct_NetworkReview" scenario = DynameqScenario(Time(0, 0), Time(12, 0)) scenario.read(projectFolder, prefix) net = DynameqNetwork(scenario) net.read(projectFolder, prefix) file1 = "/Users/michalis/Documents/sfcta/05252012/car_notoll_matx.dqt" demand1 = Demand.readDynameqTable(net, file1) _npyArray1 = demand1._demandTable.getNumpyArray() * 3 file2 = "/Users/michalis/Documents/sfcta/05252012/vehcountorig_Car_NoToll_matx.dqt" demand2 = Demand.readDynameqTable(net, file2) pdb.set_trace() _npyArray1 = _npyArray1.sum(0) _npyArray2 = demand2._demandTable.getNumpyArray().sum(0) pdb.set_trace() plotTripHistogram(_npyArray1, "carNoTollHistogram1") plotTripHistogram(_npyArray2, "carNoTollHistogram2")
def test_write(self): """ """ fileName = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'dynameqNetwork_gearySubset', 'gearysubnet_matx.dqt') net = getTestNet() demand = Demand.readDynameqTable(net, fileName) # TODO: this requires subdir test to exist. Write this to tempfile.mkdtemp() outFileName = "test/testDemand.dqt" demand.writeDynameqTable(outFileName) demand2 = Demand.readDynameqTable(net, outFileName) assert demand == demand2 os.remove("test/testDemand.dqt")
def test_plotHistogram(self): fileName = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'dynameqNetwork_gearySubset', 'gearysubnet_matx.dqt') net = getTestNet() demand = Demand.readDynameqTable(net, fileName) for startTime in range(0, 45, 15): for o in net.iterCentroids(): for d in net.iterCentroids(): demand.setValue(Time(0, startTime + 15), o.getId(), d.getId(), random.random() * 10) _npyArray = demand._demandTable.getNumpyArray() plotTripHistogram(_npyArray, "tripHistogram")
def test_1read(self): fileName = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'dynameqNetwork_gearySubset', 'gearysubnet_matx.dqt') net = getTestNet() demand = Demand.readDynameqTable(net, fileName) assert demand.getNumSlices() == 4 assert demand.getValue(Time(0, 15), 56, 8) == 4000 assert demand.getValue(Time(0, 45), 8, 2) == 34 demand.setValue(Time(0, 45), 8, 2, 35) assert demand.getValue(Time(0, 45), 8, 2) == 35 demand.setValue(Time(0, 15), 56, 8, 4001) assert not demand.getValue(Time(0, 15), 56, 8) == 4000 assert demand.getValue(Time(0, 15), 56, 8) == 4001