Repository navigation
Stop hiding numpy.msort() deprecation warnings with Masked arrays - #18173
Conversation
`numpy.msort()` was deprecated in version 1.24 and removed in 2.0. The updated test demonstrates that `astropy` erroneously hides the deprecation message if `msort()` is called with a `Masked` array.
Calling `numpy.msort()` with a `Masked` array no longer hides the deprecation message (with `numpy` 1.24-1.26).
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
| warnings.warn( | ||
| "msort is deprecated, use np.sort(a, axis=0) instead", | ||
| DeprecationWarning, |
There was a problem hiding this comment.
This is missing a stacklevel, but the call goes through <__array_function__ internals>, which apparently destroys Python's ability to do anything sensible with the stacklevel. This warning is only displayed for users that have astropy > 7.1.0 together with 1.24 <= numpy < 2.0. I would imagine most users have either a recent version of both or an old version of both, so the number of people that have the potential of seeing this warning is small enough that the stacklevel is not worth worrying about too much.
|
I don't think we should backport this. Nothing is really broken and extra warning in bugfix release would surprise people. Thanks for your understanding. |
mhvk
left a comment
There was a problem hiding this comment.
Thanks for catching that. I guess the underlying problem is that, unusually, this helper does not actually call the underlying function directly. Which in turn is probably because it was one of those functions I didn't even know about, but which turned up when we started to try to be sure that we covered all functions.
Anyway, let's get this in (I agree with @pllim on not backporting).
Description
numpy.msort()was deprecated in 1.24 and removed in 2.0, but despite that no warnings are emitted if the function is called with aMaskedarray. The first commit here reveals the bug, the second fixes it.The reason this went unnoticed was that the function that checks
np.msort()with aMaskedarray is skipped entirely unless the installednumpyversion is <1.24, where the function was not deprecated. We do have machinery that tries to check for the completeness of relevant tests, but that machinery only checks that an appropriate test function exists, not that it is called (which also has the charming consequence that removing a test that is always skipped can cause other tests to fail).