Skip to content

Commit

Permalink
Clean test for vector conversion overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-Tehrani committed Aug 5, 2020
1 parent e8152c4 commit 5ae1c32
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions iodata/test/test_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ def test_converting_from_cartesian_to_pure():
overlap_cp = tfs[2]
coeff = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
coeff2 = convert_vector_basis(coeff, np.eye(5), overlap_cp)
desired = np.array([-0.5 - 0.5 * 4.0 + 6.0, 3.0, 5.0,
0.86602540378 * 1.0 - 0.86602540378 * 4.0, 2.0])
desired = overlap_cp.dot(coeff)
assert_allclose(coeff2, desired)


Expand All @@ -173,13 +172,12 @@ def test_converting_from_pure_to_cartesian():
overlap_cp = tfs[1]
coeff = np.array([1., 2., 3.])
coeff2 = convert_vector_basis(coeff, np.eye(3), overlap_cp.T)
desired = np.array([2., 3., 1.])
desired = np.linalg.lstsq(overlap_cp, coeff, rcond=None)[0]
assert_equal(coeff2, desired)

# Test converting D-type.
overlap_cp = tfs[2]
coeff = np.array([1., 2., 3., 4., 5.])
coeff2 = convert_vector_basis(coeff, np.eye(6), overlap_cp.T)
desired = np.array([np.sqrt(3.0) * 4.0 / 2.0 - 0.5, 5.0, 2.0,
-np.sqrt(3.0) * 4.0 / 2.0 - 0.5, 3.0, 1.0])
assert_equal(coeff2, desired)
pcoeff = np.array([1., 2., 3., 4., 5.])
ccoeff = convert_vector_basis(pcoeff, np.eye(6), np.linalg.pinv(overlap_cp))
desired = np.linalg.lstsq(overlap_cp, pcoeff, rcond=None)[0]
assert_allclose(ccoeff, desired)

0 comments on commit 5ae1c32

Please sign in to comment.