Skip to content

CLN: de-duplicate _isnan #37373

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
Oct 24, 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
5 changes: 0 additions & 5 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,6 @@ def astype(self, dtype, copy=True):

return Index.astype(self, dtype=dtype, copy=copy)

@cache_readonly
def _isnan(self):
""" return if each value is nan"""
return self._data.codes == -1

@doc(Index.fillna)
def fillna(self, value, downcast=None):
value = self._validate_scalar(value)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def wrapper(left, right):


@inherit_names(
["inferred_freq", "_isnan", "_resolution_obj", "resolution"],
["inferred_freq", "_resolution_obj", "resolution"],
DatetimeLikeArrayMixin,
cache=True,
)
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/indexes/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,7 @@ def astype(self, dtype, copy=True):
# pass copy=False because any copying will be done in the
# _data.astype call above
return Index(new_values, dtype=new_values.dtype, name=self.name, copy=False)

@cache_readonly
def _isnan(self) -> np.ndarray:
return self._data.isna()
13 changes: 0 additions & 13 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
is_object_dtype,
is_scalar,
)
from pandas.core.dtypes.missing import isna

from pandas.core.algorithms import take_1d
from pandas.core.arrays.interval import IntervalArray, _interval_shared_docs
Expand Down Expand Up @@ -192,9 +191,6 @@ class IntervalIndex(IntervalMixin, ExtensionIndex):
# we would like our indexing holder to defer to us
_defer_to_indexing = True

# Immutable, so we are able to cache computations like isna in '_mask'
_mask = None

_data: IntervalArray
_values: IntervalArray

Expand Down Expand Up @@ -342,15 +338,6 @@ def _shallow_copy(
result._cache = self._cache
return result

@cache_readonly
def _isnan(self):
"""
Return a mask indicating if each value is NA.
"""
if self._mask is None:
self._mask = isna(self.left)
return self._mask

@cache_readonly
def _engine(self):
left = self._maybe_convert_i8(self.left)
Expand Down