Skip to content

Commit

Permalink
Merge pull request #26 from santisoler/fix-python-tests
Browse files Browse the repository at this point in the history
[JOSS Review] Improve Python tests and unpin Numpy version
  • Loading branch information
schuhmaj authored Mar 13, 2024
2 parents f6b6575 + 86fd2f4 commit fa2dba3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: polyhedral-gravity-env
channels:
- conda-forge
dependencies:
- numpy==1.23.4
- numpy
- pytest
- pytest-xdist
30 changes: 12 additions & 18 deletions test/python/test_polyhedral_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ def test_polyhedral_gravity(
computation_points=points,
parallel=True
)
sol = np.array([np.array(x) for x in sol])
actual_potential = sol[:, 0].flatten()
assert np.testing.assert_array_almost_equal(actual_potential, expected_potential) is None

actual_acceleration = np.array([np.array(x) for x in sol[:, 1]])
assert np.testing.assert_array_almost_equal(actual_acceleration, expected_acceleration) is None
potential = np.array([result[0] for result in sol])
acceleration = np.array([result[1] for result in sol])
np.testing.assert_array_almost_equal(potential, expected_potential)
np.testing.assert_array_almost_equal(acceleration, expected_acceleration)


@pytest.mark.parametrize(
Expand All @@ -92,12 +90,10 @@ def test_polyhedral_gravity_evaluable(
computation_points=points,
parallel=True
)
sol = np.array([np.array(x) for x in sol])
actual_potential = sol[:, 0].flatten()
assert np.testing.assert_array_almost_equal(actual_potential, expected_potential) is None

actual_acceleration = np.array([np.array(x) for x in sol[:, 1]])
assert np.testing.assert_array_almost_equal(actual_acceleration, expected_acceleration) is None
potential = np.array([result[0] for result in sol])
acceleration = np.array([result[1] for result in sol])
np.testing.assert_array_almost_equal(potential, expected_potential)
np.testing.assert_array_almost_equal(acceleration, expected_acceleration)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -128,9 +124,7 @@ def test_polyhedral_evaluable_pickle(
computation_points=points,
parallel=True
)
sol = np.array([np.array(x) for x in sol])
actual_potential = sol[:, 0].flatten()
assert np.testing.assert_array_almost_equal(actual_potential, expected_potential) is None

actual_acceleration = np.array([np.array(x) for x in sol[:, 1]])
assert np.testing.assert_array_almost_equal(actual_acceleration, expected_acceleration) is None
potential = np.array([result[0] for result in sol])
acceleration = np.array([result[1] for result in sol])
np.testing.assert_array_almost_equal(potential, expected_potential)
np.testing.assert_array_almost_equal(acceleration, expected_acceleration)

0 comments on commit fa2dba3

Please sign in to comment.