def test_from_table_recover(self,tmp_path): grid = np.random.randint(60,100,3) size = np.ones(3)+np.random.rand(3) s = seeds.from_random(size,np.random.randint(60,100)) geom = Geom.from_Voronoi_tessellation(grid,size,s) coords = grid_filters.cell_coord0(grid,size) t = Table(np.column_stack((coords.reshape(-1,3,order='F'),geom.material.flatten(order='F'))),{'c':3,'m':1}) assert geom_equal(geom.sort().renumber(),Geom.from_table(t,'c',['m']))
def test_from_table(self): grid = np.random.randint(60,100,3) size = np.ones(3)+np.random.rand(3) coords = grid_filters.cell_coord0(grid,size).reshape(-1,3,order='F') z=np.ones(grid.prod()) z[grid[:2].prod()*int(grid[2]/2):]=0 t = Table(np.column_stack((coords,z)),{'coords':3,'z':1}) g = Geom.from_table(t,'coords',['1_coords','z']) assert g.N_materials == g.grid[0]*2 and (g.material[:,:,-1]-g.material[:,:,0] == grid[0]).all()