Skip to content
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

Fix RangeIndex unary operators. #11868

Merged
merged 1 commit into from
Oct 6, 2022
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
15 changes: 7 additions & 8 deletions python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,14 @@ def min(self):
def max(self):
return self._minmax("max")

def __neg__(self):
return -self._as_int_index()

# Patch in all binops and unary ops, which bypass __getattr__ on the instance
# and prevent the above overload from working.
for unaop in ("__neg__", "__pos__", "__abs__"):
setattr(
RangeIndex,
unaop,
lambda self, op=unaop: getattr(self._as_int64(), op)(),
)
def __pos__(self):
return +self._as_int_index()

def __abs__(self):
return abs(self._as_int_index())


class GenericIndex(SingleColumnFrame, BaseIndex):
Expand Down