Skip to content

Commit

Permalink
CLN: Standardize searchsorted signatures (#22670)
Browse files Browse the repository at this point in the history
The parameter is "value" across the board.

xref gh-14645.
  • Loading branch information
gfyoung authored Sep 13, 2018
1 parent 0473aab commit ba2720b
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 27 deletions.
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ Removal of prior version deprecations/changes
- Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`)
- :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats`` (:issue:`14645`)
- Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`, :issue:`6581`)
- :meth:`Categorical.searchsorted` and :meth:`Series.searchsorted` have renamed the ``v`` argument to ``value`` (:issue:`14645`)
- :meth:`TimedeltaIndex.searchsorted`, :meth:`DatetimeIndex.searchsorted`, and :meth:`PeriodIndex.searchsorted` have renamed the ``key`` argument to ``value`` (:issue:`14645`)

.. _whatsnew_0240.performance:

Expand Down
1 change: 0 additions & 1 deletion pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,6 @@ def memory_usage(self, deep=False):

@Substitution(klass='Categorical')
@Appender(_shared_docs['searchsorted'])
@deprecate_kwarg(old_arg_name='v', new_arg_name='value')
def searchsorted(self, value, side='left', sorter=None):
if not self.ordered:
raise ValueError("Categorical not ordered\nyou can use "
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import pandas._libs.lib as lib
from pandas.compat.numpy import function as nv
from pandas.compat import PYPY, OrderedDict
from pandas.util._decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)
from pandas.util._decorators import Appender, cache_readonly, Substitution

from pandas.core.accessor import DirNamesMixin

Expand Down Expand Up @@ -1228,7 +1227,6 @@ def factorize(self, sort=False, na_sentinel=-1):

@Substitution(klass='IndexOpsMixin')
@Appender(_shared_docs['searchsorted'])
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
def searchsorted(self, value, side='left', sorter=None):
# needs coercion on the key (DatetimeIndex does already)
return self.values.searchsorted(value, side=side, sorter=sorter)
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
generate_range, CDay, prefix_mapping)

from pandas.core.tools.timedeltas import to_timedelta
from pandas.util._decorators import (
Appender, cache_readonly, deprecate_kwarg, Substitution)
from pandas.util._decorators import Appender, cache_readonly, Substitution
import pandas.core.common as com
import pandas.tseries.offsets as offsets
import pandas.core.tools.datetimes as tools
Expand Down Expand Up @@ -1375,7 +1374,6 @@ def normalize(self):

@Substitution(klass='DatetimeIndex')
@Appender(_shared_docs['searchsorted'])
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
def searchsorted(self, value, side='left', sorter=None):
if isinstance(value, (np.ndarray, Index)):
value = np.array(value, dtype=_NS_DTYPE, copy=False)
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
from pandas.core.indexes.base import _index_shared_docs, ensure_index

from pandas import compat
from pandas.util._decorators import (Appender, Substitution, cache_readonly,
deprecate_kwarg)
from pandas.util._decorators import Appender, Substitution, cache_readonly

import pandas.core.indexes.base as ibase
_index_doc_kwargs = dict(ibase._index_doc_kwargs)
Expand Down Expand Up @@ -426,7 +425,6 @@ def astype(self, dtype, copy=True, how='start'):

@Substitution(klass='PeriodIndex')
@Appender(_shared_docs['searchsorted'])
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
def searchsorted(self, value, side='left', sorter=None):
if isinstance(value, Period):
if value.freq != self.freq:
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/indexes/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from pandas.core.indexes.base import _index_shared_docs
import pandas.core.common as com
import pandas.core.dtypes.concat as _concat
from pandas.util._decorators import Appender, Substitution, deprecate_kwarg
from pandas.util._decorators import Appender, Substitution
from pandas.core.indexes.datetimelike import (
TimelikeOps, DatetimeIndexOpsMixin, wrap_arithmetic_op)
from pandas.core.tools.timedeltas import (
Expand Down Expand Up @@ -609,7 +609,6 @@ def _partial_td_slice(self, key, freq, use_lhs=True, use_rhs=True):

@Substitution(klass='TimedeltaIndex')
@Appender(_shared_docs['searchsorted'])
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
def searchsorted(self, value, side='left', sorter=None):
if isinstance(value, (np.ndarray, Index)):
value = np.array(value, dtype=_TD_DTYPE, copy=False)
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
import pandas.core.indexes.base as ibase

import pandas.io.formats.format as fmt
from pandas.util._decorators import (
Appender, deprecate, deprecate_kwarg, Substitution)
from pandas.util._decorators import Appender, deprecate, Substitution
from pandas.util._validators import validate_bool_kwarg

from pandas._libs import index as libindex, tslibs, lib, iNaT
Expand Down Expand Up @@ -2089,7 +2088,6 @@ def __rmatmul__(self, other):

@Substitution(klass='Series')
@Appender(base._shared_docs['searchsorted'])
@deprecate_kwarg(old_arg_name='v', new_arg_name='value')
def searchsorted(self, value, side='left', sorter=None):
if sorter is not None:
sorter = ensure_platform_int(sorter)
Expand Down
5 changes: 0 additions & 5 deletions pandas/tests/arrays/categorical/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ def test_searchsorted(self):
pytest.raises(ValueError, lambda: c2.searchsorted('apple'))
pytest.raises(ValueError, lambda: s2.searchsorted('apple'))

with tm.assert_produces_warning(FutureWarning):
res = c1.searchsorted(v=['bread'])
exp = np.array([3], dtype=np.intp)
tm.assert_numpy_array_equal(res, exp)

def test_unique(self):
# categories are reordered based on value when ordered=False
cat = Categorical(["a", "b"])
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/indexes/period/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ def test_searchsorted(self, freq):
with tm.assert_raises_regex(period.IncompatibleFrequency, msg):
pidx.searchsorted(pd.Period('2014-01-01', freq='5D'))

with tm.assert_produces_warning(FutureWarning):
pidx.searchsorted(key=p2)


class TestPeriodIndexConversion(object):
def test_tolist(self):
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,10 +1368,6 @@ def test_searchsorted(self):
idx = s.searchsorted(1, side='right')
tm.assert_numpy_array_equal(idx, np.array([1], dtype=np.intp))

with tm.assert_produces_warning(FutureWarning):
idx = s.searchsorted(v=1, side='left')
tm.assert_numpy_array_equal(idx, np.array([0], dtype=np.intp))

def test_searchsorted_numeric_dtypes_scalar(self):
s = Series([1, 2, 90, 1000, 3e9])
r = s.searchsorted(30)
Expand Down

0 comments on commit ba2720b

Please sign in to comment.