@@ -3680,7 +3680,7 @@ def is_int(v):
3680
3680
)
3681
3681
indexer = key
3682
3682
else :
3683
- indexer = self .slice_indexer (start , stop , step , kind = kind )
3683
+ indexer = self .slice_indexer (start , stop , step )
3684
3684
3685
3685
return indexer
3686
3686
@@ -5643,7 +5643,7 @@ def slice_indexer(
5643
5643
>>> idx.slice_indexer(start='b', end=('c', 'g'))
5644
5644
slice(1, 3, None)
5645
5645
"""
5646
- start_slice , end_slice = self .slice_locs (start , end , step = step , kind = kind )
5646
+ start_slice , end_slice = self .slice_locs (start , end , step = step )
5647
5647
5648
5648
# return a slice
5649
5649
if not is_scalar (start_slice ):
@@ -5673,7 +5673,7 @@ def _validate_indexer(self, form: str_t, key, kind: str_t):
5673
5673
if key is not None and not is_integer (key ):
5674
5674
raise self ._invalid_indexer (form , key )
5675
5675
5676
- def _maybe_cast_slice_bound (self , label , side : str_t , kind ):
5676
+ def _maybe_cast_slice_bound (self , label , side : str_t , kind = no_default ):
5677
5677
"""
5678
5678
This function should be overloaded in subclasses that allow non-trivial
5679
5679
casting on label-slice bounds, e.g. datetime-like indices allowing
@@ -5693,7 +5693,8 @@ def _maybe_cast_slice_bound(self, label, side: str_t, kind):
5693
5693
-----
5694
5694
Value of `side` parameter should be validated in caller.
5695
5695
"""
5696
- assert kind in ["loc" , "getitem" , None ]
5696
+ assert kind in ["loc" , "getitem" , None , no_default ]
5697
+ self ._deprecated_arg (kind , "kind" , "_maybe_cast_slice_bound" )
5697
5698
5698
5699
# We are a plain index here (sub-class override this method if they
5699
5700
# wish to have special treatment for floats/ints, e.g. Float64Index and
@@ -5718,7 +5719,7 @@ def _searchsorted_monotonic(self, label, side: str_t = "left"):
5718
5719
5719
5720
raise ValueError ("index must be monotonic increasing or decreasing" )
5720
5721
5721
- def get_slice_bound (self , label , side : str_t , kind ) -> int :
5722
+ def get_slice_bound (self , label , side : str_t , kind = None ) -> int :
5722
5723
"""
5723
5724
Calculate slice bound that corresponds to given label.
5724
5725
@@ -5748,7 +5749,7 @@ def get_slice_bound(self, label, side: str_t, kind) -> int:
5748
5749
5749
5750
# For datetime indices label may be a string that has to be converted
5750
5751
# to datetime boundary according to its resolution.
5751
- label = self ._maybe_cast_slice_bound (label , side , kind )
5752
+ label = self ._maybe_cast_slice_bound (label , side )
5752
5753
5753
5754
# we need to look up the label
5754
5755
try :
@@ -5838,13 +5839,13 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
5838
5839
5839
5840
start_slice = None
5840
5841
if start is not None :
5841
- start_slice = self .get_slice_bound (start , "left" , kind )
5842
+ start_slice = self .get_slice_bound (start , "left" )
5842
5843
if start_slice is None :
5843
5844
start_slice = 0
5844
5845
5845
5846
end_slice = None
5846
5847
if end is not None :
5847
- end_slice = self .get_slice_bound (end , "right" , kind )
5848
+ end_slice = self .get_slice_bound (end , "right" )
5848
5849
if end_slice is None :
5849
5850
end_slice = len (self )
5850
5851
@@ -6176,6 +6177,18 @@ def shape(self) -> Shape:
6176
6177
# See GH#27775, GH#27384 for history/reasoning in how this is defined.
6177
6178
return (len (self ),)
6178
6179
6180
+ def _deprecated_arg (self , value , name : str_t , methodname : str_t ) -> None :
6181
+ """
6182
+ Issue a FutureWarning if the arg/kwarg is not no_default.
6183
+ """
6184
+ if value is not no_default :
6185
+ warnings .warn (
6186
+ f"'{ name } ' argument in { methodname } is deprecated "
6187
+ "and will be removed in a future version. Do not pass it." ,
6188
+ FutureWarning ,
6189
+ stacklevel = 3 ,
6190
+ )
6191
+
6179
6192
6180
6193
def ensure_index_from_sequences (sequences , names = None ):
6181
6194
"""
0 commit comments