Exemplo n.º 1
0
 def test_sort_component(self):
     x = np.random.random((5, 12))
     t = Table(x, {'F': (3, 3), 'v': (3, )}, ['random test data'])
     unsort = t.get('4_F')
     t.sort_by('4_F')
     sort = t.get('4_F')
     assert np.all(np.sort(unsort, 0) == sort)
Exemplo n.º 2
0
 def test_rename_equivalent(self):
     x = np.random.random((5, 13))
     t = Table(x, {
         'F': (3, 3),
         'v': (3, ),
         's': (1, )
     }, ['random test data'])
     s = t.get('s')
     t.rename('s', 'u')
     u = t.get('u')
     assert np.all(s == u)
Exemplo n.º 3
0
 def test_sort_scalar(self):
     x = np.random.random((5, 13))
     t = Table(x, {
         'F': (3, 3),
         'v': (3, ),
         's': (1, )
     }, ['random test data'])
     unsort = t.get('s')
     t.sort_by('s')
     sort = t.get('s')
     assert np.all(np.sort(unsort, 0) == sort)
Exemplo n.º 4
0
 def test_join(self):
     x = np.random.random((5, 13))
     a = Table(x, {
         'F': (3, 3),
         'v': (3, ),
         's': (1, )
     }, ['random test data'])
     y = np.random.random((5, 3))
     b = Table(y, {'u': (3, )}, ['random test data'])
     a.join(b)
     assert np.array_equal(a.get('u'), b.get('u'))
Exemplo n.º 5
0
 def test_sort(self):
     t = Table(np.array([[0,1,],[2,1,]]),
               {'v':(2,)},
               ['test data'])\
         .add('s',np.array(['b','a']))\
         .sort_by('s')
     assert np.all(t.get('v')[:, 0] == np.array([2, 0]))
Exemplo n.º 6
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()
Exemplo n.º 7
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))
Exemplo n.º 8
0
 def test_sort_revert(self):
     x = np.random.random((5, 12))
     t = Table(x, {'F': (3, 3), 'v': (3, )}, ['random test data'])
     t.sort_by('4_F', ascending=False)
     sort = t.get('4_F')
     assert np.all(np.sort(sort, 0) == sort[::-1, :])