def test_path_calculations(self): path_output = tpt.find_top_paths(self.sources, self.sinks, self.tprob) paths_ref = io.loadh( tpt_get("dijkstra_paths.h5"), 'Data') fluxes_ref = io.loadh( tpt_get("dijkstra_fluxes.h5"), 'Data') bottlenecks_ref = io.loadh( tpt_get("dijkstra_bottlenecks.h5"), 'Data') #npt.assert_array_almost_equal(path_output[0], paths_ref) npt.assert_array_almost_equal(path_output[1], bottlenecks_ref) npt.assert_array_almost_equal(path_output[2], fluxes_ref)
def test_path_calculations(self): path_output = tpt.find_top_paths(self.sources, self.sinks, self.tprob) paths_ref = io.loadh(os.path.join(self.tpt_ref_dir,"dijkstra_paths.h5"), 'Data') fluxes_ref = io.loadh(os.path.join(self.tpt_ref_dir,"dijkstra_fluxes.h5"), 'Data') bottlenecks_ref = io.loadh(os.path.join(self.tpt_ref_dir,"dijkstra_bottlenecks.h5"), 'Data') #npt.assert_array_almost_equal(path_output[0], paths_ref) npt.assert_array_almost_equal(path_output[1], bottlenecks_ref) npt.assert_array_almost_equal(path_output[2], fluxes_ref)
def test_path_calculations(self): path_output = tpt.find_top_paths(self.sources, self.sinks, self.tprob) paths_ref = io.loadh( tpt_get("dijkstra_paths.h5"), 'Data') fluxes_ref = io.loadh( tpt_get("dijkstra_fluxes.h5"), 'Data') bottlenecks_ref = io.loadh( tpt_get("dijkstra_bottlenecks.h5"), 'Data') for i in range(len(paths_ref)): npt.assert_array_almost_equal(path_output[0][i], paths_ref[i]) npt.assert_array_almost_equal(path_output[1], bottlenecks_ref) npt.assert_array_almost_equal(path_output[2], fluxes_ref)
def run(tprob, A, B, n): (Paths, Bottlenecks, Fluxes) = tpt.find_top_paths(A, B, tprob, num_paths=n) # We have to pad the paths with -1s to make a square array maxi = 0 # the maximum path length for path in Paths: if len(path) > maxi: maxi = len(path) PaddedPaths = -1 * np.ones( (len(Paths), maxi ) ) for i, path in enumerate(Paths): PaddedPaths[i,:len(path)] = np.array(path) return PaddedPaths, np.array(Bottlenecks), np.array(Fluxes)
def run(tprob, A, B, n): Paths, Bottlenecks, Fluxes = tpt.find_top_paths(A, B, tprob, num_paths=n) # We have to pad the paths with -1s to make a square array maxi = 0 # the maximum path length for path in Paths: if len(path) > maxi: maxi = len(path) PaddedPaths = -1 * np.ones((len(Paths), maxi)) for i, path in enumerate(Paths): PaddedPaths[i, :len(path)] = np.array(path) return PaddedPaths, np.array(Bottlenecks), np.array(Fluxes)