|
15 | 15 | import numpy as np |
16 | 16 |
|
17 | 17 | from astropy.units.quantity_helper.function_helpers import FunctionAssigner |
18 | | -from astropy.utils.compat import NUMPY_LT_1_24, NUMPY_LT_2_0, NUMPY_LT_2_1, NUMPY_LT_2_2 |
| 18 | +from astropy.utils.compat import NUMPY_LT_2_0, NUMPY_LT_2_1, NUMPY_LT_2_2 |
19 | 19 |
|
20 | 20 | if NUMPY_LT_2_0: |
21 | 21 | import numpy.core as np_core |
@@ -571,11 +571,9 @@ def bincount(x, weights=None, minlength=0): |
571 | 571 |
|
572 | 572 | @dispatched_function |
573 | 573 | def msort(a): |
574 | | - if not NUMPY_LT_1_24: |
575 | | - warnings.warn( |
576 | | - "msort is deprecated, use np.sort(a, axis=0) instead", |
577 | | - DeprecationWarning, |
578 | | - ) |
| 574 | + warnings.warn( |
| 575 | + "msort is deprecated, use np.sort(a, axis=0) instead", DeprecationWarning |
| 576 | + ) |
579 | 577 | result = a.copy() |
580 | 578 | result.sort(axis=0) |
581 | 579 | return result, None, None |
@@ -749,27 +747,14 @@ def median(a, axis=None, out=None, overwrite_input=False, keepdims=False): |
749 | 747 | if out is not None and not isinstance(out, Masked): |
750 | 748 | raise NotImplementedError |
751 | 749 |
|
752 | | - a = Masked(a) |
753 | | - |
754 | | - if NUMPY_LT_1_24: |
755 | | - r, k = _ureduce( |
756 | | - a, |
757 | | - func=_masked_median, |
758 | | - axis=axis, |
759 | | - out=out, |
760 | | - overwrite_input=overwrite_input, |
761 | | - ) |
762 | | - result = (r.reshape(k) if keepdims else r) if out is None else out |
763 | | - |
764 | | - else: |
765 | | - result = _ureduce( |
766 | | - a, |
767 | | - func=_masked_median, |
768 | | - axis=axis, |
769 | | - out=out, |
770 | | - overwrite_input=overwrite_input, |
771 | | - keepdims=keepdims, |
772 | | - ) |
| 750 | + result = _ureduce( |
| 751 | + Masked(a), |
| 752 | + func=_masked_median, |
| 753 | + axis=axis, |
| 754 | + out=out, |
| 755 | + overwrite_input=overwrite_input, |
| 756 | + keepdims=keepdims, |
| 757 | + ) |
773 | 758 | return result, None, None |
774 | 759 |
|
775 | 760 |
|
@@ -832,36 +817,7 @@ def _preprocess_quantile(a, q, axis=None, out=None, **kwargs): |
832 | 817 | return a, q, axis, out, kwargs |
833 | 818 |
|
834 | 819 |
|
835 | | -if NUMPY_LT_1_24: |
836 | | - |
837 | | - @dispatched_function |
838 | | - def quantile( |
839 | | - a, |
840 | | - q, |
841 | | - axis=None, |
842 | | - out=None, |
843 | | - overwrite_input=False, |
844 | | - method="linear", |
845 | | - keepdims=False, |
846 | | - *, |
847 | | - interpolation=None, |
848 | | - ): |
849 | | - a, q, axis, out, kwargs = _preprocess_quantile( |
850 | | - a, |
851 | | - q, |
852 | | - axis, |
853 | | - out, |
854 | | - overwrite_input=overwrite_input, |
855 | | - method=method, |
856 | | - keepdims=keepdims, |
857 | | - interpolation=interpolation, |
858 | | - ) |
859 | | - keepdims = kwargs.pop("keepdims", False) |
860 | | - r, k = _ureduce(a, func=_masked_quantile, q=q, axis=axis, out=out, **kwargs) |
861 | | - result = (r.reshape(q.shape + k) if keepdims else r) if out is None else out |
862 | | - return result, None, None |
863 | | - |
864 | | -elif NUMPY_LT_2_0: |
| 820 | +if NUMPY_LT_2_0: |
865 | 821 |
|
866 | 822 | @dispatched_function |
867 | 823 | def quantile( |
@@ -1446,33 +1402,18 @@ def _copy_of_mask(a): |
1446 | 1402 | return mask.copy() if mask is not None else False |
1447 | 1403 |
|
1448 | 1404 |
|
1449 | | -if NUMPY_LT_1_24: # "kind" argument introduced in 1.24. |
1450 | | - |
1451 | | - @dispatched_function |
1452 | | - def in1d(ar1, ar2, assume_unique=False, invert=False): |
1453 | | - mask = _copy_of_mask(ar1).ravel() |
1454 | | - return _in1d(ar1, ar2, assume_unique, invert), mask, None |
1455 | | - |
1456 | | - @dispatched_function |
1457 | | - def isin(element, test_elements, assume_unique=False, invert=False): |
1458 | | - element = np.asanyarray(element) |
1459 | | - result = _in1d(element, test_elements, assume_unique, invert) |
1460 | | - result.shape = element.shape |
1461 | | - return result, _copy_of_mask(element), None |
1462 | | - |
1463 | | -else: |
| 1405 | +@dispatched_function |
| 1406 | +def in1d(ar1, ar2, assume_unique=False, invert=False, *, kind=None): |
| 1407 | + mask = _copy_of_mask(ar1).ravel() |
| 1408 | + return _in1d(ar1, ar2, assume_unique, invert, kind=kind), mask, None |
1464 | 1409 |
|
1465 | | - @dispatched_function |
1466 | | - def in1d(ar1, ar2, assume_unique=False, invert=False, *, kind=None): |
1467 | | - mask = _copy_of_mask(ar1).ravel() |
1468 | | - return _in1d(ar1, ar2, assume_unique, invert, kind=kind), mask, None |
1469 | 1410 |
|
1470 | | - @dispatched_function |
1471 | | - def isin(element, test_elements, assume_unique=False, invert=False, *, kind=None): |
1472 | | - element = np.asanyarray(element) |
1473 | | - result = _in1d(element, test_elements, assume_unique, invert, kind=kind) |
1474 | | - result.shape = element.shape |
1475 | | - return result, _copy_of_mask(element), None |
| 1411 | +@dispatched_function |
| 1412 | +def isin(element, test_elements, assume_unique=False, invert=False, *, kind=None): |
| 1413 | + element = np.asanyarray(element) |
| 1414 | + result = _in1d(element, test_elements, assume_unique, invert, kind=kind) |
| 1415 | + result.shape = element.shape |
| 1416 | + return result, _copy_of_mask(element), None |
1476 | 1417 |
|
1477 | 1418 |
|
1478 | 1419 | @dispatched_function |
|
0 commit comments