[JOSS Review] Improve Python tests and unpin Numpy version #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve Python tests to work with latest Numpy version. Modify how the potential and acceleration are retrieved from the solution returned by
evaluate()
andGravityEvaluable
in test functions so they can run with the latest Numpy versions. The previous tests were trying to generate an array from ragged tuples, which is no longer supported by Numpy. Also, modify theassert np.testing.assert_almost_equal() is None
lines since the Numpy testing functions always returnNone
. Unpin Numpy version inenvironment.yml
file.@schuhmaj I took some liberties here and made a few changes that I think worth taking a look at. I noticed that the Python tests were only running using the pinned version of Numpy you have in the
environment.yml
file, but not with the latest ones. The reason of this was the lines that try to convert the solutions (a list of tuples) into an array:polyhedral-gravity-model/test/python/test_polyhedral_gravity.py
Line 68 in ebe47ec
Each element in
sol
is a tuple with the three fields, and each one of them has different number of elements:Numpy v1.23.4 is raising a deprecation warning when trying to convert this ragged lists to an array:
This means that this line of code won't work with newer Numpy versions (like the latest one, v1.26.4).
The solution I suggest in this PR is to grab the results for the potential and the acceleration for each computation point directly from the
sol
variable (see lines changed in this PR).I also unpinned Numpy in the
environment.yml
file since tests should run using the latest Numpy version.Moreover, I modified the
assert
lines. Thenumpy.testing.assert...()
functions always returnNone
, so asserting if their outputs are None is trivial. Instead it's better to just leave these function calls as they are (see the changed lines in this PR).Let me know what do you think about this, and feel free to ask any question, and suggest or push changes if you desire to.
This PR is part of the JOSS review: openjournals/joss-reviews#6384