Exemple #1
0
 def __le__(self, other):
     try:
         other = _sympify(other)
     except SympifyError:
         return False    # sympy > other  -->  ! <=
     if isinstance(other, NumberSymbol):
         return other.__gt__(self)
     if other.is_comparable: other = other.evalf()
     if isinstance(other, Number):
         return bool(mlib.mpf_le(self._mpf_, other._as_mpf_val(self._prec)))
     return Expr.__le__(self, other)
Exemple #2
0
 def __le__(self, other):
     try:
         other = _sympify(other)
     except SympifyError:
         return False    # sympy > other  -->  ! <=
     if isinstance(other, NumberSymbol):
         return other.__gt__(self)
     if other.is_comparable: other = other.evalf()
     if isinstance(other, Number):
         return bool(mlib.mpf_le(self._mpf_, other._as_mpf_val(self._prec)))
     return Expr.__le__(self, other)
Exemple #3
0
 def __le__(self, other):
     try:
         other = _sympify(other)
     except SympifyError:
         return False    # sympy > other  -->  not <=
     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(mlib.mpf_le(self._as_mpf_val(other._prec), other._mpf_))
         return bool(self.p * other.q <= self.q * other.p)
     return Expr.__le__(self, other)
Exemple #4
0
 def __le__(self, other):
     try:
         other = _sympify(other)
     except SympifyError:
         return False    # sympy > other  -->  not <=
     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(mlib.mpf_le(self._as_mpf_val(other._prec), other._mpf_))
         return bool(self.p * other.q <= self.q * other.p)
     return Expr.__le__(self, other)