rpoleski / MulensModel

Microlensing Modelling package
https://rpoleski.github.io/MulensModel/
Other
57 stars 15 forks source link

DeprecationWarning from NumPy in test_Model.py #127

Closed rapoliveira closed 7 months ago

rapoliveira commented 8 months ago

The automated tests using NumPy >= v1.25 present this DeprecationWarning:

source/MulensModel/tests/test_Model.py::test_BLPS_shear_active
  /Users/raphael/postdoc/MulensModel_raphael/source/MulensModel/tests/test_Model.py:182: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    assert not isclose(magnification, 4.691830781584699, abs_tol=1e-2)

The release notes from NumPy explains the change, which is related to not treating arrays of size 1 as scalars anymore.

Changing magnification to magnification[0] in test_BLPS_shear_active() solves it. I will do it!

rpoleski commented 8 months ago

The above one is easy. Though, I see you also changed integrate.simps to integrate.simpson. Did scipy just change the name of the function? If so, then do you know when?

rpoleski commented 7 months ago

The main part done in 62d83c1.

rapoliveira commented 7 months ago

This DeprecationWarning also appeared in the automated tests:

DeprecationWarning: 'scipy.integrate.simps' is deprecated in favour of 'scipy.integrate.simpson' and will be removed in SciPy 1.14.0

I found that integrate.simpson was added in version 1.11.0 and integrate.simps will be removed in the next SciPy minor release.

rpoleski commented 7 months ago

Please add an if statement that decides which function to use based on scipy.__version__ and then this function is used.

rapoliveira commented 7 months ago

Done! Based on the discussion in commit fe58801, I added a try-except block instead.

rpoleski commented 7 months ago

Thanks. Suggestion: never use bare except. Reason: the code cannot be killed by Ctrl-C etc.