test + resulting bug fix

This commit is contained in:
Martin Diehl 2020-05-03 17:04:03 +02:00
parent 5d4b554b00
commit 7d1e0850ab
2 changed files with 16 additions and 1 deletions

View File

@ -1219,6 +1219,6 @@ class Rotation:
p = 2
else:
p = np.where(np.maximum(np.abs(xyz[...,0]),np.abs(xyz[...,1])) <= np.abs(xyz[...,2]),0,
np.where(np.maximum(np.abs(xyz[...,1]),np.abs(xyz[...,2])) <= np.abs(xyz[...,0]),2,3))
np.where(np.maximum(np.abs(xyz[...,1]),np.abs(xyz[...,2])) <= np.abs(xyz[...,0]),1,2))
return order[direction][p]

View File

@ -264,3 +264,18 @@ class TestRotation:
for h,c in zip(ho,co):
print(h,c)
assert np.allclose(conversion(h),c)
@pytest.mark.parametrize('direction',['forward',
'backward'])
def test_pyramid_vectorization(self,direction):
p = np.random.rand(n,3)
o = Rotation._get_order(p,direction)
for i,o_i in enumerate(o):
assert np.allclose(o_i,Rotation._get_order(p[i],direction))
def test_pyramid_invariant(self):
a = np.random.rand(n,3)
f = damask.Rotation._get_order(a,'forward')
b = damask.Rotation._get_order(a,'backward')
assert np.all(np.take_along_axis(np.take_along_axis(a,f,-1),b,-1) == a)