Skip to content

CLN: Fix order of index methods. #5081

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 2, 2013
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
58 changes: 29 additions & 29 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,6 @@ class Index(FrozenNDArray):

_engine_type = _index.ObjectEngine

def is_(self, other):
"""
More flexible, faster check like ``is`` but that works through views

Note: this is *not* the same as ``Index.identical()``, which checks
that metadata is also the same.

Parameters
----------
other : object
other object to compare against.

Returns
-------
True if both have same underlying data, False otherwise : bool
"""
# use something other than None to be clearer
return self._id is getattr(other, '_id', Ellipsis)

def _reset_identity(self):
"Initializes or resets ``_id`` attribute with new object"
self._id = _Identity()

def view(self, *args, **kwargs):
result = super(Index, self).view(*args, **kwargs)
if isinstance(result, Index):
result._id = self._id
return result

def __new__(cls, data, dtype=None, copy=False, name=None, fastpath=False,
**kwargs):

Expand Down Expand Up @@ -187,6 +158,35 @@ def __new__(cls, data, dtype=None, copy=False, name=None, fastpath=False,
subarr._set_names([name])
return subarr

def is_(self, other):
"""
More flexible, faster check like ``is`` but that works through views

Note: this is *not* the same as ``Index.identical()``, which checks
that metadata is also the same.

Parameters
----------
other : object
other object to compare against.

Returns
-------
True if both have same underlying data, False otherwise : bool
"""
# use something other than None to be clearer
return self._id is getattr(other, '_id', Ellipsis)

def _reset_identity(self):
"Initializes or resets ``_id`` attribute with new object"
self._id = _Identity()

def view(self, *args, **kwargs):
result = super(Index, self).view(*args, **kwargs)
if isinstance(result, Index):
result._id = self._id
return result

# construction helpers
@classmethod
def _scalar_data_error(cls, data):
Expand Down