Skip to content

Commit b47108f

Browse files
committed
CLN: remove no-longer-used 'kind' keyword
1 parent 97dbe2a commit b47108f

File tree

8 files changed

+14
-25
lines changed

8 files changed

+14
-25
lines changed

pandas/core/indexes/base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5587,7 +5587,7 @@ def _validate_indexer(self, form: str_t, key, kind: str_t):
55875587
if key is not None and not is_integer(key):
55885588
raise self._invalid_indexer(form, key)
55895589

5590-
def _maybe_cast_slice_bound(self, label, side: str_t, kind):
5590+
def _maybe_cast_slice_bound(self, label, side: str_t):
55915591
"""
55925592
This function should be overloaded in subclasses that allow non-trivial
55935593
casting on label-slice bounds, e.g. datetime-like indices allowing
@@ -5597,7 +5597,6 @@ def _maybe_cast_slice_bound(self, label, side: str_t, kind):
55975597
----------
55985598
label : object
55995599
side : {'left', 'right'}
5600-
kind : {'loc', 'getitem'} or None
56015600
56025601
Returns
56035602
-------
@@ -5607,7 +5606,6 @@ def _maybe_cast_slice_bound(self, label, side: str_t, kind):
56075606
-----
56085607
Value of `side` parameter should be validated in caller.
56095608
"""
5610-
assert kind in ["loc", "getitem", None]
56115609

56125610
# We are a plain index here (sub-class override this method if they
56135611
# wish to have special treatment for floats/ints, e.g. Float64Index and
@@ -5662,7 +5660,7 @@ def get_slice_bound(self, label, side: str_t, kind) -> int:
56625660

56635661
# For datetime indices label may be a string that has to be converted
56645662
# to datetime boundary according to its resolution.
5665-
label = self._maybe_cast_slice_bound(label, side, kind)
5663+
label = self._maybe_cast_slice_bound(label, side)
56665664

56675665
# we need to look up the label
56685666
try:

pandas/core/indexes/datetimes.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,15 +720,14 @@ def _maybe_cast_for_get_loc(self, key) -> Timestamp:
720720
key = key.tz_convert(self.tz)
721721
return key
722722

723-
def _maybe_cast_slice_bound(self, label, side: str, kind):
723+
def _maybe_cast_slice_bound(self, label, side: str):
724724
"""
725725
If label is a string, cast it to datetime according to resolution.
726726
727727
Parameters
728728
----------
729729
label : object
730730
side : {'left', 'right'}
731-
kind : {'loc', 'getitem'} or None
732731
733732
Returns
734733
-------
@@ -738,7 +737,6 @@ def _maybe_cast_slice_bound(self, label, side: str, kind):
738737
-----
739738
Value of `side` parameter should be validated in caller.
740739
"""
741-
assert kind in ["loc", "getitem", None]
742740

743741
if isinstance(label, str):
744742
freq = getattr(self, "freqstr", getattr(self, "inferred_freq", None))
@@ -819,12 +817,12 @@ def check_str_or_none(point):
819817
mask = np.array(True)
820818
deprecation_mask = np.array(True)
821819
if start is not None:
822-
start_casted = self._maybe_cast_slice_bound(start, "left", kind)
820+
start_casted = self._maybe_cast_slice_bound(start, "left")
823821
mask = start_casted <= self
824822
deprecation_mask = start_casted == self
825823

826824
if end is not None:
827-
end_casted = self._maybe_cast_slice_bound(end, "right", kind)
825+
end_casted = self._maybe_cast_slice_bound(end, "right")
828826
mask = (self <= end_casted) & mask
829827
deprecation_mask = (end_casted == self) | deprecation_mask
830828

pandas/core/indexes/interval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ def _should_fallback_to_positional(self) -> bool:
802802
# positional in this case
803803
return self.dtype.subtype.kind in ["m", "M"]
804804

805-
def _maybe_cast_slice_bound(self, label, side: str, kind):
806-
return getattr(self, side)._maybe_cast_slice_bound(label, side, kind)
805+
def _maybe_cast_slice_bound(self, label, side: str):
806+
return getattr(self, side)._maybe_cast_slice_bound(label, side)
807807

808808
@Appender(Index._convert_list_indexer.__doc__)
809809
def _convert_list_indexer(self, keyarr):

pandas/core/indexes/numeric.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def _validate_dtype(cls, dtype: Dtype) -> None:
114114
# Indexing Methods
115115

116116
@doc(Index._maybe_cast_slice_bound)
117-
def _maybe_cast_slice_bound(self, label, side: str, kind):
118-
assert kind in ["loc", "getitem", None]
117+
def _maybe_cast_slice_bound(self, label, side: str):
119118

120119
# we will try to coerce to integers
121120
return self._maybe_cast_indexer(label)

pandas/core/indexes/period.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def get_loc(self, key, method=None, tolerance=None):
530530
except KeyError as err:
531531
raise KeyError(orig_key) from err
532532

533-
def _maybe_cast_slice_bound(self, label, side: str, kind: str):
533+
def _maybe_cast_slice_bound(self, label, side: str):
534534
"""
535535
If label is a string or a datetime, cast it to Period.ordinal according
536536
to resolution.
@@ -539,7 +539,6 @@ def _maybe_cast_slice_bound(self, label, side: str, kind: str):
539539
----------
540540
label : object
541541
side : {'left', 'right'}
542-
kind : {'loc', 'getitem'}
543542
544543
Returns
545544
-------
@@ -548,9 +547,7 @@ def _maybe_cast_slice_bound(self, label, side: str, kind: str):
548547
Notes
549548
-----
550549
Value of `side` parameter should be validated in caller.
551-
552550
"""
553-
assert kind in ["loc", "getitem"]
554551

555552
if isinstance(label, datetime):
556553
return Period(label, freq=self.freq)

pandas/core/indexes/timedeltas.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,19 @@ def get_loc(self, key, method=None, tolerance=None):
192192

193193
return Index.get_loc(self, key, method, tolerance)
194194

195-
def _maybe_cast_slice_bound(self, label, side: str, kind):
195+
def _maybe_cast_slice_bound(self, label, side: str):
196196
"""
197197
If label is a string, cast it to timedelta according to resolution.
198198
199199
Parameters
200200
----------
201201
label : object
202202
side : {'left', 'right'}
203-
kind : {'loc', 'getitem'} or None
204203
205204
Returns
206205
-------
207206
label : object
208207
"""
209-
assert kind in ["loc", "getitem", None]
210-
211208
if isinstance(label, str):
212209
parsed = Timedelta(label)
213210
lbound = parsed.round(parsed.resolution_string)

pandas/tests/indexes/datetimes/test_indexing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,18 +679,18 @@ def test_maybe_cast_slice_bounds_empty(self):
679679
# GH#14354
680680
empty_idx = date_range(freq="1H", periods=0, end="2015")
681681

682-
right = empty_idx._maybe_cast_slice_bound("2015-01-02", "right", "loc")
682+
right = empty_idx._maybe_cast_slice_bound("2015-01-02", "right")
683683
exp = Timestamp("2015-01-02 23:59:59.999999999")
684684
assert right == exp
685685

686-
left = empty_idx._maybe_cast_slice_bound("2015-01-02", "left", "loc")
686+
left = empty_idx._maybe_cast_slice_bound("2015-01-02", "left")
687687
exp = Timestamp("2015-01-02 00:00:00")
688688
assert left == exp
689689

690690
def test_maybe_cast_slice_duplicate_monotonic(self):
691691
# https://github.com/pandas-dev/pandas/issues/16515
692692
idx = DatetimeIndex(["2017", "2017"])
693-
result = idx._maybe_cast_slice_bound("2017-01-01", "left", "loc")
693+
result = idx._maybe_cast_slice_bound("2017-01-01", "left")
694694
expected = Timestamp("2017-01-01")
695695
assert result == expected
696696

pandas/tests/indexes/period/test_partial_slicing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_maybe_cast_slice_bound(self, make_range, frame_or_series):
110110

111111
# Check the lower-level calls are raising where expected.
112112
with pytest.raises(TypeError, match=msg):
113-
idx._maybe_cast_slice_bound("foo", "left", "loc")
113+
idx._maybe_cast_slice_bound("foo", "left")
114114
with pytest.raises(TypeError, match=msg):
115115
idx.get_slice_bound("foo", "left", "loc")
116116

0 commit comments

Comments
 (0)