Пример #1
0
def test_RealDomain_from_sympy():
    RR = RR_mpmath()

    assert RR.convert(S(0)) == RR.dtype(0)
    assert RR.convert(S(0.0)) == RR.dtype(0.0)
    assert RR.convert(S(1)) == RR.dtype(1)
    assert RR.convert(S(1.0)) == RR.dtype(1.0)
    assert RR.convert(sin(1)) == RR.dtype(sin(1).evalf())
    raises(CoercionFailed, lambda: RR.convert(x))
    raises(CoercionFailed, lambda: RR.convert(oo))
    raises(CoercionFailed, lambda: RR.convert(-oo))
Пример #2
0
def test_RealDomain_from_sympy():
    RR = RR_mpmath()

    assert RR.convert(S(0)) == RR.dtype(0)
    assert RR.convert(S(0.0)) == RR.dtype(0.0)
    assert RR.convert(S(1)) == RR.dtype(1)
    assert RR.convert(S(1.0)) == RR.dtype(1.0)
    assert RR.convert(sin(1)) == RR.dtype(sin(1).evalf())
    raises(CoercionFailed, "RR.convert(x)")
    raises(CoercionFailed, "RR.convert(oo)")
    raises(CoercionFailed, "RR.convert(-oo)")

    RR = RR_sympy()

    assert RR.convert(S(0)) == RR.dtype(0)
    assert RR.convert(S(0.0)) == RR.dtype(0.0)
    assert RR.convert(S(1)) == RR.dtype(1)
    assert RR.convert(S(1.0)) == RR.dtype(1.0)
    assert RR.convert(sin(1)) == RR.dtype(sin(1).evalf())
    assert RR.n(3, 2) == RR.evalf(3, 2) == Rational(3).n(2)
    raises(CoercionFailed, "RR.convert(x)")
    raises(CoercionFailed, "RR.convert(oo)")
    raises(CoercionFailed, "RR.convert(-oo)")