Skip to content

Commit 551f4af

Browse files
committed
modify dunder methods of +/- inf object for comparison
1 parent bf6453d commit 551f4af

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pandas/_libs/algos.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,22 @@ class Infinity(object):
6565
""" provide a positive Infinity comparision method for ranking """
6666

6767
__lt__ = lambda self, other: False
68-
__le__ = lambda self, other: self is other
69-
__eq__ = lambda self, other: self is other
70-
__ne__ = lambda self, other: self is not other
71-
__gt__ = lambda self, other: self is not other
68+
__le__ = lambda self, other: isinstance(other, Infinity)
69+
__eq__ = lambda self, other: isinstance(other, Infinity)
70+
__ne__ = lambda self, other: not isinstance(other, Infinity)
71+
__gt__ = lambda self, other: not isinstance(other, Infinity)
7272
__ge__ = lambda self, other: True
7373

7474

7575
class NegInfinity(object):
7676
""" provide a negative Infinity comparision method for ranking """
7777

78-
__lt__ = lambda self, other: self is not other
78+
__lt__ = lambda self, other: not isinstance(other, NegInfinity)
7979
__le__ = lambda self, other: True
80-
__eq__ = lambda self, other: self is other
81-
__ne__ = lambda self, other: self is not other
80+
__eq__ = lambda self, other: isinstance(other, NegInfinity)
81+
__ne__ = lambda self, other: not isinstance(other, NegInfinity)
8282
__gt__ = lambda self, other: False
83-
__ge__ = lambda self, other: self is other
83+
__ge__ = lambda self, other: isinstance(other, NegInfinity)
8484

8585

8686
@cython.wraparound(False)

0 commit comments

Comments
 (0)