Skip to content

Commit

Permalink
Fix RangeIndex unary operators. (#11868)
Browse files Browse the repository at this point in the history
These operators rely on a method that was renamed in #11272 and are also out of sync with the rest of the `RangeIndex` design now that the `__getattr__` overload has been removed (#10538).

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #11868
  • Loading branch information
vyasr authored Oct 6, 2022
1 parent 4525474 commit 029b1db
Showing 1 changed file with 7 additions and 8 deletions.
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

0 comments on commit 029b1db

Please sign in to comment.