Skip to content

Commit

Permalink
COMPAT: Compat with numpy dev argsort (radix sort added) (#26373)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
TomAugspurger committed May 13, 2019
1 parent e26aa00 commit a6e43a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 8 additions & 1 deletion pandas/compat/numpy/function.py
Expand Up @@ -18,9 +18,10 @@
easier to adjust to future upstream changes in the analogous numpy signatures.
"""
from collections import OrderedDict
from distutils.version import LooseVersion
from typing import Any, Dict, Optional, Union

from numpy import ndarray
from numpy import __version__ as _np_version, ndarray

from pandas._libs.lib import is_bool, is_integer
from pandas.errors import UnsupportedFunctionCall
Expand Down Expand Up @@ -107,6 +108,12 @@ def validate_argmax_with_skipna(skipna, args, kwargs):
ARGSORT_DEFAULTS['axis'] = -1
ARGSORT_DEFAULTS['kind'] = 'quicksort'
ARGSORT_DEFAULTS['order'] = None

if LooseVersion(_np_version) >= LooseVersion("1.17.0"):
# GH-26361. NumPy added radix sort and changed default to None.
ARGSORT_DEFAULTS['kind'] = None


validate_argsort = CompatValidator(ARGSORT_DEFAULTS, fname='argsort',
max_fname_arg_count=0, method='both')

Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/groupby/test_groupby.py
Expand Up @@ -10,8 +10,7 @@

import pandas as pd
from pandas import (
DataFrame, Index, MultiIndex, Series, Timestamp, date_range,
read_csv)
DataFrame, Index, MultiIndex, Series, Timestamp, date_range, read_csv)
import pandas.core.common as com
import pandas.util.testing as tm
from pandas.util.testing import (
Expand Down

0 comments on commit a6e43a4

Please sign in to comment.