Пример #1
0
def test_RealField_from_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.convert(oo) == RR("+inf")
    assert RR.convert(-oo) == RR("-inf")
    raises(CoercionFailed, lambda: RR.convert(x))
Пример #2
0
def test_RealField_from_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.convert(oo) == RR("+inf")
    assert RR.convert(-oo) == RR("-inf")
    raises(CoercionFailed, lambda: RR.convert(x))
Пример #3
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))
Пример #4
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))
Пример #5
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)")
Пример #6
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)")
Пример #7
0
def test_RealField_from_sympy():
    assert RR.convert(S.Zero) == RR.dtype(0)
    assert RR.convert(S(0.0)) == RR.dtype(0.0)
    assert RR.convert(S.One) == RR.dtype(1)
    assert RR.convert(S(1.0)) == RR.dtype(1.0)
    assert RR.convert(sin(1)) == RR.dtype(sin(1).evalf())