Skip to content

Commit

Permalink
fix test to check for imposible boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
DomFijan committed Apr 23, 2024
1 parent b51d8d7 commit d78e08e
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions tests/test_box_Box.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,35 @@ def test_to_and_from_box_lengths_and_angles(self):
np.random.uniform(0, np.pi),
np.random.uniform(0, np.pi),
)
box = freud.box.Box.from_box_lengths_and_angles(
*original_box_lengths_and_angles
)
lengths_and_angles_computed = box.to_box_lengths_and_angles()
np.testing.assert_allclose(
lengths_and_angles_computed,
original_box_lengths_and_angles,
rtol=1e-6,
atol=1e-14,
)
if (
1
- np.cos(original_box_lengths_and_angles[4]) ** 2
- (
(
np.cos(original_box_lengths_and_angles[3])
- np.cos(original_box_lengths_and_angles[4])
* np.cos(original_box_lengths_and_angles[5])
)
/ np.sin(original_box_lengths_and_angles[5])
)
** 2
< 0
):
with pytest.raises(ValueError):
freud.box.Box.from_box_lengths_and_angles(
*original_box_lengths_and_angles
)
else:
box = freud.box.Box.from_box_lengths_and_angles(
*original_box_lengths_and_angles
)
lengths_and_angles_computed = box.to_box_lengths_and_angles()
np.testing.assert_allclose(
lengths_and_angles_computed,
original_box_lengths_and_angles,
rtol=1e-6,
atol=1e-14,
)

def test_matrix(self):
box = freud.box.Box(2, 2, 2, 1, 0.5, 0.1)
Expand Down

0 comments on commit d78e08e

Please sign in to comment.