Skip to content

Commit 9f2143f

Browse files
committed
fix compat with numpy<1.24
1 parent af1a6e8 commit 9f2143f

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎astropy/units/quantity_helper/function_helpers.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
dimensionless_unscaled,
4848
)
4949
from astropy.utils import isiterable
50-
from astropy.utils.compat import NUMPY_LT_1_23, NUMPY_LT_2_0
50+
from astropy.utils.compat import NUMPY_LT_1_23, NUMPY_LT_1_24, NUMPY_LT_2_0
5151

5252
if NUMPY_LT_2_0:
5353
import numpy.core as np_core
@@ -918,16 +918,26 @@ def unique(
918918
return_counts=False,
919919
axis=None,
920920
*,
921-
equal_nan=True, # new in numpy 1.24
921+
equal_nan=None, # new in numpy 1.24
922922
):
923923
unit = ar.unit
924924
n_index = sum(bool(i) for i in (return_index, return_inverse, return_counts))
925925
if n_index:
926926
unit = [unit] + n_index * [None]
927927

928+
if NUMPY_LT_1_24:
929+
if equal_nan is not None:
930+
raise TypeError("unique() got an unexpected keyword argument 'equal_nan'")
931+
else:
932+
kwargs = {}
933+
else:
934+
if equal_nan is None:
935+
equal_nan = False
936+
kwargs = {"equal_nan": equal_nan}
937+
928938
return (
929939
(ar.value, return_index, return_inverse, return_counts, axis),
930-
{"equal_nan": equal_nan},
940+
kwargs,
931941
unit,
932942
None,
933943
)

0 commit comments

Comments
 (0)