Example #1
0
 def __le__(self, other):
     other = Basic.sympify(other)
     if self is other: return True
     if other.is_comparable: other = other.evalf()
     if isinstance(other, Number):
         return self.evalf()<=other
     return RelMeths.__le__(self, other)
Example #2
0
 def __le__(self, other):
     other = Basic.sympify(other)
     if isinstance(other, NumberSymbol):
         return other.__gt__(self)
     if other.is_comparable: other = other.evalf()
     if isinstance(other, Number):
         return bool(self._as_decimal()<=other._as_decimal())
     return RelMeths.__le__(self, other)
Example #3
0
 def __ne__(self, other):
     other = Basic.sympify(other)
     if isinstance(other, NumberSymbol):
         if other.is_irrational: return True
         return other.__ne__(self)
     if other.is_comparable: other = other.evalf()
     if isinstance(other, Number):
         return bool(self._as_decimal()!=other._as_decimal())
     return RelMeths.__ne__(self, other)
Example #4
0
 def __le__(self, other):
     other = Basic.sympify(other)
     if isinstance(other, NumberSymbol):
         return other.__gt__(self)
     if other.is_comparable and not isinstance(other, Rational): other = other.evalf()
     if isinstance(other, Number):
         if isinstance(other, Real):
             return bool(self._as_decimal()<=other._as_decimal())
         return bool(self.p * other.q <= self.q * other.p)
     return RelMeths.__le__(self, other)
Example #5
0
 def __lt__(self, other):
     other = Basic.sympify(other)
     if self is other: return False
     if isinstance(other, Number):
         approx = self.approximation_interval(other.__class__)
         if approx is not None:
             l,u = approx
             if other < l: return False
             if other > u: return True
         return self.evalf()<other
     if other.is_comparable:
         other = other.evalf()
         return self.evalf()<other
     return RelMeths.__lt__(self, other)
Example #6
0
 def __eq__(self, other):
     other = Basic.sympify(other)
     if isinstance(other, NumberSymbol):
         if other.is_irrational: return False
         return other.__eq__(self)
     from sympy.core.function import FunctionClass
     if isinstance(self, Number) and isinstance(other, FunctionClass):
         return False
     if other.is_comparable and not isinstance(other, Rational): other = other.evalf()
     if isinstance(other, Number):
         if isinstance(other, Real):
             return bool(self._as_decimal()==other._as_decimal())
         return bool(self.p==other.p and self.q==other.q)
     return RelMeths.__eq__(self, other)
Example #7
0
 def __ne__(self, other):
     other = Basic.sympify(other)
     if self is other: return False
     if isinstance(other, Number) and self.is_irrational: return True
     return RelMeths.__ne__(self, other)