From 9fb3fef4b08d54abd0ebc289374f4d1c512e292c Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 8 Sep 2020 10:39:31 -0400 Subject: [PATCH] changed British "normalise" to US "normalize" as we (should) follow US English everywhere else. --- processing/post/addOrientations.py | 4 ++-- python/damask/_rotation.py | 8 ++++---- python/tests/test_Rotation.py | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/processing/post/addOrientations.py b/processing/post/addOrientations.py index 79da15fdd..51d668eb9 100755 --- a/processing/post/addOrientations.py +++ b/processing/post/addOrientations.py @@ -104,8 +104,8 @@ input = [options.eulers is not None, if np.sum(input) != 1: parser.error('needs exactly one input format.') -r = damask.Rotation.from_axis_angle(np.array(options.crystalrotation),options.degrees,normalise=True) -R = damask.Rotation.from_axis_angle(np.array(options.labrotation),options.degrees,normalise=True) +r = damask.Rotation.from_axis_angle(np.array(options.crystalrotation),options.degrees,normalize=True) +R = damask.Rotation.from_axis_angle(np.array(options.labrotation),options.degrees,normalize=True) for name in filenames: damask.util.report(scriptName,name) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 9ee7fd5cc..ac7b3ace8 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -408,7 +408,7 @@ class Rotation: @staticmethod def from_axis_angle(axis_angle, degrees = False, - normalise = False, + normalize = False, P = -1): """ Initialize from Axis angle pair. @@ -434,7 +434,7 @@ class Rotation: if P == 1: ax[...,0:3] *= -1 if degrees: ax[..., 3] = np.radians(ax[...,3]) - if normalise: ax[...,0:3] /= np.linalg.norm(ax[...,0:3],axis=-1) + if normalize: ax[...,0:3] /= np.linalg.norm(ax[...,0:3],axis=-1) if np.any(ax[...,3] < 0.0) or np.any(ax[...,3] > np.pi): raise ValueError('Axis angle rotation angle outside of [0..π].') if not np.all(np.isclose(np.linalg.norm(ax[...,0:3],axis=-1), 1.0)): @@ -493,7 +493,7 @@ class Rotation: @staticmethod def from_Rodrigues(rho, - normalise = False, + normalize = False, P = -1): """ Initialize from Rodrigues-Frank vector. @@ -516,7 +516,7 @@ class Rotation: raise ValueError('P ∉ {-1,1}') if P == 1: ro[...,0:3] *= -1 - if normalise: ro[...,0:3] /= np.linalg.norm(ro[...,0:3],axis=-1) + if normalize: ro[...,0:3] /= np.linalg.norm(ro[...,0:3],axis=-1) if np.any(ro[...,3] < 0.0): raise ValueError('Rodrigues vector rotation angle not positive.') if not np.all(np.isclose(np.linalg.norm(ro[...,0:3],axis=-1), 1.0)): diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 8b26a7472..3ed1f27c6 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -698,13 +698,13 @@ class TestRotation: assert ok and np.isclose(np.linalg.norm(o),1.0) @pytest.mark.parametrize('P',[1,-1]) - @pytest.mark.parametrize('normalise',[True,False]) + @pytest.mark.parametrize('normalize',[True,False]) @pytest.mark.parametrize('degrees',[True,False]) - def test_axis_angle(self,set_of_rotations,degrees,normalise,P): + def test_axis_angle(self,set_of_rotations,degrees,normalize,P): c = np.array([P*-1,P*-1,P*-1,1.]) for rot in set_of_rotations: m = rot.as_Eulers() - o = Rotation.from_axis_angle(rot.as_axis_angle(degrees)*c,degrees,normalise,P).as_Eulers() + o = Rotation.from_axis_angle(rot.as_axis_angle(degrees)*c,degrees,normalize,P).as_Eulers() u = np.array([np.pi*2,np.pi,np.pi*2]) ok = np.allclose(m,o,atol=atol) ok = ok or np.allclose(np.where(np.isclose(m,u),m-u,m),np.where(np.isclose(o,u),o-u,o),atol=atol) @@ -725,12 +725,12 @@ class TestRotation: assert ok and np.isclose(np.linalg.norm(o[:3]),1.0) and o[3]<=np.pi+1.e-9 @pytest.mark.parametrize('P',[1,-1]) - @pytest.mark.parametrize('normalise',[True,False]) - def test_Rodrigues(self,set_of_rotations,normalise,P): + @pytest.mark.parametrize('normalize',[True,False]) + def test_Rodrigues(self,set_of_rotations,normalize,P): c = np.array([P*-1,P*-1,P*-1,1.]) for rot in set_of_rotations: m = rot.as_matrix() - o = Rotation.from_Rodrigues(rot.as_Rodrigues()*c,normalise,P).as_matrix() + o = Rotation.from_Rodrigues(rot.as_Rodrigues()*c,normalize,P).as_matrix() ok = np.allclose(m,o,atol=atol) print(m,o) assert ok and np.isclose(np.linalg.det(o),1.0)