Skip to content

Commit

Permalink
Fix apparently wrong rich comparisons wrt NumberSymbol
Browse files Browse the repository at this point in the history
Taken mostly from sympy/sympy#13091.
  • Loading branch information
skirpichev committed Aug 6, 2017
1 parent 2d034ae commit 15b490a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions diofant/core/numbers.py
Expand Up @@ -970,7 +970,7 @@ def __eq__(self, other):
@_sympifyit('other', NotImplemented)
def __gt__(self, other):
if isinstance(other, NumberSymbol):
return other.__le__(self)
return other.__lt__(self)
if other.is_comparable:
other = other.evalf()
if isinstance(other, Number) and other is not S.NaN:
Expand All @@ -981,7 +981,7 @@ def __gt__(self, other):
@_sympifyit('other', NotImplemented)
def __ge__(self, other):
if isinstance(other, NumberSymbol):
return other.__lt__(self)
return other.__le__(self)
if other.is_comparable:
other = other.evalf()
if isinstance(other, Number) and other is not S.NaN:
Expand All @@ -992,7 +992,7 @@ def __ge__(self, other):
@_sympifyit('other', NotImplemented)
def __lt__(self, other):
if isinstance(other, NumberSymbol):
return other.__ge__(self)
return other.__gt__(self)
if other.is_extended_real and other.is_number:
other = other.evalf()
if isinstance(other, Number) and other is not S.NaN:
Expand All @@ -1003,7 +1003,7 @@ def __lt__(self, other):
@_sympifyit('other', NotImplemented)
def __le__(self, other):
if isinstance(other, NumberSymbol):
return other.__gt__(self)
return other.__ge__(self)
if other.is_extended_real and other.is_number:
other = other.evalf()
if isinstance(other, Number) and other is not S.NaN:
Expand Down Expand Up @@ -1323,7 +1323,7 @@ def __eq__(self, other):
@_sympifyit('other', NotImplemented)
def __gt__(self, other):
if isinstance(other, NumberSymbol):
return other.__le__(self)
return other.__lt__(self)
expr = self
if isinstance(other, Number):
if isinstance(other, Rational):
Expand All @@ -1338,7 +1338,7 @@ def __gt__(self, other):
@_sympifyit('other', NotImplemented)
def __ge__(self, other):
if isinstance(other, NumberSymbol):
return other.__lt__(self)
return other.__le__(self)
expr = self
if isinstance(other, Number):
if isinstance(other, Rational):
Expand All @@ -1353,7 +1353,7 @@ def __ge__(self, other):
@_sympifyit('other', NotImplemented)
def __lt__(self, other):
if isinstance(other, NumberSymbol):
return other.__ge__(self)
return other.__gt__(self)
expr = self
if isinstance(other, Number):
if isinstance(other, Rational):
Expand All @@ -1369,7 +1369,7 @@ def __lt__(self, other):
def __le__(self, other):
expr = self
if isinstance(other, NumberSymbol):
return other.__gt__(self)
return other.__ge__(self)
elif isinstance(other, Number):
if isinstance(other, Rational):
return _sympify(bool(self.p*other.q <= self.q*other.p))
Expand Down

0 comments on commit 15b490a

Please sign in to comment.