Skip to content

CLN: leftover ix checks #30951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class NDFrame(PandasObject, SelectionMixin, indexing.IndexingMixin):
]
_internal_names_set: Set[str] = set(_internal_names)
_accessors: Set[str] = set()
_deprecations: FrozenSet[str] = frozenset(["get_values", "ix"])
_deprecations: FrozenSet[str] = frozenset(["get_values"])
_metadata: List[str] = []
_is_copy = None
_data: BlockManager
Expand Down
29 changes: 14 additions & 15 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2829,24 +2829,24 @@ def _filter_indexer_tolerance(self, target, indexer, tolerance):
Parameters
----------
key : label of the slice bound
kind : {'ix', 'loc', 'getitem', 'iloc'} or None
kind : {'loc', 'getitem', 'iloc'} or None
"""

@Appender(_index_shared_docs["_convert_scalar_indexer"])
def _convert_scalar_indexer(self, key, kind=None):
assert kind in ["ix", "loc", "getitem", "iloc", None]
assert kind in ["loc", "getitem", "iloc", None]

if kind == "iloc":
return self._validate_indexer("positional", key, kind)

if len(self) and not isinstance(self, ABCMultiIndex):

# we can raise here if we are definitive that this
# is positional indexing (eg. .ix on with a float)
# is positional indexing (eg. .loc on with a float)
# or label indexing if we are using a type able
# to be represented in the index

if kind in ["getitem", "ix"] and is_float(key):
if kind in ["getitem"] and is_float(key):
if not self.is_floating():
return self._invalid_indexer("label", key)

Expand Down Expand Up @@ -2882,12 +2882,12 @@ def _convert_scalar_indexer(self, key, kind=None):
Parameters
----------
key : label of the slice bound
kind : {'ix', 'loc', 'getitem', 'iloc'} or None
kind : {'loc', 'getitem', 'iloc'} or None
"""

@Appender(_index_shared_docs["_convert_slice_indexer"])
def _convert_slice_indexer(self, key: slice, kind=None):
assert kind in ["ix", "loc", "getitem", "iloc", None]
assert kind in ["loc", "getitem", "iloc", None]

# validate iloc
if kind == "iloc":
Expand Down Expand Up @@ -3026,7 +3026,7 @@ def _convert_index_indexer(self, keyarr):
@Appender(_index_shared_docs["_convert_list_indexer"])
def _convert_list_indexer(self, keyarr, kind=None):
if (
kind in [None, "iloc", "ix"]
kind in [None, "iloc"]
and is_integer_dtype(keyarr)
and not self.is_floating()
and not isinstance(keyarr, ABCPeriodIndex)
Expand Down Expand Up @@ -4704,7 +4704,7 @@ def _validate_indexer(self, form, key, kind):
If we are positional indexer, validate that we have appropriate
typed bounds must be an integer.
"""
assert kind in ["ix", "loc", "getitem", "iloc"]
assert kind in ["loc", "getitem", "iloc"]

if key is None:
pass
Expand All @@ -4725,7 +4725,7 @@ def _validate_indexer(self, form, key, kind):
----------
label : object
side : {'left', 'right'}
kind : {'ix', 'loc', 'getitem'}
kind : {'loc', 'getitem'} or None

Returns
-------
Expand All @@ -4738,15 +4738,14 @@ def _validate_indexer(self, form, key, kind):

@Appender(_index_shared_docs["_maybe_cast_slice_bound"])
def _maybe_cast_slice_bound(self, label, side, kind):
assert kind in ["ix", "loc", "getitem", None]
assert kind in ["loc", "getitem", None]

# We are a plain index here (sub-class override this method if they
# wish to have special treatment for floats/ints, e.g. Float64Index and
# datetimelike Indexes
# reject them
if is_float(label):
if not (kind in ["ix"] and (self.holds_integer() or self.is_floating())):
self._invalid_indexer("slice", label)
self._invalid_indexer("slice", label)

# we are trying to find integer bounds on a non-integer based index
# this is rejected (generally .loc gets you here)
Expand Down Expand Up @@ -4780,14 +4779,14 @@ def get_slice_bound(self, label, side, kind):
----------
label : object
side : {'left', 'right'}
kind : {'ix', 'loc', 'getitem'}
kind : {'loc', 'getitem'} or None

Returns
-------
int
Index of label.
"""
assert kind in ["ix", "loc", "getitem", None]
assert kind in ["loc", "getitem", None]

if side not in ("left", "right"):
raise ValueError(
Expand Down Expand Up @@ -4847,7 +4846,7 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
If None, defaults to the end.
step : int, defaults None
If None, defaults to 1.
kind : {'ix', 'loc', 'getitem'} or None
kind : {'loc', 'getitem'} or None

Returns
-------
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ def _convert_scalar_indexer(self, key, kind=None):
Parameters
----------
key : label of the slice bound
kind : {'ix', 'loc', 'getitem', 'iloc'} or None
kind : {'loc', 'getitem', 'iloc'} or None
"""

assert kind in ["ix", "loc", "getitem", "iloc", None]
assert kind in ["loc", "getitem", "iloc", None]

# we don't allow integer/float indexing for loc
# we don't allow float indexing for ix/getitem
Expand All @@ -400,7 +400,7 @@ def _convert_scalar_indexer(self, key, kind=None):
is_flt = is_float(key)
if kind in ["loc"] and (is_int or is_flt):
self._invalid_indexer("index", key)
elif kind in ["ix", "getitem"] and is_flt:
elif kind in ["getitem"] and is_flt:
self._invalid_indexer("index", key)

return super()._convert_scalar_indexer(key, kind=kind)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def _maybe_cast_slice_bound(self, label, side, kind):
----------
label : object
side : {'left', 'right'}
kind : {'ix', 'loc', 'getitem'}
kind : {'loc', 'getitem'} or None

Returns
-------
Expand All @@ -752,7 +752,7 @@ def _maybe_cast_slice_bound(self, label, side, kind):
-----
Value of `side` parameter should be validated in caller.
"""
assert kind in ["ix", "loc", "getitem", None]
assert kind in ["loc", "getitem", None]

if is_float(label) or isinstance(label, time) or is_integer(label):
self._invalid_indexer("slice", label)
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/indexes/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _validate_dtype(cls, dtype: Dtype) -> None:

@Appender(_index_shared_docs["_maybe_cast_slice_bound"])
def _maybe_cast_slice_bound(self, label, side, kind):
assert kind in ["ix", "loc", "getitem", None]
assert kind in ["loc", "getitem", None]

# we will try to coerce to integers
return self._maybe_cast_indexer(label)
Expand Down Expand Up @@ -260,7 +260,7 @@ def asi8(self) -> np.ndarray:

@Appender(_index_shared_docs["_convert_scalar_indexer"])
def _convert_scalar_indexer(self, key, kind=None):
assert kind in ["ix", "loc", "getitem", "iloc", None]
assert kind in ["loc", "getitem", "iloc", None]

# don't coerce ilocs to integers
if kind != "iloc":
Expand Down Expand Up @@ -317,7 +317,7 @@ def asi8(self) -> np.ndarray:

@Appender(_index_shared_docs["_convert_scalar_indexer"])
def _convert_scalar_indexer(self, key, kind=None):
assert kind in ["ix", "loc", "getitem", "iloc", None]
assert kind in ["loc", "getitem", "iloc", None]

# don't coerce ilocs to integers
if kind != "iloc":
Expand Down Expand Up @@ -404,7 +404,7 @@ def astype(self, dtype, copy=True):

@Appender(_index_shared_docs["_convert_scalar_indexer"])
def _convert_scalar_indexer(self, key, kind=None):
assert kind in ["ix", "loc", "getitem", "iloc", None]
assert kind in ["loc", "getitem", "iloc", None]

if kind == "iloc":
return self._validate_indexer("positional", key, kind)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def _maybe_cast_slice_bound(self, label, side, kind):
----------
label : object
side : {'left', 'right'}
kind : {'ix', 'loc', 'getitem'}
kind : {'loc', 'getitem'}

Returns
-------
Expand All @@ -636,7 +636,7 @@ def _maybe_cast_slice_bound(self, label, side, kind):
Value of `side` parameter should be validated in caller.

"""
assert kind in ["ix", "loc", "getitem"]
assert kind in ["loc", "getitem"]

if isinstance(label, datetime):
return Period(label, freq=self.freq)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ def _maybe_cast_slice_bound(self, label, side, kind):
----------
label : object
side : {'left', 'right'}
kind : {'ix', 'loc', 'getitem'}
kind : {'loc', 'getitem'} or None

Returns
-------
label : object
"""
assert kind in ["ix", "loc", "getitem", None]
assert kind in ["loc", "getitem", None]

if isinstance(label, str):
parsed = Timedelta(label)
Expand Down