missing tests
This commit is contained in:
parent
044f069437
commit
a4dfd7fc74
|
@ -18,7 +18,7 @@ def reference_dir(reference_dir_base):
|
||||||
return os.path.join(reference_dir_base,'Table')
|
return os.path.join(reference_dir_base,'Table')
|
||||||
|
|
||||||
class TestTable:
|
class TestTable:
|
||||||
|
|
||||||
def test_get_scalar(self,default):
|
def test_get_scalar(self,default):
|
||||||
d = default.get('s')
|
d = default.get('s')
|
||||||
assert np.allclose(d,1.0) and d.shape[1:] == (1,)
|
assert np.allclose(d,1.0) and d.shape[1:] == (1,)
|
||||||
|
@ -29,12 +29,12 @@ class TestTable:
|
||||||
|
|
||||||
def test_get_tensor(self,default):
|
def test_get_tensor(self,default):
|
||||||
d = default.get('F')
|
d = default.get('F')
|
||||||
assert np.allclose(d,1.0) and d.shape[1:] == (3,3)
|
assert np.allclose(d,1.0) and d.shape[1:] == (3,3)
|
||||||
|
|
||||||
def test_get_component(self,default):
|
def test_get_component(self,default):
|
||||||
d = default.get('5_F')
|
d = default.get('5_F')
|
||||||
assert np.allclose(d,1.0) and d.shape[1:] == (1,)
|
assert np.allclose(d,1.0) and d.shape[1:] == (1,)
|
||||||
|
|
||||||
def test_write_read_str(self,default,tmpdir):
|
def test_write_read_str(self,default,tmpdir):
|
||||||
default.to_ASCII(str(tmpdir.join('default.txt')))
|
default.to_ASCII(str(tmpdir.join('default.txt')))
|
||||||
new = Table.from_ASCII(str(tmpdir.join('default.txt')))
|
new = Table.from_ASCII(str(tmpdir.join('default.txt')))
|
||||||
|
@ -69,15 +69,20 @@ class TestTable:
|
||||||
def test_read_strange(self,reference_dir,fname):
|
def test_read_strange(self,reference_dir,fname):
|
||||||
with open(os.path.join(reference_dir,fname)) as f:
|
with open(os.path.join(reference_dir,fname)) as f:
|
||||||
Table.from_ASCII(f)
|
Table.from_ASCII(f)
|
||||||
|
|
||||||
def test_set(self,default):
|
def test_set(self,default):
|
||||||
default.set('F',np.zeros((5,3,3)),'set to zero')
|
default.set('F',np.zeros((5,3,3)),'set to zero')
|
||||||
d=default.get('F')
|
d=default.get('F')
|
||||||
assert np.allclose(d,0.0) and d.shape[1:] == (3,3)
|
assert np.allclose(d,0.0) and d.shape[1:] == (3,3)
|
||||||
|
|
||||||
|
def test_set_component(self,default):
|
||||||
|
default.set('1_F',np.zeros((5)),'set to zero')
|
||||||
|
d=default.get('F')
|
||||||
|
assert np.allclose(d[...,0,0],0.0) and d.shape[1:] == (3,3)
|
||||||
|
|
||||||
def test_labels(self,default):
|
def test_labels(self,default):
|
||||||
assert default.labels == ['F','v','s']
|
assert default.labels == ['F','v','s']
|
||||||
|
|
||||||
def test_add(self,default):
|
def test_add(self,default):
|
||||||
d = np.random.random((5,9))
|
d = np.random.random((5,9))
|
||||||
default.add('nine',d,'random data')
|
default.add('nine',d,'random data')
|
||||||
|
|
|
@ -42,12 +42,25 @@ class TestGridFilters:
|
||||||
assert np.allclose(grid_filters.node_displacement_fluct(size,F),
|
assert np.allclose(grid_filters.node_displacement_fluct(size,F),
|
||||||
grid_filters.cell_2_node(grid_filters.cell_displacement_fluct(size,F)))
|
grid_filters.cell_2_node(grid_filters.cell_displacement_fluct(size,F)))
|
||||||
|
|
||||||
def test_interpolation_nonperiodic(self):
|
def test_interpolation_to_node(self):
|
||||||
size = np.random.random(3)
|
size = np.random.random(3)
|
||||||
grid = np.random.randint(8,32,(3))
|
grid = np.random.randint(8,32,(3))
|
||||||
F = np.random.random(tuple(grid)+(3,3))
|
F = np.random.random(tuple(grid)+(3,3))
|
||||||
assert np.allclose(grid_filters.node_coord(size,F) [1:-1,1:-1,1:-1],grid_filters.cell_2_node(
|
assert np.allclose(grid_filters.node_coord(size,F) [1:-1,1:-1,1:-1],
|
||||||
grid_filters.cell_coord(size,F))[1:-1,1:-1,1:-1])
|
grid_filters.cell_2_node(grid_filters.cell_coord(size,F))[1:-1,1:-1,1:-1])
|
||||||
|
|
||||||
|
def test_interpolation_to_cell(self):
|
||||||
|
grid = np.random.randint(1,30,(3))
|
||||||
|
|
||||||
|
node_coord_x = np.linspace(0,np.pi*2,num=grid[0]+1)
|
||||||
|
node_field_x = np.cos(node_coord_x)
|
||||||
|
node_field = np.broadcast_to(node_field_x.reshape(-1,1,1),grid+1)
|
||||||
|
|
||||||
|
cell_coord_x = node_coord_x[:-1]+node_coord_x[1]*.5
|
||||||
|
cell_field_x = np.interp(cell_coord_x,node_coord_x,node_field_x,period=np.pi*2.)
|
||||||
|
cell_field = np.broadcast_to(cell_field_x.reshape(-1,1,1),grid)
|
||||||
|
|
||||||
|
assert np.allclose(cell_field,grid_filters.node_2_cell(node_field))
|
||||||
|
|
||||||
@pytest.mark.parametrize('mode',['cell','node'])
|
@pytest.mark.parametrize('mode',['cell','node'])
|
||||||
def test_coord0_origin(self,mode):
|
def test_coord0_origin(self,mode):
|
||||||
|
|
Loading…
Reference in New Issue