Ejemplo n.º 1
0
 def test_sort(self):
     t = Table(np.array([[
         0,
         1,
     ], [
         2,
         1,
     ]]), {'v': (2, )}, ['test data'])
     t.add('s', np.array(['b', 'a']))
     t.sort_by('s')
     assert np.all(t.get('1_v') == np.array([2, 0]).reshape(2, 1))
Ejemplo n.º 2
0
 def test_from_table(self):
     cells = np.random.randint(60,100,3)
     size = np.ones(3)+np.random.rand(3)
     coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3,order='F')
     z=np.ones(cells.prod())
     z[cells[:2].prod()*int(cells[2]/2):]=0
     t = Table(np.column_stack((coords,z)),{'coords':3,'z':1})
     t = t.add('indicator',t.get('coords')[:,0])
     g = Grid.from_table(t,'coords',['indicator','z'])
     assert g.N_materials == g.cells[0]*2 and (g.material[:,:,-1]-g.material[:,:,0] == cells[0]).all()
Ejemplo n.º 3
0
 def test_relationship_reference(self, update, reference_dir, model,
                                 lattice):
     reference = os.path.join(reference_dir, f'{lattice}_{model}.txt')
     ori = Orientation(Rotation(), lattice)
     eu = np.array(
         [o.rotation.as_Eulers(degrees=True) for o in ori.related(model)])
     if update:
         coords = np.array([(1, i + 1) for i, x in enumerate(eu)])
         table = Table(eu, {'Eulers': (3, )})
         table = table.add('pos', coords)
         table.save(reference)
     assert np.allclose(eu, Table.load(reference).get('Eulers'))