Skip to content

CLN: inconsistent kwarg name #31721

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
Feb 6, 2020
Merged
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
20 changes: 10 additions & 10 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ def _slice(self, obj, axis: int, kind=None):

def _get_setitem_indexer(self, key):
if self.axis is not None:
return self._convert_tuple(key, setting=True)
return self._convert_tuple(key, is_setter=True)

ax = self.obj._get_axis(0)

Expand All @@ -612,15 +612,15 @@ def _get_setitem_indexer(self, key):

if isinstance(key, tuple):
try:
return self._convert_tuple(key, setting=True)
return self._convert_tuple(key, is_setter=True)
except IndexingError:
pass

if isinstance(key, range):
return list(key)

try:
return self._convert_to_indexer(key, axis=0, setting=True)
return self._convert_to_indexer(key, axis=0, is_setter=True)
except TypeError as e:

# invalid indexer type vs 'other' indexing errors
Expand Down Expand Up @@ -683,22 +683,22 @@ def _is_nested_tuple_indexer(self, tup: Tuple) -> bool:
return any(is_nested_tuple(tup, ax) for ax in self.obj.axes)
return False

def _convert_tuple(self, key, setting: bool = False):
def _convert_tuple(self, key, is_setter: bool = False):
keyidx = []
if self.axis is not None:
axis = self.obj._get_axis_number(self.axis)
for i in range(self.ndim):
if i == axis:
keyidx.append(
self._convert_to_indexer(key, axis=axis, setting=setting)
self._convert_to_indexer(key, axis=axis, is_setter=is_setter)
)
else:
keyidx.append(slice(None))
else:
for i, k in enumerate(key):
if i >= self.ndim:
raise IndexingError("Too many indexers")
idx = self._convert_to_indexer(k, axis=i, setting=setting)
idx = self._convert_to_indexer(k, axis=i, is_setter=is_setter)
keyidx.append(idx)
return tuple(keyidx)

Expand Down Expand Up @@ -1569,7 +1569,7 @@ def _validate_read_indexer(
"https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike" # noqa:E501
)

def _convert_to_indexer(self, key, axis: int, setting: bool = False):
def _convert_to_indexer(self, key, axis: int, is_setter: bool = False):
raise AbstractMethodError(self)

def __getitem__(self, key):
Expand Down Expand Up @@ -1778,7 +1778,7 @@ def _get_slice_axis(self, slice_obj: slice, axis: int):
# return a DatetimeIndex instead of a slice object.
return self.obj.take(indexer, axis=axis)

def _convert_to_indexer(self, key, axis: int, setting: bool = False):
def _convert_to_indexer(self, key, axis: int, is_setter: bool = False):
"""
Convert indexing key into something we can use to do actual fancy
indexing on a ndarray.
Expand All @@ -1804,7 +1804,7 @@ def _convert_to_indexer(self, key, axis: int, setting: bool = False):
key = self._convert_scalar_indexer(key, axis)
except TypeError:
# but we will allow setting
if not setting:
if not is_setter:
raise

# see if we are positional in nature
Expand Down Expand Up @@ -2037,7 +2037,7 @@ def _get_slice_axis(self, slice_obj: slice, axis: int):
indexer = self._convert_slice_indexer(slice_obj, axis)
return self._slice(indexer, axis=axis, kind="iloc")

def _convert_to_indexer(self, key, axis: int, setting: bool = False):
def _convert_to_indexer(self, key, axis: int, is_setter: bool = False):
"""
Much simpler as we only have to deal with our valid types.
"""
Expand Down