def test_Domain_interface(): pytest.raises(TypeError, lambda: DomainElement().parent) assert RR(1).parent is RR assert CC(1).parent is CC assert RR.has_default_precision assert CC.has_default_precision RR3 = RealField(prec=53, dps=3) assert str(RR3(1.7611107002)) == '1.76' assert RealField(tol=3).tolerance == 3.0 assert RealField(tol=0.1).tolerance == 0.1 assert RealField(tol='0.1').tolerance == 0.1 pytest.raises(ValueError, lambda: RealField(tol=object())) pytest.raises(AttributeError, lambda: CC.ring) pytest.raises(DomainError, lambda: CC.get_exact()) assert str(EX(1)) == 'EX(1)' assert EX(1).as_expr() == Integer(1) assert bool(EX(1)) is True assert bool(EX(0)) is False
def test_Domain_get_exact(): assert EX.get_exact() == EX assert ZZ.get_exact() == ZZ assert QQ.get_exact() == QQ assert RR.get_exact() == QQ assert CC.get_exact() == QQ.algebraic_field(I) assert ALG.get_exact() == ALG assert ZZ.inject(x).get_exact() == ZZ.inject(x) assert QQ.inject(x).get_exact() == QQ.inject(x) assert ZZ.inject(x, y).get_exact() == ZZ.inject(x, y) assert QQ.inject(x, y).get_exact() == QQ.inject(x, y) assert ZZ.inject(x).field.get_exact() == ZZ.inject(x).field assert QQ.inject(x).field.get_exact() == QQ.inject(x).field assert ZZ.inject(x, y).field.get_exact() == ZZ.inject(x, y).field assert QQ.inject(x, y).field.get_exact() == QQ.inject(x, y).field