Skip to content

CLN: remove _index_data #43229

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 2 commits into from
Sep 2, 2021
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
3 changes: 0 additions & 3 deletions pandas/_libs/reduction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ cdef class _BaseGrouper:

cdef inline _update_cached_objs(self, object cached_series, object cached_index,
Slider islider, Slider vslider):
# See the comment in indexes/base.py about _index_data.
# We need this for EA-backed indexes that have a reference
# to a 1-d ndarray like datetime / timedelta / period.
cached_index._engine.clear_mapping()
cached_index._cache.clear() # e.g. inferred_freq must go
cached_series._mgr.set_values(vslider.buf)
Expand Down
5 changes: 0 additions & 5 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,6 @@ def _simple_new(cls: type[_IndexT], values, name: Hashable = None) -> _IndexT:

result = object.__new__(cls)
result._data = values
# _index_data is a (temporary?) fix to ensure that the direct data
# manipulation we do in `_libs/reduction.pyx` continues to work.
# We need access to the actual ndarray, since we're messing with
# data buffers and strides.
result._index_data = values
result._name = name
result._cache = {}
result._reset_identity()
Expand Down
13 changes: 0 additions & 13 deletions pandas/core/indexes/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,19 +464,6 @@ class NDArrayBackedExtensionIndex(ExtensionIndex):

_data: NDArrayBackedExtensionArray

@classmethod
def _simple_new(
cls,
values: NDArrayBackedExtensionArray,
name: Hashable = None,
):
result = super()._simple_new(values, name)

# For groupby perf. See note in indexes/base about _index_data
result._index_data = values._ndarray

return result

def _get_engine_target(self) -> np.ndarray:
return self._data._ndarray

Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/arithmetic/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ class MyIndex(pd.Index):
def _simple_new(cls, values, name=None, dtype=None):
result = object.__new__(cls)
result._data = values
result._index_data = values
result._name = name
result._calls = 0
result._reset_identity()
Expand All @@ -350,7 +349,7 @@ def _simple_new(cls, values, name=None, dtype=None):

def __add__(self, other):
self._calls += 1
return self._simple_new(self._index_data)
return self._simple_new(self._data)

def __radd__(self, other):
return self.__add__(other)
Expand Down