From ce92e3e12ade9da6f39eb620caa0474041af4478 Mon Sep 17 00:00:00 2001 From: ifilot Date: Wed, 21 Jun 2023 09:05:45 +0200 Subject: [PATCH] Adding improper rotations to tests --- meta.yaml | 2 +- sphecerix/_version.py | 2 +- tests/test_improper_rotation.py | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/test_improper_rotation.py diff --git a/meta.yaml b/meta.yaml index ade951f..2f2b103 100644 --- a/meta.yaml +++ b/meta.yaml @@ -1,6 +1,6 @@ package: name: "sphecerix" - version: "0.3.0" + version: "0.4.0" source: path: . diff --git a/sphecerix/_version.py b/sphecerix/_version.py index f2b3589..49c37a8 100644 --- a/sphecerix/_version.py +++ b/sphecerix/_version.py @@ -1 +1 @@ -__version__ = "0.3.0" \ No newline at end of file +__version__ = "0.4.0" \ No newline at end of file diff --git a/tests/test_improper_rotation.py b/tests/test_improper_rotation.py new file mode 100644 index 0000000..4f902f5 --- /dev/null +++ b/tests/test_improper_rotation.py @@ -0,0 +1,38 @@ +import unittest +import numpy as np +import sys +import os +from scipy.spatial.transform import Rotation as R + +# add a reference to load the Sphecerix library +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +# import functions +from sphecerix import tesseral_wigner_D_improper + +class TestImproperRotation(unittest.TestCase): + """ + Test improper rotation matrices + """ + + def test_improper_s4(self): + """ + Test the result under an improper rotation + """ + # construct rotation vector + axis = np.array([1,0,0]) + Robj = R.from_rotvec(axis * np.pi / 2) + + # construct wigner D matrix + D = tesseral_wigner_D_improper(1, Robj) + + # assert that determinant is -1 + np.testing.assert_almost_equal(np.linalg.det(D), -1) + + # rotate a point at +x,+y,+z under S4 to -x,-y,+z + # note that the ordering in the vector (using increasing value of m) + # is [y,z,x] + np.testing.assert_almost_equal(D @ np.array([1,1,1]), np.array([-1,1,-1])) + +if __name__ == '__main__': + unittest.main()