Esempio n. 1
0
 def __ne__(self, other):
     try:
         other = _sympify(other)
     except SympifyError:
         return True     # sympy != 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(not mlib.mpf_eq(self._mpf_, other._as_mpf_val(self._prec)))
     return True     # Real != non-Number
Esempio n. 2
0
 def __ne__(self, other):
     try:
         other = _sympify(other)
     except SympifyError:
         return True     # sympy != 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(not mlib.mpf_eq(self._mpf_, other._as_mpf_val(self._prec)))
     return True     # Real != non-Number
Esempio n. 3
0
 def __eq__(self, other):
     try:
         other = _sympify(other)
     except SympifyError:
         return False    # sympy != other  -->  not ==
     if isinstance(other, NumberSymbol):
         if other.is_irrational: return False
         return other.__eq__(self)
     if isinstance(other, FunctionClass): #cos as opposed to cos(x)
         return False
     if other.is_comparable: other = other.evalf()
     if isinstance(other, Number):
         return bool(mlib.mpf_eq(self._mpf_, other._as_mpf_val(self._prec)))
     return False    # Real != non-Number
Esempio n. 4
0
    def __eq__(self, other):
        try:
            other = _sympify(other)
        except SympifyError:
            return False    # sympy != other  -->  not ==
        if isinstance(other, NumberSymbol):
            if other.is_irrational: return False
            return other.__eq__(self)
        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(mlib.mpf_eq(self._as_mpf_val(other._prec), other._mpf_))
            return bool(self.p==other.p and self.q==other.q)

        return False    # Rational != non-Number
Esempio n. 5
0
    def __ne__(self, other):
        try:
            other = _sympify(other)
        except SympifyError:
            return True     # sympy != other
        if isinstance(other, NumberSymbol):
            if other.is_irrational: return True
            return other.__ne__(self)
        if isinstance(other, FunctionClass): #cos as opposed to cos(x)
            return True
        if other.is_comparable and not isinstance(other, Rational): other = other.evalf()
        if isinstance(other, Number):
            if isinstance(other, Real):
                return bool(not mlib.mpf_eq(self._as_mpf_val(other._prec), other._mpf_))
            return bool(self.p!=other.p or self.q!=other.q)

        return True     # Rational != non-Number
Esempio n. 6
0
    def __eq__(self, other):
        try:
            other = _sympify(other)
        except SympifyError:
            return False    # sympy != other  -->  not ==
        if isinstance(other, NumberSymbol):
            if other.is_irrational: return False
            return other.__eq__(self)
        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(mlib.mpf_eq(self._as_mpf_val(other._prec), other._mpf_))
            return bool(self.p==other.p and self.q==other.q)

        return False    # Rational != non-Number