def test_FractionField(): assert ( srepr(QQ.frac_field(x)) == "FractionField(FracField((Symbol('x'),), QQ, lex))" ) assert ( srepr(QQ.frac_field(x, y, order=grlex)) == "FractionField(FracField((Symbol('x'), Symbol('y')), QQ, grlex))" )
def test_PolynomialRingBase(): assert srepr(ZZ.old_poly_ring(x)) == \ "GlobalPolynomialRing(ZZ, Symbol('x'))" assert srepr(ZZ[x].old_poly_ring(y)) == \ "GlobalPolynomialRing(ZZ[x], Symbol('y'))" assert srepr(QQ.frac_field(x).old_poly_ring(y)) == \ "GlobalPolynomialRing(FractionField(FracField((Symbol('x'),), QQ, lex)), Symbol('y'))"
def test_PrettyPoly(): from sympy.polys.domains import QQ F = QQ.frac_field(x, y) R = QQ[x, y] assert sstr(F.convert(x / (x + y))) == sstr(x / (x + y)) assert sstr(R.convert(x + y)) == sstr(x + y)
def test_FiniteExtension_division_ring(): # Test division in FiniteExtension over a ring KQ = FiniteExtension(Poly(x**2 - 1, x, domain=QQ)) KZ = FiniteExtension(Poly(x**2 - 1, x, domain=ZZ)) KQt = FiniteExtension(Poly(x**2 - 1, x, domain=QQ[t])) KQtf = FiniteExtension(Poly(x**2 - 1, x, domain=QQ.frac_field(t))) assert KQ.is_Field is True assert KZ.is_Field is False assert KQt.is_Field is False assert KQtf.is_Field is True for K in KQ, KZ, KQt, KQtf: xK = K.convert(x) assert xK / K.one == xK assert xK // K.one == xK assert xK % K.one == K.zero raises(ZeroDivisionError, lambda: xK / K.zero) raises(ZeroDivisionError, lambda: xK // K.zero) raises(ZeroDivisionError, lambda: xK % K.zero) if K.is_Field: assert xK / xK == K.one assert xK // xK == K.one assert xK % xK == K.zero else: raises(NotImplementedError, lambda: xK / xK) raises(NotImplementedError, lambda: xK // xK) raises(NotImplementedError, lambda: xK % xK)
def test_FractionField(): assert srepr(QQ.frac_field(x)) == \ "FractionField(FracField((Symbol('x'),), QQ, lex))" assert srepr(QQ.frac_field(x, y, order=grlex)) == \ "FractionField(FracField((Symbol('x'), Symbol('y')), QQ, grlex))"
def test_PrettyPoly(): F = QQ.frac_field(x, y) R = QQ[x, y] assert sstr(F.convert(x / (x + y))) == sstr(x / (x + y)) assert sstr(R.convert(x + y)) == sstr(x + y)