Skip to content

Commit b26362d

Browse files
committed
Update a test to reveal a utils.masked bug
`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.
1 parent 33adcd6 commit b26362d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎astropy/utils/masked/tests/test_function_helpers.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
"""
1313

14+
import contextlib
1415
import itertools
1516

1617
import numpy as np
@@ -1269,9 +1270,18 @@ def test_sort_complex(self):
12691270
expected = ma[np.lexsort((ma.unmasked.imag, ma.unmasked.real, ma.mask))]
12701271
assert_masked_equal(o, expected)
12711272

1272-
@pytest.mark.skipif(not NUMPY_LT_1_24, reason="np.msort is deprecated")
1273+
@pytest.mark.skipif(not NUMPY_LT_2_0, reason="np.msort was removed in numpy 2.0")
1274+
@pytest.mark.xfail(
1275+
condition=not NUMPY_LT_1_24,
1276+
reason="astropy erroneously hides an upstream deprecation message",
1277+
)
12731278
def test_msort(self):
1274-
o = np.msort(self.ma)
1279+
with (
1280+
contextlib.nullcontext()
1281+
if NUMPY_LT_1_24
1282+
else pytest.warns(DeprecationWarning, match="msort is deprecated")
1283+
):
1284+
o = np.msort(self.ma)
12751285
expected = np.sort(self.ma, axis=0)
12761286
assert_masked_equal(o, expected)
12771287

0 commit comments

Comments
 (0)