def test_cart_pure_s(): work_cart = np.random.normal(0, 1, 1) work_pure = np.random.normal(0, 1, 1) _cart_to_pure_low(work_cart, work_pure, shell_type=0, nant=1, npost=1) assert abs(work_cart - work_pure).max() < 1e-10 work_cart = np.random.normal(0, 1, 10) work_pure = np.random.normal(0, 1, 10) _cart_to_pure_low(work_cart, work_pure, shell_type=0, nant=2, npost=5) assert abs(work_cart - work_pure).max() < 1e-10
def test_cart_pure_domain(): work_cart = np.random.normal(0, 1, (3, 70)) work_pure = np.random.normal(0, 1, (3, 70)) with assert_raises(ValueError): _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=_get_max_shell_type() + 1, nant=1, npost=1) with assert_raises(ValueError): _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=-1, nant=1, npost=1) with assert_raises(ValueError): _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=3, nant=0, npost=1) with assert_raises(ValueError): _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=3, nant=1, npost=0)
def test_cart_pure_g(): tf = tfs[4] work_cart = np.random.normal(0, 1, 15) work_pure = np.random.normal(0, 1, 9) _cart_to_pure_low(work_cart, work_pure, shell_type=4, nant=1, npost=1) assert abs(np.dot(tf, work_cart) - work_pure).max() < 1e-10 work_cart = np.random.normal(0, 1, (3, 15)) work_pure = np.random.normal(0, 1, (3, 9)) _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=4, nant=3, npost=1) assert abs(np.dot(work_cart[:, :15], tf.T) - work_pure).max() < 1e-10
def test_cart_pure_p(): work_cart = np.random.normal(0, 1, 3) work_pure = np.random.normal(0, 1, 3) _cart_to_pure_low(work_cart, work_pure, shell_type=1, nant=1, npost=1) assert abs(work_cart[[2, 0, 1]] - work_pure).max() < 1e-10 work_cart = np.random.normal(0, 1, (10, 3)) work_pure = np.random.normal(0, 1, (10, 3)) _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=1, nant=10, npost=1) assert abs(work_cart[:, [2, 0, 1]] - work_pure).max() < 1e-10 work_cart = np.random.normal(0, 1, (10, 3, 2)) work_pure = np.random.normal(0, 1, (10, 3, 2)) _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=1, nant=10, npost=2) assert abs(work_cart[:, [2, 0, 1], :] - work_pure).max() < 1e-10 work_cart = np.random.normal(0, 1, (3, 6)) work_pure = np.random.normal(0, 1, (3, 6)) _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=1, nant=1, npost=6) assert abs(work_cart[[2, 0, 1], :] - work_pure).max() < 1e-10 work_cart = np.random.normal(0, 1, (5, 2, 3, 2, 3)) work_pure = np.random.normal(0, 1, (5, 2, 3, 2, 3)) _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=1, nant=10, npost=6) assert abs(work_cart[:, :, [2, 0, 1], :, :] - work_pure).max() < 1e-10
def test_cart_pure_d(): tf = tfs[2] work_cart = np.random.normal(0, 1, 6) work_pure = np.random.normal(0, 1, 5) _cart_to_pure_low(work_cart, work_pure, shell_type=2, nant=1, npost=1) assert abs(np.dot(tf, work_cart) - work_pure[:5]).max() < 1e-10 work_cart = np.random.normal(0, 1, (10, 6)) work_pure = np.random.normal(0, 1, (10, 5)) _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=2, nant=10, npost=1) assert abs(np.dot(work_cart, tf.T) - work_pure).max() < 1e-10 work_cart = np.random.normal(0, 1, (6, 10)) work_pure = np.random.normal(0, 1, (5, 10)) _cart_to_pure_low(work_cart.reshape(-1), work_pure.reshape(-1), shell_type=2, nant=1, npost=10) assert abs(np.dot(tf, work_cart) - work_pure).max() < 1e-10