Skip to content

Commit

Permalink
Merge pull request #391 from glotzerlab/fix/rotational-invariance-tests
Browse files Browse the repository at this point in the history
Fix rotational invariance tests on CI
  • Loading branch information
vyasr authored Aug 20, 2019
2 parents 3b97ede + b6dfcd3 commit b483a83
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ references:
# Install from and test all wheels
for PYBIN in /opt/python/*/bin/; do
"${PYBIN}/python" -m pip install freud_analysis --no-deps --no-index -f ~/ci/freud/wheelhouse
"${PYBIN}/python" -m pip install rowan sympy
cd ~/ci/freud/tests
"${PYBIN}/python" -m unittest discover . -v
done
Expand Down Expand Up @@ -286,6 +287,7 @@ references:
for VERSION in ${PY_VERSIONS[@]}; do
pyenv global ${VERSION}
pip install freud_analysis --no-deps --no-index -f ~/ci/freud/wheelhouse
pip install rowan sympy
cd ~/ci/freud/tests
python -m unittest discover . -v
done
Expand Down
8 changes: 4 additions & 4 deletions tests/test_order_LocalQl.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ def test_rotational_invariance(self):
quat = rowan.random.rand()
positions_rotated = rowan.rotate(quat, positions)
q6.compute(positions_rotated, nlist=nlist)
npt.assert_almost_equal(q6.Ql[0], q6_unrotated_order)
npt.assert_almost_equal(q6.Ql[0], PERFECT_FCC_Q6)
npt.assert_allclose(q6.Ql[0], q6_unrotated_order, rtol=1e-5)
npt.assert_allclose(q6.Ql[0], PERFECT_FCC_Q6, rtol=1e-5)


class TestLocalQlNear(unittest.TestCase):
Expand Down Expand Up @@ -282,8 +282,8 @@ def test_rotational_invariance(self):
quat = rowan.random.rand()
positions_rotated = rowan.rotate(quat, positions)
q6.compute(positions_rotated, nlist=nlist)
npt.assert_almost_equal(q6.Ql[0], q6_unrotated_order)
npt.assert_almost_equal(q6.Ql[0], PERFECT_FCC_Q6)
npt.assert_allclose(q6.Ql[0], q6_unrotated_order, rtol=1e-5)
npt.assert_allclose(q6.Ql[0], PERFECT_FCC_Q6, rtol=1e-5)


if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions tests/test_order_LocalWl.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def test_rotational_invariance(self):
quat = rowan.random.rand()
positions_rotated = rowan.rotate(quat, positions)
w6.compute(positions_rotated, nlist=nlist)
npt.assert_almost_equal(w6.Wl[0], w6_unrotated_order)
npt.assert_almost_equal(w6.Wl[0], PERFECT_FCC_W6)
npt.assert_allclose(w6.Wl[0], w6_unrotated_order, rtol=1e-5)
npt.assert_allclose(w6.Wl[0], PERFECT_FCC_W6, rtol=1e-5)


class TestLocalWlNear(unittest.TestCase):
Expand Down Expand Up @@ -278,8 +278,8 @@ def test_rotational_invariance(self):
quat = rowan.random.rand()
positions_rotated = rowan.rotate(quat, positions)
w6.compute(positions_rotated, nlist=nlist)
npt.assert_almost_equal(w6.Wl[0], w6_unrotated_order)
npt.assert_almost_equal(w6.Wl[0], PERFECT_FCC_W6)
npt.assert_allclose(w6.Wl[0], w6_unrotated_order, rtol=1e-5)
npt.assert_allclose(w6.Wl[0], PERFECT_FCC_W6, rtol=1e-5)


if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions tests/test_order_Steinhardt.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ def test_rotational_invariance(self):

# Ensure Q6 is rotationally invariant
q6.compute(box, positions_rotated, nlist=nlist)
npt.assert_almost_equal(q6.order[0], q6_unrotated_order)
npt.assert_almost_equal(q6.order[0], PERFECT_FCC_Q6)
npt.assert_allclose(q6.order[0], q6_unrotated_order, rtol=1e-5)
npt.assert_allclose(q6.order[0], PERFECT_FCC_Q6, rtol=1e-5)

# Ensure W6 is rotationally invariant
w6.compute(box, positions_rotated, nlist=nlist)
npt.assert_almost_equal(w6.order[0], w6_unrotated_order)
npt.assert_almost_equal(w6.order[0], PERFECT_FCC_W6)
npt.assert_allclose(w6.order[0], w6_unrotated_order, rtol=1e-5)
npt.assert_allclose(w6.order[0], PERFECT_FCC_W6, rtol=1e-5)

def test_repr(self):
comp = freud.order.Steinhardt(1.5, 6)
Expand Down

0 comments on commit b483a83

Please sign in to comment.