def test_into_edges_reconnetcion_onsmall_graph_3d_higres_neighborhood( self): data = np.array([[[0, 0], [0, 1]], [[0, 1], [1, 1]]]) g = graph.Graph(data, (0.1, 0.2, 0.05), grid_function="nd", nsplit=2) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk")
def test_from_edges_reconnetcion_onsmall_graph_3d_higres_neighborhood( self): data = np.array([ [[ 1, 1, ], [ 1, 0, ]], [[ 1, 0, ], [ 0, 0, ]], ]) g = graph.Graph(data, (0.1, 0.2, 0.05), grid_function="nd", nsplit=2, compute_msindex=True) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk")
def test_just_two_blocks(self): data = np.array([[[0, 1]]]) g = graph.Graph(data, (0.1, 0.2, 0.05), grid_function="nd", nsplit=2) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk") g
def test_into_edges_reconnetcion_on_small_graph_3d(self): data = np.array([ [[ 0, 0, ], [ 0, 0, ]], [[ 0, 0, ], [ 0, 1, ]], ]) g = graph.Graph(data, (0.1, 0.2, 0.05), grid_function="nd", nsplit=2) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk") g.edges self.assertEqual(g.edges.shape[0], 33) self.assertEqual(g.edges.shape[1], 2) self.assertEqual(g.nodes.shape[0], 15)
def test_graph_3d_two_slices(self): data = np.array([ [[0, 0, 0, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]], [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]], ]) g = graph.Graph(data, (0.1, 0.12, 0.05)) g.run()
def test_graph_3d_implementation(self): data = np.array([[0, 0, 0, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) # g = graph.Graph(data, (0.1, 0.12), grid_function="2d", nsplit=3) # 3d 2:0, # diff 3d 2:6, 3:15, 4:24, 5:33 6:42 7:51 g = graph.Graph(data, (0.1, 0.12), grid_function="nd", nsplit=7) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk") g.lastnode
def test_graph_2d_implementation(self): data = np.array([[0, 0, 0, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) g = graph.Graph(data, (0.1, 0.12), grid_function="2d", nsplit=7) # g = graph.Graph(data, (0.1, 0.12), grid_function="nd", nsplit=5) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk") # 2d edge number diff= nsplit:(g.lastedge - g.edmax_debug) # # 2: 6, 3:15, 4:24 g
def test_graph_3d(self): data = np.array([ [[0, 0, 0, 0, 0], [0, 1, 1, 0, 1], [1, 1, 1, 0, 0], [0, 0, 0, 0, 1]], [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 1]], [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 1]], ]) g = graph.Graph(data, (0.1, 0.12, 0.05), grid_function="nd", nsplit=6) # 2:-21, 3:10, 4:57 5:120 6:199 31, 47, 63, 79 16, 16, 16 g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk") g.lastnode
def test_into_maximum_edge_number(self): # data = np.random.random([50, 50, 8]) data = np.random.random([5, 3, 3]) data = data < 0.08 # data = np.random.random_integers(0,1, [10,10,10]) g = graph.Graph(data, (0.1, 0.2, 0.05), grid_function="nd", nsplit=6) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk") unused_edges = g.edmax - g.lastedge unused_nodes = g.ndmax - g.lastnode edge_efectivity = 1 - float(unused_edges) / g.edmax node_efectivity = 1 - float(unused_nodes) / g.ndmax logger.info("Memory node efficiency: {} ({})".format( node_efectivity, g.ndmax)) logger.info("Memory edge efficiency: {} ({})".format( edge_efectivity, g.edmax)) g
def test_raise_exception_on_different_input_shapes(self): data = np.array([ [[ 1, 1, ], [ 1, 0, ]], [[ 1, 0, ], [ 0, 0, ]], ]) g = graph.Graph(data, (0.1, 0.2), grid_function="nd", nsplit=2)
def test_msindex_on_small_graph_3d(self): data = np.array([[[1, 0], [0, 0]], [[0, 0], [0, 0]]]) g = graph.Graph(data, (0.1, 0.2, 0.05), grid_function="nd", nsplit=2, compute_msindex=True) g.run(base_grid_vtk_fn="base_grid.vtk", final_grid_vtk_fn="final_grid.vtk") self.assertEqual(g.edges.shape[0], 33) self.assertEqual(g.edges.shape[1], 2) self.assertEqual(g.nodes.shape[0], 15) # msindex with low resolution should be in the beginning of data un, counts = np.unique(g.msinds, return_counts=True) # on this example first 7 node labeles should be used multiple timse self.assertTrue( (counts[:7] > 1).all(), msg= "on this example first 7 node labeles should be used multiple times", )
def test_raise_exception_on_different_input_shapes(self): data = np.array([[[1, 1], [1, 0]], [[1, 0], [0, 0]]]) with pytest.raises(ValueError) as excinfo: g = graph.Graph(data, (0.1, 0.2), grid_function="nd", nsplit=2)