Skip to content

Commit a6e43a4

Browse files
COMPAT: Compat with numpy dev argsort (radix sort added) (#26373)
* Compat with numpy dev numpy/numpy@12fb101 adds radix sort to np.argsort. For versions of NumPy with this change (>=1.17), we need to adjust our validator. Closes #26361 * isort
1 parent e26aa00 commit a6e43a4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pandas/compat/numpy/function.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
easier to adjust to future upstream changes in the analogous numpy signatures.
1919
"""
2020
from collections import OrderedDict
21+
from distutils.version import LooseVersion
2122
from typing import Any, Dict, Optional, Union
2223

23-
from numpy import ndarray
24+
from numpy import __version__ as _np_version, ndarray
2425

2526
from pandas._libs.lib import is_bool, is_integer
2627
from pandas.errors import UnsupportedFunctionCall
@@ -107,6 +108,12 @@ def validate_argmax_with_skipna(skipna, args, kwargs):
107108
ARGSORT_DEFAULTS['axis'] = -1
108109
ARGSORT_DEFAULTS['kind'] = 'quicksort'
109110
ARGSORT_DEFAULTS['order'] = None
111+
112+
if LooseVersion(_np_version) >= LooseVersion("1.17.0"):
113+
# GH-26361. NumPy added radix sort and changed default to None.
114+
ARGSORT_DEFAULTS['kind'] = None
115+
116+
110117
validate_argsort = CompatValidator(ARGSORT_DEFAULTS, fname='argsort',
111118
max_fname_arg_count=0, method='both')
112119

pandas/tests/groupby/test_groupby.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
import pandas as pd
1212
from pandas import (
13-
DataFrame, Index, MultiIndex, Series, Timestamp, date_range,
14-
read_csv)
13+
DataFrame, Index, MultiIndex, Series, Timestamp, date_range, read_csv)
1514
import pandas.core.common as com
1615
import pandas.util.testing as tm
1716
from pandas.util.testing import (

0 commit comments

Comments
 (0)