easier to understand

This commit is contained in:
Martin Diehl 2023-06-12 20:38:14 +02:00
parent 1a4c171109
commit 137c4e3b03
1 changed files with 66 additions and 64 deletions

View File

@ -81,12 +81,26 @@ class TestGridFilters:
grid_filters.displacement_avg_node])
def test_displacement_avg_vanishes(self,function):
"""Ensure that random fluctuations in F do not result in average displacement.""" # noqa
size = np.random.random(3)
size = np.random.random(3) + 1.0
cells = np.random.randint(8,32,(3))
F = np.random.random(tuple(cells)+(3,3))
F += np.eye(3) - np.average(F,axis=(0,1,2))
assert np.allclose(function(size,F),0.0)
@pytest.mark.parametrize('function',[grid_filters.displacement_avg_point,
grid_filters.displacement_avg_node])
def test_displacement_avg_vanishes_simple(self,function):
F = np.eye(3)
size = np.random.random(3) + 1.0
F_c = F.copy()
F_t = F.copy()
F_c[0,0] = 0.8
F_t[0,0] = 1.2
F_no_avg = np.concatenate([np.broadcast_to(_,(10,20,20,3,3)) for _ in [F_t,F_c]])
assert np.allclose(function(size,F_no_avg),0.0)
@pytest.mark.parametrize('function',[grid_filters.displacement_fluct_point,
grid_filters.displacement_fluct_node])
def test_displacement_fluct_vanishes_avg(self,function):
@ -96,18 +110,6 @@ class TestGridFilters:
F = np.broadcast_to(np.random.random((3,3)), tuple(cells)+(3,3))
assert np.allclose(function(size,F),0.0)
def test_displacement_fluct_vanishes_plus_minus(self):
F = np.eye(3)
F_c = F.copy()
F_t = F.copy()
F_c[0,0] = 0.8
F_t[0,0] = 1.2
F_no_avg = np.concatenate([np.broadcast_to(_,(10,20,20,3,3)) for _ in [F_t,F_c]])
assert np.allclose(grid_filters.displacement_point([1,1,1],F_no_avg),
grid_filters.displacement_fluct_point([1,1,1],F_no_avg))
displacement_fluct_test_data = [
(['np.sin(np.pi*2*nodes[...,0]/size[0])', '0.0', '0.0',
'0.0', '0.0', '0.0',