Skip to content

Commit

Permalink
Adding improper rotations to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ifilot committed Jun 21, 2023
1 parent 844a627 commit ce92e3e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: "sphecerix"
version: "0.3.0"
version: "0.4.0"

source:
path: .
Expand Down
2 changes: 1 addition & 1 deletion sphecerix/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.0"
__version__ = "0.4.0"
38 changes: 38 additions & 0 deletions tests/test_improper_rotation.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit ce92e3e

Please sign in to comment.