def test_localring(): Qxy = QQ.frac_field(x, y) R = QQ.poly_ring(x, y, order="ilex") X = R.convert(x) Y = R.convert(y) assert x in R assert 1/x not in R assert 1/(1 + x) in R assert Y in R assert X.ring == R assert X*(Y**2+1)/(1 + X) == R.convert(x*(y**2 + 1)/(1 + x)) assert X*y == X*Y raises(ExactQuotientFailed, lambda: X/Y) raises(ExactQuotientFailed, lambda: x/Y) raises(ExactQuotientFailed, lambda: X/y) assert X + y == X + Y == R.convert(x + y) == x + Y assert X - y == X - Y == R.convert(x - y) == x - Y assert X + 1 == R.convert(x + 1) assert X**2 / X == X assert R.from_GlobalPolynomialRing(ZZ[x, y].convert(x), ZZ[x, y]) == X assert R.from_FractionField(Qxy.convert(x), Qxy) == X raises(CoercionFailed, lambda: R.from_FractionField(Qxy.convert(x)/y, Qxy)) raises(ExactQuotientFailed, lambda: X/Y) raises(NotReversible, lambda: X.invert()) assert R._sdm_to_vector(R._vector_to_sdm([X/(X + 1), Y/(1 + X*Y)], R.order), 2) == \ [X*(1 + X*Y), Y*(1 + X)]
def test_conversion(): L = QQ.poly_ring(x, y, order="ilex") G = QQ[x, y] assert L.convert(x) == L.convert(G.convert(x), G) assert G.convert(x) == G.convert(L.convert(x), L) raises(CoercionFailed, lambda: G.convert(L.convert(1/(1+x)), L))
def test_units(): R = QQ[x] assert R.is_unit(R.convert(1)) assert R.is_unit(R.convert(2)) assert not R.is_unit(R.convert(x)) assert not R.is_unit(R.convert(1 + x)) R = QQ.poly_ring(x, order='ilex') assert R.is_unit(R.convert(1)) assert R.is_unit(R.convert(2)) assert not R.is_unit(R.convert(x)) assert R.is_unit(R.convert(1 + x)) R = ZZ[x] assert R.is_unit(R.convert(1)) assert not R.is_unit(R.convert(2)) assert not R.is_unit(R.convert(x)) assert not R.is_unit(R.convert(1 + x))
def test_localring(): Qxy = QQ.frac_field(x, y) R = QQ.poly_ring(x, y, order="ilex") X = R.convert(x) Y = R.convert(y) assert x in R assert 1/x not in R assert 1/(1 + x) in R assert Y in R assert X.ring == R assert X*(Y**2+1)/(1 + X) == R.convert(x*(y**2 + 1)/(1 + x)) assert X*y == X*Y raises(ExactQuotientFailed, lambda: X/Y) raises(ExactQuotientFailed, lambda: x/Y) raises(ExactQuotientFailed, lambda: X/y) assert X + y == X + Y == R.convert(x + y) == x + Y assert X + 1 == R.convert(x + 1) assert X**2 / X == X assert R.from_GlobalPolynomialRing(ZZ[x, y].convert(x), ZZ[x, y]) == X assert R.from_FractionField(Qxy.convert(x), Qxy) == X raises(CoercionFailed, lambda: R.from_FractionField(Qxy.convert(x)/y, Qxy))
def test_localring(): Qxy = QQ.frac_field(x, y) R = QQ.poly_ring(x, y, order="ilex") X = R.convert(x) Y = R.convert(y) assert x in R assert 1/x not in R assert 1/(1 + x) in R assert Y in R assert X.ring == R assert X*(Y**2+1)/(1 + X) == R.convert(x*(y**2 + 1)/(1 + x)) assert X*y == X*Y raises(ExactQuotientFailed, 'X/Y') raises(ExactQuotientFailed, 'x/Y') raises(ExactQuotientFailed, 'X/y') assert X + y == X + Y == R.convert(x + y) == x + Y assert X + 1 == R.convert(x + 1) assert X**2 / X == X assert R.from_GlobalPolynomialRing(ZZ[x, y].convert(x), ZZ[x, y]) == X assert R.from_FractionField(Qxy.convert(x), Qxy) == X raises(CoercionFailed, 'R.from_FractionField(Qxy.convert(x)/y, Qxy)')
def test_PolynomialRing(): from sympy.polys.domains import QQ assert latex(QQ[x, y]) == r"\mathbb{Q}\left[x, y\right]" assert latex(QQ.poly_ring(x, y, order="ilex")) == \ r"S_<^{-1}\mathbb{Q}\left[x, y\right]"
def test_Domain__unify(): assert ZZ.unify(ZZ) == ZZ assert QQ.unify(QQ) == QQ assert ZZ.unify(QQ) == QQ assert QQ.unify(ZZ) == QQ assert EX.unify(EX) == EX assert ZZ.unify(EX) == EX assert QQ.unify(EX) == EX assert EX.unify(ZZ) == EX assert EX.unify(QQ) == EX assert ZZ.poly_ring('x').unify(EX) == EX assert ZZ.frac_field('x').unify(EX) == EX assert EX.unify(ZZ.poly_ring('x')) == EX assert EX.unify(ZZ.frac_field('x')) == EX assert ZZ.poly_ring('x', 'y').unify(EX) == EX assert ZZ.frac_field('x', 'y').unify(EX) == EX assert EX.unify(ZZ.poly_ring('x', 'y')) == EX assert EX.unify(ZZ.frac_field('x', 'y')) == EX assert QQ.poly_ring('x').unify(EX) == EX assert QQ.frac_field('x').unify(EX) == EX assert EX.unify(QQ.poly_ring('x')) == EX assert EX.unify(QQ.frac_field('x')) == EX assert QQ.poly_ring('x', 'y').unify(EX) == EX assert QQ.frac_field('x', 'y').unify(EX) == EX assert EX.unify(QQ.poly_ring('x', 'y')) == EX assert EX.unify(QQ.frac_field('x', 'y')) == EX assert ZZ.poly_ring('x').unify(ZZ) == ZZ.poly_ring('x') assert ZZ.poly_ring('x').unify(QQ) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(ZZ) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(QQ) == QQ.poly_ring('x') assert ZZ.unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x') assert QQ.unify(ZZ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.poly_ring('x', 'y').unify(ZZ) == ZZ.poly_ring('x', 'y') assert ZZ.poly_ring('x', 'y').unify(QQ) == QQ.poly_ring('x', 'y') assert QQ.poly_ring('x', 'y').unify(ZZ) == QQ.poly_ring('x', 'y') assert QQ.poly_ring('x', 'y').unify(QQ) == QQ.poly_ring('x', 'y') assert ZZ.unify(ZZ.poly_ring('x', 'y')) == ZZ.poly_ring('x', 'y') assert QQ.unify(ZZ.poly_ring('x', 'y')) == QQ.poly_ring('x', 'y') assert ZZ.unify(QQ.poly_ring('x', 'y')) == QQ.poly_ring('x', 'y') assert QQ.unify(QQ.poly_ring('x', 'y')) == QQ.poly_ring('x', 'y') assert ZZ.frac_field('x').unify(ZZ) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ) == QQ.frac_field('x') assert ZZ.unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert QQ.unify(ZZ.frac_field('x')) == EX # QQ.frac_field('x') assert ZZ.unify(QQ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.frac_field('x', 'y').unify(ZZ) == ZZ.frac_field('x', 'y') assert ZZ.frac_field('x', 'y').unify(QQ) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x', 'y').unify(ZZ) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x', 'y').unify(QQ) == QQ.frac_field('x', 'y') assert ZZ.unify(ZZ.frac_field('x', 'y')) == ZZ.frac_field('x', 'y') assert QQ.unify(ZZ.frac_field('x', 'y')) == EX # QQ.frac_field('x','y') assert ZZ.unify(QQ.frac_field('x', 'y')) == EX # QQ.frac_field('x','y') assert QQ.unify(QQ.frac_field('x', 'y')) == QQ.frac_field('x', 'y') assert ZZ.poly_ring('x').unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x') assert ZZ.poly_ring('x').unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(ZZ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.poly_ring('x', 'y').unify(ZZ.poly_ring('x')) == ZZ.poly_ring( 'x', 'y') assert ZZ.poly_ring('x', 'y').unify(QQ.poly_ring('x')) == QQ.poly_ring( 'x', 'y') assert QQ.poly_ring('x', 'y').unify(ZZ.poly_ring('x')) == QQ.poly_ring( 'x', 'y') assert QQ.poly_ring('x', 'y').unify(QQ.poly_ring('x')) == QQ.poly_ring( 'x', 'y') assert ZZ.poly_ring('x').unify(ZZ.poly_ring('x', 'y')) == ZZ.poly_ring( 'x', 'y') assert ZZ.poly_ring('x').unify(QQ.poly_ring('x', 'y')) == QQ.poly_ring( 'x', 'y') assert QQ.poly_ring('x').unify(ZZ.poly_ring('x', 'y')) == QQ.poly_ring( 'x', 'y') assert QQ.poly_ring('x').unify(QQ.poly_ring('x', 'y')) == QQ.poly_ring( 'x', 'y') assert ZZ.poly_ring('x', 'y').unify(ZZ.poly_ring('x', 'z')) == ZZ.poly_ring( 'x', 'y', 'z') assert ZZ.poly_ring('x', 'y').unify(QQ.poly_ring('x', 'z')) == QQ.poly_ring( 'x', 'y', 'z') assert QQ.poly_ring('x', 'y').unify(ZZ.poly_ring('x', 'z')) == QQ.poly_ring( 'x', 'y', 'z') assert QQ.poly_ring('x', 'y').unify(QQ.poly_ring('x', 'z')) == QQ.poly_ring( 'x', 'y', 'z') assert ZZ.frac_field('x').unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ.frac_field('x')) == QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.frac_field('x', 'y').unify(ZZ.frac_field('x')) == ZZ.frac_field( 'x', 'y') assert ZZ.frac_field('x', 'y').unify(QQ.frac_field('x')) == QQ.frac_field( 'x', 'y') assert QQ.frac_field('x', 'y').unify(ZZ.frac_field('x')) == QQ.frac_field( 'x', 'y') assert QQ.frac_field('x', 'y').unify(QQ.frac_field('x')) == QQ.frac_field( 'x', 'y') assert ZZ.frac_field('x').unify(ZZ.frac_field('x', 'y')) == ZZ.frac_field( 'x', 'y') assert ZZ.frac_field('x').unify(QQ.frac_field('x', 'y')) == QQ.frac_field( 'x', 'y') assert QQ.frac_field('x').unify(ZZ.frac_field('x', 'y')) == QQ.frac_field( 'x', 'y') assert QQ.frac_field('x').unify(QQ.frac_field('x', 'y')) == QQ.frac_field( 'x', 'y') assert ZZ.frac_field('x', 'y').unify(ZZ.frac_field('x', 'z')) == ZZ.frac_field( 'x', 'y', 'z') assert ZZ.frac_field('x', 'y').unify(QQ.frac_field('x', 'z')) == QQ.frac_field( 'x', 'y', 'z') assert QQ.frac_field('x', 'y').unify(ZZ.frac_field('x', 'z')) == QQ.frac_field( 'x', 'y', 'z') assert QQ.frac_field('x', 'y').unify(QQ.frac_field('x', 'z')) == QQ.frac_field( 'x', 'y', 'z') assert ZZ.poly_ring('x').unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert ZZ.poly_ring('x').unify( QQ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.poly_ring('x').unify( ZZ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.poly_ring('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.poly_ring('x', 'y').unify(ZZ.frac_field('x')) == ZZ.frac_field( 'x', 'y') assert ZZ.poly_ring('x', 'y').unify( QQ.frac_field('x')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x', 'y').unify( ZZ.frac_field('x')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x', 'y').unify(QQ.frac_field('x')) == QQ.frac_field( 'x', 'y') assert ZZ.poly_ring('x').unify(ZZ.frac_field('x', 'y')) == ZZ.frac_field( 'x', 'y') assert ZZ.poly_ring('x').unify(QQ.frac_field( 'x', 'y')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x').unify(ZZ.frac_field( 'x', 'y')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x').unify(QQ.frac_field('x', 'y')) == QQ.frac_field( 'x', 'y') assert ZZ.poly_ring('x', 'y').unify(ZZ.frac_field('x', 'z')) == ZZ.frac_field( 'x', 'y', 'z') assert ZZ.poly_ring('x', 'y').unify(QQ.frac_field( 'x', 'z')) == EX # QQ.frac_field('x','y','z') assert QQ.poly_ring('x', 'y').unify(ZZ.frac_field( 'x', 'z')) == EX # QQ.frac_field('x','y','z') assert QQ.poly_ring('x', 'y').unify(QQ.frac_field('x', 'z')) == QQ.frac_field( 'x', 'y', 'z') assert ZZ.frac_field('x').unify(ZZ.poly_ring('x')) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify( QQ.poly_ring('x')) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify( ZZ.poly_ring('x')) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ.poly_ring('x')) == QQ.frac_field('x') assert ZZ.frac_field('x', 'y').unify(ZZ.poly_ring('x')) == ZZ.frac_field( 'x', 'y') assert ZZ.frac_field('x', 'y').unify( QQ.poly_ring('x')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x', 'y').unify( ZZ.poly_ring('x')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x', 'y').unify(QQ.poly_ring('x')) == QQ.frac_field( 'x', 'y') assert ZZ.frac_field('x').unify(ZZ.poly_ring('x', 'y')) == ZZ.frac_field( 'x', 'y') assert ZZ.frac_field('x').unify(QQ.poly_ring( 'x', 'y')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x').unify(ZZ.poly_ring( 'x', 'y')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x').unify(QQ.poly_ring('x', 'y')) == QQ.frac_field( 'x', 'y') assert ZZ.frac_field('x', 'y').unify(ZZ.poly_ring('x', 'z')) == ZZ.frac_field( 'x', 'y', 'z') assert ZZ.frac_field('x', 'y').unify(QQ.poly_ring( 'x', 'z')) == EX # QQ.frac_field('x','y','z') assert QQ.frac_field('x', 'y').unify(ZZ.poly_ring( 'x', 'z')) == EX # QQ.frac_field('x','y','z') assert QQ.frac_field('x', 'y').unify(QQ.poly_ring('x', 'z')) == QQ.frac_field( 'x', 'y', 'z') alg = QQ.algebraic_field(sqrt(5)) assert alg.unify(alg['x', 'y']) == alg['x', 'y'] assert alg['x', 'y'].unify(alg) == alg['x', 'y'] assert alg.unify(alg.frac_field('x', 'y')) == alg.frac_field('x', 'y') assert alg.frac_field('x', 'y').unify(alg) == alg.frac_field('x', 'y') ext = QQ.algebraic_field(sqrt(7)) raises(NotImplementedError, "alg.unify(ext)") raises(UnificationFailed, "ZZ.poly_ring('x','y').unify(ZZ, gens=('y', 'z'))") raises(UnificationFailed, "ZZ.unify(ZZ.poly_ring('x','y'), gens=('y', 'z'))")
def test_PolynomialRing(): from sympy.polys.domains import QQ assert latex(QQ[x, y]) == r"\mathbb{Q}\left[x, y\right]" assert latex(QQ.poly_ring(x, y, order="ilex")) == r"S_<^{-1}\mathbb{Q}\left[x, y\right]"
def test_Domain_unify_composite(): assert unify(ZZ.poly_ring(x), ZZ) == ZZ.poly_ring(x) assert unify(ZZ.poly_ring(x), QQ) == QQ.poly_ring(x) assert unify(QQ.poly_ring(x), ZZ) == QQ.poly_ring(x) assert unify(QQ.poly_ring(x), QQ) == QQ.poly_ring(x) assert unify(ZZ, ZZ.poly_ring(x)) == ZZ.poly_ring(x) assert unify(QQ, ZZ.poly_ring(x)) == QQ.poly_ring(x) assert unify(ZZ, QQ.poly_ring(x)) == QQ.poly_ring(x) assert unify(QQ, QQ.poly_ring(x)) == QQ.poly_ring(x) assert unify(ZZ.poly_ring(x, y), ZZ) == ZZ.poly_ring(x, y) assert unify(ZZ.poly_ring(x, y), QQ) == QQ.poly_ring(x, y) assert unify(QQ.poly_ring(x, y), ZZ) == QQ.poly_ring(x, y) assert unify(QQ.poly_ring(x, y), QQ) == QQ.poly_ring(x, y) assert unify(ZZ, ZZ.poly_ring(x, y)) == ZZ.poly_ring(x, y) assert unify(QQ, ZZ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert unify(ZZ, QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert unify(QQ, QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert unify(ZZ.frac_field(x), ZZ) == ZZ.frac_field(x) assert unify(ZZ.frac_field(x), QQ) == QQ.frac_field(x) assert unify(QQ.frac_field(x), ZZ) == QQ.frac_field(x) assert unify(QQ.frac_field(x), QQ) == QQ.frac_field(x) assert unify(ZZ, ZZ.frac_field(x)) == ZZ.frac_field(x) assert unify(QQ, ZZ.frac_field(x)) == QQ.frac_field(x) assert unify(ZZ, QQ.frac_field(x)) == QQ.frac_field(x) assert unify(QQ, QQ.frac_field(x)) == QQ.frac_field(x) assert unify(ZZ.frac_field(x, y), ZZ) == ZZ.frac_field(x, y) assert unify(ZZ.frac_field(x, y), QQ) == QQ.frac_field(x, y) assert unify(QQ.frac_field(x, y), ZZ) == QQ.frac_field(x, y) assert unify(QQ.frac_field(x, y), QQ) == QQ.frac_field(x, y) assert unify(ZZ, ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert unify(QQ, ZZ.frac_field(x, y)) == QQ.frac_field(x, y) assert unify(ZZ, QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert unify(QQ, QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert unify(ZZ.poly_ring(x), ZZ.poly_ring(x)) == ZZ.poly_ring(x) assert unify(ZZ.poly_ring(x), QQ.poly_ring(x)) == QQ.poly_ring(x) assert unify(QQ.poly_ring(x), ZZ.poly_ring(x)) == QQ.poly_ring(x) assert unify(QQ.poly_ring(x), QQ.poly_ring(x)) == QQ.poly_ring(x) assert unify(ZZ.poly_ring(x, y), ZZ.poly_ring(x)) == ZZ.poly_ring(x, y) assert unify(ZZ.poly_ring(x, y), QQ.poly_ring(x)) == QQ.poly_ring(x, y) assert unify(QQ.poly_ring(x, y), ZZ.poly_ring(x)) == QQ.poly_ring(x, y) assert unify(QQ.poly_ring(x, y), QQ.poly_ring(x)) == QQ.poly_ring(x, y) assert unify(ZZ.poly_ring(x), ZZ.poly_ring(x, y)) == ZZ.poly_ring(x, y) assert unify(ZZ.poly_ring(x), QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert unify(QQ.poly_ring(x), ZZ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert unify(QQ.poly_ring(x), QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert unify(ZZ.poly_ring(x, y), ZZ.poly_ring(x, z)) == ZZ.poly_ring(x, y, z) assert unify(ZZ.poly_ring(x, y), QQ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert unify(QQ.poly_ring(x, y), ZZ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert unify(QQ.poly_ring(x, y), QQ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert unify(ZZ.frac_field(x), ZZ.frac_field(x)) == ZZ.frac_field(x) assert unify(ZZ.frac_field(x), QQ.frac_field(x)) == QQ.frac_field(x) assert unify(QQ.frac_field(x), ZZ.frac_field(x)) == QQ.frac_field(x) assert unify(QQ.frac_field(x), QQ.frac_field(x)) == QQ.frac_field(x) assert unify(ZZ.frac_field(x, y), ZZ.frac_field(x)) == ZZ.frac_field(x, y) assert unify(ZZ.frac_field(x, y), QQ.frac_field(x)) == QQ.frac_field(x, y) assert unify(QQ.frac_field(x, y), ZZ.frac_field(x)) == QQ.frac_field(x, y) assert unify(QQ.frac_field(x, y), QQ.frac_field(x)) == QQ.frac_field(x, y) assert unify(ZZ.frac_field(x), ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert unify(ZZ.frac_field(x), QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert unify(QQ.frac_field(x), ZZ.frac_field(x, y)) == QQ.frac_field(x, y) assert unify(QQ.frac_field(x), QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert unify(ZZ.frac_field(x, y), ZZ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert unify(ZZ.frac_field(x, y), QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert unify(QQ.frac_field(x, y), ZZ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert unify(QQ.frac_field(x, y), QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert unify(ZZ.poly_ring(x), ZZ.frac_field(x)) == ZZ.frac_field(x) assert unify(ZZ.poly_ring(x), QQ.frac_field(x)) == ZZ.frac_field(x) assert unify(QQ.poly_ring(x), ZZ.frac_field(x)) == ZZ.frac_field(x) assert unify(QQ.poly_ring(x), QQ.frac_field(x)) == QQ.frac_field(x) assert unify(ZZ.poly_ring(x, y), ZZ.frac_field(x)) == ZZ.frac_field(x, y) assert unify(ZZ.poly_ring(x, y), QQ.frac_field(x)) == ZZ.frac_field(x, y) assert unify(QQ.poly_ring(x, y), ZZ.frac_field(x)) == ZZ.frac_field(x, y) assert unify(QQ.poly_ring(x, y), QQ.frac_field(x)) == QQ.frac_field(x, y) assert unify(ZZ.poly_ring(x), ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert unify(ZZ.poly_ring(x), QQ.frac_field(x, y)) == ZZ.frac_field(x, y) assert unify(QQ.poly_ring(x), ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert unify(QQ.poly_ring(x), QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert unify(ZZ.poly_ring(x, y), ZZ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert unify(ZZ.poly_ring(x, y), QQ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert unify(QQ.poly_ring(x, y), ZZ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert unify(QQ.poly_ring(x, y), QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert unify(ZZ.frac_field(x), ZZ.poly_ring(x)) == ZZ.frac_field(x) assert unify(ZZ.frac_field(x), QQ.poly_ring(x)) == ZZ.frac_field(x) assert unify(QQ.frac_field(x), ZZ.poly_ring(x)) == ZZ.frac_field(x) assert unify(QQ.frac_field(x), QQ.poly_ring(x)) == QQ.frac_field(x) assert unify(ZZ.frac_field(x, y), ZZ.poly_ring(x)) == ZZ.frac_field(x, y) assert unify(ZZ.frac_field(x, y), QQ.poly_ring(x)) == ZZ.frac_field(x, y) assert unify(QQ.frac_field(x, y), ZZ.poly_ring(x)) == ZZ.frac_field(x, y) assert unify(QQ.frac_field(x, y), QQ.poly_ring(x)) == QQ.frac_field(x, y) assert unify(ZZ.frac_field(x), ZZ.poly_ring(x, y)) == ZZ.frac_field(x, y) assert unify(ZZ.frac_field(x), QQ.poly_ring(x, y)) == ZZ.frac_field(x, y) assert unify(QQ.frac_field(x), ZZ.poly_ring(x, y)) == ZZ.frac_field(x, y) assert unify(QQ.frac_field(x), QQ.poly_ring(x, y)) == QQ.frac_field(x, y) assert unify(ZZ.frac_field(x, y), ZZ.poly_ring(x, z)) == ZZ.frac_field(x, y, z) assert unify(ZZ.frac_field(x, y), QQ.poly_ring(x, z)) == ZZ.frac_field(x, y, z) assert unify(QQ.frac_field(x, y), ZZ.poly_ring(x, z)) == ZZ.frac_field(x, y, z) assert unify(QQ.frac_field(x, y), QQ.poly_ring(x, z)) == QQ.frac_field(x, y, z)
def test_Domain__unify(): assert ZZ.unify(ZZ) == ZZ assert QQ.unify(QQ) == QQ assert ZZ.unify(QQ) == QQ assert QQ.unify(ZZ) == QQ assert EX.unify(EX) == EX assert ZZ.unify(EX) == EX assert QQ.unify(EX) == EX assert EX.unify(ZZ) == EX assert EX.unify(QQ) == EX assert ZZ.poly_ring('x').unify(EX) == EX assert ZZ.frac_field('x').unify(EX) == EX assert EX.unify(ZZ.poly_ring('x')) == EX assert EX.unify(ZZ.frac_field('x')) == EX assert ZZ.poly_ring('x','y').unify(EX) == EX assert ZZ.frac_field('x','y').unify(EX) == EX assert EX.unify(ZZ.poly_ring('x','y')) == EX assert EX.unify(ZZ.frac_field('x','y')) == EX assert QQ.poly_ring('x').unify(EX) == EX assert QQ.frac_field('x').unify(EX) == EX assert EX.unify(QQ.poly_ring('x')) == EX assert EX.unify(QQ.frac_field('x')) == EX assert QQ.poly_ring('x','y').unify(EX) == EX assert QQ.frac_field('x','y').unify(EX) == EX assert EX.unify(QQ.poly_ring('x','y')) == EX assert EX.unify(QQ.frac_field('x','y')) == EX assert ZZ.poly_ring('x').unify(ZZ) == ZZ.poly_ring('x') assert ZZ.poly_ring('x').unify(QQ) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(ZZ) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(QQ) == QQ.poly_ring('x') assert ZZ.unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x') assert QQ.unify(ZZ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.poly_ring('x','y').unify(ZZ) == ZZ.poly_ring('x','y') assert ZZ.poly_ring('x','y').unify(QQ) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(ZZ) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(QQ) == QQ.poly_ring('x','y') assert ZZ.unify(ZZ.poly_ring('x','y')) == ZZ.poly_ring('x','y') assert QQ.unify(ZZ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert ZZ.unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert QQ.unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert ZZ.frac_field('x').unify(ZZ) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ) == QQ.frac_field('x') assert ZZ.unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert QQ.unify(ZZ.frac_field('x')) == EX # QQ.frac_field('x') assert ZZ.unify(QQ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.frac_field('x','y').unify(ZZ) == ZZ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(QQ) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(ZZ) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(QQ) == QQ.frac_field('x','y') assert ZZ.unify(ZZ.frac_field('x','y')) == ZZ.frac_field('x','y') assert QQ.unify(ZZ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert ZZ.unify(QQ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert QQ.unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert ZZ.poly_ring('x').unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x') assert ZZ.poly_ring('x').unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(ZZ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.poly_ring('x','y').unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x','y') assert ZZ.poly_ring('x','y').unify(QQ.poly_ring('x')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(ZZ.poly_ring('x')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(QQ.poly_ring('x')) == QQ.poly_ring('x','y') assert ZZ.poly_ring('x').unify(ZZ.poly_ring('x','y')) == ZZ.poly_ring('x','y') assert ZZ.poly_ring('x').unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x').unify(ZZ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x').unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert ZZ.poly_ring('x','y').unify(ZZ.poly_ring('x','z')) == ZZ.poly_ring('x','y','z') assert ZZ.poly_ring('x','y').unify(QQ.poly_ring('x','z')) == QQ.poly_ring('x','y','z') assert QQ.poly_ring('x','y').unify(ZZ.poly_ring('x','z')) == QQ.poly_ring('x','y','z') assert QQ.poly_ring('x','y').unify(QQ.poly_ring('x','z')) == QQ.poly_ring('x','y','z') assert ZZ.frac_field('x').unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ.frac_field('x')) == QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.frac_field('x','y').unify(ZZ.frac_field('x')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(QQ.frac_field('x')) == QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(ZZ.frac_field('x')) == QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(QQ.frac_field('x')) == QQ.frac_field('x','y') assert ZZ.frac_field('x').unify(ZZ.frac_field('x','y')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x').unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert QQ.frac_field('x').unify(ZZ.frac_field('x','y')) == QQ.frac_field('x','y') assert QQ.frac_field('x').unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(ZZ.frac_field('x','z')) == ZZ.frac_field('x','y','z') assert ZZ.frac_field('x','y').unify(QQ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(ZZ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(QQ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert ZZ.poly_ring('x').unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert ZZ.poly_ring('x').unify(QQ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.poly_ring('x').unify(ZZ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.poly_ring('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.poly_ring('x','y').unify(ZZ.frac_field('x')) == ZZ.frac_field('x','y') assert ZZ.poly_ring('x','y').unify(QQ.frac_field('x')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x','y').unify(ZZ.frac_field('x')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x','y').unify(QQ.frac_field('x')) == QQ.frac_field('x','y') assert ZZ.poly_ring('x').unify(ZZ.frac_field('x','y')) == ZZ.frac_field('x','y') assert ZZ.poly_ring('x').unify(QQ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x').unify(ZZ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x').unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert ZZ.poly_ring('x','y').unify(ZZ.frac_field('x','z')) == ZZ.frac_field('x','y','z') assert ZZ.poly_ring('x','y').unify(QQ.frac_field('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.poly_ring('x','y').unify(ZZ.frac_field('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.poly_ring('x','y').unify(QQ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert ZZ.frac_field('x').unify(ZZ.poly_ring('x')) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ.poly_ring('x')) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ.poly_ring('x')) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ.poly_ring('x')) == QQ.frac_field('x') assert ZZ.frac_field('x','y').unify(ZZ.poly_ring('x')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(QQ.poly_ring('x')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(ZZ.poly_ring('x')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(QQ.poly_ring('x')) == QQ.frac_field('x','y') assert ZZ.frac_field('x').unify(ZZ.poly_ring('x','y')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x').unify(QQ.poly_ring('x','y')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x').unify(ZZ.poly_ring('x','y')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x').unify(QQ.poly_ring('x','y')) == QQ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(ZZ.poly_ring('x','z')) == ZZ.frac_field('x','y','z') assert ZZ.frac_field('x','y').unify(QQ.poly_ring('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(ZZ.poly_ring('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(QQ.poly_ring('x','z')) == QQ.frac_field('x','y','z') alg = QQ.algebraic_field(sqrt(5)) assert alg.unify(alg['x','y']) == alg['x','y'] assert alg['x','y'].unify(alg) == alg['x','y'] assert alg.unify(alg.frac_field('x','y')) == alg.frac_field('x','y') assert alg.frac_field('x','y').unify(alg) == alg.frac_field('x','y') ext = QQ.algebraic_field(sqrt(7)) raises(NotImplementedError, "alg.unify(ext)") raises(UnificationFailed, "ZZ.poly_ring('x','y').unify(ZZ, gens=('y', 'z'))") raises(UnificationFailed, "ZZ.unify(ZZ.poly_ring('x','y'), gens=('y', 'z'))")
def test_build_order(): R = QQ.poly_ring(x, y, order=(("lex", x), ("ilex", y))) assert R.order((1, 5)) == ((1,), (-5,))
def test_Domain__unify(): assert ZZ.unify(ZZ) == ZZ assert QQ.unify(QQ) == QQ assert ZZ.unify(QQ) == QQ assert QQ.unify(ZZ) == QQ assert EX.unify(EX) == EX assert ZZ.unify(EX) == EX assert QQ.unify(EX) == EX assert EX.unify(ZZ) == EX assert EX.unify(QQ) == EX assert ZZ.poly_ring(x).unify(EX) == EX assert ZZ.frac_field(x).unify(EX) == EX assert EX.unify(ZZ.poly_ring(x)) == EX assert EX.unify(ZZ.frac_field(x)) == EX assert ZZ.poly_ring(x, y).unify(EX) == EX assert ZZ.frac_field(x, y).unify(EX) == EX assert EX.unify(ZZ.poly_ring(x, y)) == EX assert EX.unify(ZZ.frac_field(x, y)) == EX assert QQ.poly_ring(x).unify(EX) == EX assert QQ.frac_field(x).unify(EX) == EX assert EX.unify(QQ.poly_ring(x)) == EX assert EX.unify(QQ.frac_field(x)) == EX assert QQ.poly_ring(x, y).unify(EX) == EX assert QQ.frac_field(x, y).unify(EX) == EX assert EX.unify(QQ.poly_ring(x, y)) == EX assert EX.unify(QQ.frac_field(x, y)) == EX assert ZZ.poly_ring(x).unify(ZZ) == ZZ.poly_ring(x) assert ZZ.poly_ring(x).unify(QQ) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(ZZ) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(QQ) == QQ.poly_ring(x) assert ZZ.unify(ZZ.poly_ring(x)) == ZZ.poly_ring(x) assert QQ.unify(ZZ.poly_ring(x)) == QQ.poly_ring(x) assert ZZ.unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert QQ.unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert ZZ.poly_ring(x, y).unify(ZZ) == ZZ.poly_ring(x, y) assert ZZ.poly_ring(x, y).unify(QQ) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(ZZ) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(QQ) == QQ.poly_ring(x, y) assert ZZ.unify(ZZ.poly_ring(x, y)) == ZZ.poly_ring(x, y) assert QQ.unify(ZZ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert ZZ.unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert QQ.unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert ZZ.frac_field(x).unify(ZZ) == ZZ.frac_field(x) assert ZZ.frac_field(x).unify(QQ) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(ZZ) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(QQ) == QQ.frac_field(x) assert ZZ.unify(ZZ.frac_field(x)) == ZZ.frac_field(x) assert QQ.unify(ZZ.frac_field(x)) == EX # QQ.frac_field(x) assert ZZ.unify(QQ.frac_field(x)) == EX # QQ.frac_field(x) assert QQ.unify(QQ.frac_field(x)) == QQ.frac_field(x) assert ZZ.frac_field(x, y).unify(ZZ) == ZZ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(QQ) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify(ZZ) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify(QQ) == QQ.frac_field(x, y) assert ZZ.unify(ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert QQ.unify(ZZ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert ZZ.unify(QQ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert QQ.unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert ZZ.poly_ring(x).unify(ZZ.poly_ring(x)) == ZZ.poly_ring(x) assert ZZ.poly_ring(x).unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(ZZ.poly_ring(x)) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert ZZ.poly_ring(x, y).unify(ZZ.poly_ring(x)) == ZZ.poly_ring(x, y) assert ZZ.poly_ring(x, y).unify(QQ.poly_ring(x)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(ZZ.poly_ring(x)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(QQ.poly_ring(x)) == QQ.poly_ring(x, y) assert ZZ.poly_ring(x).unify(ZZ.poly_ring(x, y)) == ZZ.poly_ring(x, y) assert ZZ.poly_ring(x).unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x).unify(ZZ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x).unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert ZZ.poly_ring(x, y).unify(ZZ.poly_ring(x, z)) == ZZ.poly_ring(x, y, z) assert ZZ.poly_ring(x, y).unify(QQ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert QQ.poly_ring(x, y).unify(ZZ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert QQ.poly_ring(x, y).unify(QQ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert ZZ.frac_field(x).unify(ZZ.frac_field(x)) == ZZ.frac_field(x) assert ZZ.frac_field(x).unify(QQ.frac_field(x)) == QQ.frac_field(x) assert QQ.frac_field(x).unify(ZZ.frac_field(x)) == QQ.frac_field(x) assert QQ.frac_field(x).unify(QQ.frac_field(x)) == QQ.frac_field(x) assert ZZ.frac_field(x, y).unify(ZZ.frac_field(x)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(QQ.frac_field(x)) == QQ.frac_field(x, y) assert QQ.frac_field(x, y).unify(ZZ.frac_field(x)) == QQ.frac_field(x, y) assert QQ.frac_field(x, y).unify(QQ.frac_field(x)) == QQ.frac_field(x, y) assert ZZ.frac_field(x).unify(ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x).unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert QQ.frac_field(x).unify(ZZ.frac_field(x, y)) == QQ.frac_field(x, y) assert QQ.frac_field(x).unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(ZZ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert ZZ.frac_field(x, y).unify(QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert QQ.frac_field(x, y).unify(ZZ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert QQ.frac_field(x, y).unify(QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert ZZ.poly_ring(x).unify(ZZ.frac_field(x)) == ZZ.frac_field(x) assert ZZ.poly_ring(x).unify(QQ.frac_field(x)) == EX # QQ.frac_field(x) assert QQ.poly_ring(x).unify(ZZ.frac_field(x)) == EX # QQ.frac_field(x) assert QQ.poly_ring(x).unify(QQ.frac_field(x)) == QQ.frac_field(x) assert ZZ.poly_ring(x, y).unify(ZZ.frac_field(x)) == ZZ.frac_field(x, y) assert ZZ.poly_ring(x, y).unify(QQ.frac_field(x)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x, y).unify(ZZ.frac_field(x)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x, y).unify(QQ.frac_field(x)) == QQ.frac_field(x, y) assert ZZ.poly_ring(x).unify(ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert ZZ.poly_ring(x).unify(QQ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x).unify(ZZ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x).unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert ZZ.poly_ring(x, y).unify(ZZ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert ZZ.poly_ring(x, y).unify(QQ.frac_field(x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.poly_ring(x, y).unify(ZZ.frac_field(x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.poly_ring(x, y).unify(QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert ZZ.frac_field(x).unify(ZZ.poly_ring(x)) == ZZ.frac_field(x) assert ZZ.frac_field(x).unify(QQ.poly_ring(x)) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(ZZ.poly_ring(x)) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(QQ.poly_ring(x)) == QQ.frac_field(x) assert ZZ.frac_field(x, y).unify(ZZ.poly_ring(x)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(QQ.poly_ring(x)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify(ZZ.poly_ring(x)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify(QQ.poly_ring(x)) == QQ.frac_field(x, y) assert ZZ.frac_field(x).unify(ZZ.poly_ring(x, y)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x).unify(QQ.poly_ring(x, y)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x).unify(ZZ.poly_ring(x, y)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x).unify(QQ.poly_ring(x, y)) == QQ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(ZZ.poly_ring(x, z)) == ZZ.frac_field(x, y, z) assert ZZ.frac_field(x, y).unify(QQ.poly_ring(x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.frac_field(x, y).unify(ZZ.poly_ring(x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.frac_field(x, y).unify(QQ.poly_ring(x, z)) == QQ.frac_field(x, y, z) alg = QQ.algebraic_field(sqrt(5)) assert alg.unify(alg[x, y]) == alg[x, y] assert alg[x, y].unify(alg) == alg[x, y] assert alg.unify(alg.frac_field(x, y)) == alg.frac_field(x, y) assert alg.frac_field(x, y).unify(alg) == alg.frac_field(x, y) ext = QQ.algebraic_field(sqrt(7)) raises(NotImplementedError, lambda: alg.unify(ext)) raises(UnificationFailed, lambda: ZZ.poly_ring(x, y).unify(ZZ, gens=(y, z))) raises(UnificationFailed, lambda: ZZ.unify(ZZ.poly_ring(x, y), gens=(y, z)))
def test_Domain__unify(): assert ZZ.unify(ZZ) == ZZ assert QQ.unify(QQ) == QQ assert ZZ.unify(QQ) == QQ assert QQ.unify(ZZ) == QQ assert EX.unify(EX) == EX assert ZZ.unify(EX) == EX assert QQ.unify(EX) == EX assert EX.unify(ZZ) == EX assert EX.unify(QQ) == EX assert ZZ.poly_ring('x').unify(EX) == EX assert ZZ.frac_field('x').unify(EX) == EX assert EX.unify(ZZ.poly_ring('x')) == EX assert EX.unify(ZZ.frac_field('x')) == EX assert ZZ.poly_ring('x','y').unify(EX) == EX assert ZZ.frac_field('x','y').unify(EX) == EX assert EX.unify(ZZ.poly_ring('x','y')) == EX assert EX.unify(ZZ.frac_field('x','y')) == EX assert QQ.poly_ring('x').unify(EX) == EX assert QQ.frac_field('x').unify(EX) == EX assert EX.unify(QQ.poly_ring('x')) == EX assert EX.unify(QQ.frac_field('x')) == EX assert QQ.poly_ring('x','y').unify(EX) == EX assert QQ.frac_field('x','y').unify(EX) == EX assert EX.unify(QQ.poly_ring('x','y')) == EX assert EX.unify(QQ.frac_field('x','y')) == EX assert ZZ.poly_ring('x').unify(ZZ) == ZZ.poly_ring('x') assert ZZ.poly_ring('x').unify(QQ) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(ZZ) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(QQ) == QQ.poly_ring('x') assert ZZ.unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x') assert QQ.unify(ZZ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.poly_ring('x','y').unify(ZZ) == ZZ.poly_ring('x','y') assert ZZ.poly_ring('x','y').unify(QQ) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(ZZ) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(QQ) == QQ.poly_ring('x','y') assert ZZ.unify(ZZ.poly_ring('x','y')) == ZZ.poly_ring('x','y') assert QQ.unify(ZZ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert ZZ.unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert QQ.unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert ZZ.frac_field('x').unify(ZZ) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ) == QQ.frac_field('x') assert ZZ.unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert QQ.unify(ZZ.frac_field('x')) == EX # QQ.frac_field('x') assert ZZ.unify(QQ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.frac_field('x','y').unify(ZZ) == ZZ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(QQ) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(ZZ) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(QQ) == QQ.frac_field('x','y') assert ZZ.unify(ZZ.frac_field('x','y')) == ZZ.frac_field('x','y') assert QQ.unify(ZZ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert ZZ.unify(QQ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert QQ.unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert ZZ.poly_ring('x').unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x') assert ZZ.poly_ring('x').unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(ZZ.poly_ring('x')) == QQ.poly_ring('x') assert QQ.poly_ring('x').unify(QQ.poly_ring('x')) == QQ.poly_ring('x') assert ZZ.poly_ring('x','y').unify(ZZ.poly_ring('x')) == ZZ.poly_ring('x','y') assert ZZ.poly_ring('x','y').unify(QQ.poly_ring('x')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(ZZ.poly_ring('x')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x','y').unify(QQ.poly_ring('x')) == QQ.poly_ring('x','y') assert ZZ.poly_ring('x').unify(ZZ.poly_ring('x','y')) == ZZ.poly_ring('x','y') assert ZZ.poly_ring('x').unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x').unify(ZZ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert QQ.poly_ring('x').unify(QQ.poly_ring('x','y')) == QQ.poly_ring('x','y') assert ZZ.poly_ring('x','y').unify(ZZ.poly_ring('x','z')) == ZZ.poly_ring('x','y','z') assert ZZ.poly_ring('x','y').unify(QQ.poly_ring('x','z')) == QQ.poly_ring('x','y','z') assert QQ.poly_ring('x','y').unify(ZZ.poly_ring('x','z')) == QQ.poly_ring('x','y','z') assert QQ.poly_ring('x','y').unify(QQ.poly_ring('x','z')) == QQ.poly_ring('x','y','z') assert ZZ.frac_field('x').unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ.frac_field('x')) == QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.frac_field('x','y').unify(ZZ.frac_field('x')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(QQ.frac_field('x')) == QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(ZZ.frac_field('x')) == QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(QQ.frac_field('x')) == QQ.frac_field('x','y') assert ZZ.frac_field('x').unify(ZZ.frac_field('x','y')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x').unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert QQ.frac_field('x').unify(ZZ.frac_field('x','y')) == QQ.frac_field('x','y') assert QQ.frac_field('x').unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(ZZ.frac_field('x','z')) == ZZ.frac_field('x','y','z') assert ZZ.frac_field('x','y').unify(QQ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(ZZ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(QQ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert ZZ.poly_ring('x').unify(ZZ.frac_field('x')) == ZZ.frac_field('x') assert ZZ.poly_ring('x').unify(QQ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.poly_ring('x').unify(ZZ.frac_field('x')) == EX # QQ.frac_field('x') assert QQ.poly_ring('x').unify(QQ.frac_field('x')) == QQ.frac_field('x') assert ZZ.poly_ring('x','y').unify(ZZ.frac_field('x')) == ZZ.frac_field('x','y') assert ZZ.poly_ring('x','y').unify(QQ.frac_field('x')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x','y').unify(ZZ.frac_field('x')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x','y').unify(QQ.frac_field('x')) == QQ.frac_field('x','y') assert ZZ.poly_ring('x').unify(ZZ.frac_field('x','y')) == ZZ.frac_field('x','y') assert ZZ.poly_ring('x').unify(QQ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x').unify(ZZ.frac_field('x','y')) == EX # QQ.frac_field('x','y') assert QQ.poly_ring('x').unify(QQ.frac_field('x','y')) == QQ.frac_field('x','y') assert ZZ.poly_ring('x','y').unify(ZZ.frac_field('x','z')) == ZZ.frac_field('x','y','z') assert ZZ.poly_ring('x','y').unify(QQ.frac_field('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.poly_ring('x','y').unify(ZZ.frac_field('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.poly_ring('x','y').unify(QQ.frac_field('x','z')) == QQ.frac_field('x','y','z') assert ZZ.frac_field('x').unify(ZZ.poly_ring('x')) == ZZ.frac_field('x') assert ZZ.frac_field('x').unify(QQ.poly_ring('x')) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(ZZ.poly_ring('x')) == EX # QQ.frac_field('x') assert QQ.frac_field('x').unify(QQ.poly_ring('x')) == QQ.frac_field('x') assert ZZ.frac_field('x','y').unify(ZZ.poly_ring('x')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(QQ.poly_ring('x')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(ZZ.poly_ring('x')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x','y').unify(QQ.poly_ring('x')) == QQ.frac_field('x','y') assert ZZ.frac_field('x').unify(ZZ.poly_ring('x','y')) == ZZ.frac_field('x','y') assert ZZ.frac_field('x').unify(QQ.poly_ring('x','y')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x').unify(ZZ.poly_ring('x','y')) == EX # QQ.frac_field('x','y') assert QQ.frac_field('x').unify(QQ.poly_ring('x','y')) == QQ.frac_field('x','y') assert ZZ.frac_field('x','y').unify(ZZ.poly_ring('x','z')) == ZZ.frac_field('x','y','z') assert ZZ.frac_field('x','y').unify(QQ.poly_ring('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(ZZ.poly_ring('x','z')) == EX # QQ.frac_field('x','y','z') assert QQ.frac_field('x','y').unify(QQ.poly_ring('x','z')) == QQ.frac_field('x','y','z') raises(UnificationFailed, "ZZ.poly_ring('x','y').unify(ZZ, gens=('y', 'z'))") raises(UnificationFailed, "ZZ.unify(ZZ.poly_ring('x','y'), gens=('y', 'z'))")
def test_Domain__unify(): assert ZZ.unify(ZZ) == ZZ assert QQ.unify(QQ) == QQ assert ZZ.unify(QQ) == QQ assert QQ.unify(ZZ) == QQ assert EX.unify(EX) == EX assert ZZ.unify(EX) == EX assert QQ.unify(EX) == EX assert EX.unify(ZZ) == EX assert EX.unify(QQ) == EX assert ZZ.poly_ring(x).unify(EX) == EX assert ZZ.frac_field(x).unify(EX) == EX assert EX.unify(ZZ.poly_ring(x)) == EX assert EX.unify(ZZ.frac_field(x)) == EX assert ZZ.poly_ring(x, y).unify(EX) == EX assert ZZ.frac_field(x, y).unify(EX) == EX assert EX.unify(ZZ.poly_ring(x, y)) == EX assert EX.unify(ZZ.frac_field(x, y)) == EX assert QQ.poly_ring(x).unify(EX) == EX assert QQ.frac_field(x).unify(EX) == EX assert EX.unify(QQ.poly_ring(x)) == EX assert EX.unify(QQ.frac_field(x)) == EX assert QQ.poly_ring(x, y).unify(EX) == EX assert QQ.frac_field(x, y).unify(EX) == EX assert EX.unify(QQ.poly_ring(x, y)) == EX assert EX.unify(QQ.frac_field(x, y)) == EX assert ZZ.poly_ring(x).unify(ZZ) == ZZ.poly_ring(x) assert ZZ.poly_ring(x).unify(QQ) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(ZZ) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(QQ) == QQ.poly_ring(x) assert ZZ.unify(ZZ.poly_ring(x)) == ZZ.poly_ring(x) assert QQ.unify(ZZ.poly_ring(x)) == QQ.poly_ring(x) assert ZZ.unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert QQ.unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert ZZ.poly_ring(x, y).unify(ZZ) == ZZ.poly_ring(x, y) assert ZZ.poly_ring(x, y).unify(QQ) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(ZZ) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(QQ) == QQ.poly_ring(x, y) assert ZZ.unify(ZZ.poly_ring(x, y)) == ZZ.poly_ring(x, y) assert QQ.unify(ZZ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert ZZ.unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert QQ.unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert ZZ.frac_field(x).unify(ZZ) == ZZ.frac_field(x) assert ZZ.frac_field(x).unify(QQ) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(ZZ) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(QQ) == QQ.frac_field(x) assert ZZ.unify(ZZ.frac_field(x)) == ZZ.frac_field(x) assert QQ.unify(ZZ.frac_field(x)) == EX # QQ.frac_field(x) assert ZZ.unify(QQ.frac_field(x)) == EX # QQ.frac_field(x) assert QQ.unify(QQ.frac_field(x)) == QQ.frac_field(x) assert ZZ.frac_field(x, y).unify(ZZ) == ZZ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(QQ) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify(ZZ) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify(QQ) == QQ.frac_field(x, y) assert ZZ.unify(ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert QQ.unify(ZZ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert ZZ.unify(QQ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert QQ.unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert ZZ.poly_ring(x).unify(ZZ.poly_ring(x)) == ZZ.poly_ring(x) assert ZZ.poly_ring(x).unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(ZZ.poly_ring(x)) == QQ.poly_ring(x) assert QQ.poly_ring(x).unify(QQ.poly_ring(x)) == QQ.poly_ring(x) assert ZZ.poly_ring(x, y).unify(ZZ.poly_ring(x)) == ZZ.poly_ring(x, y) assert ZZ.poly_ring(x, y).unify(QQ.poly_ring(x)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(ZZ.poly_ring(x)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x, y).unify(QQ.poly_ring(x)) == QQ.poly_ring(x, y) assert ZZ.poly_ring(x).unify(ZZ.poly_ring(x, y)) == ZZ.poly_ring(x, y) assert ZZ.poly_ring(x).unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x).unify(ZZ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert QQ.poly_ring(x).unify(QQ.poly_ring(x, y)) == QQ.poly_ring(x, y) assert ZZ.poly_ring(x, y).unify(ZZ.poly_ring(x, z)) == ZZ.poly_ring(x, y, z) assert ZZ.poly_ring(x, y).unify(QQ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert QQ.poly_ring(x, y).unify(ZZ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert QQ.poly_ring(x, y).unify(QQ.poly_ring(x, z)) == QQ.poly_ring(x, y, z) assert ZZ.frac_field(x).unify(ZZ.frac_field(x)) == ZZ.frac_field(x) assert ZZ.frac_field(x).unify(QQ.frac_field(x)) == QQ.frac_field(x) assert QQ.frac_field(x).unify(ZZ.frac_field(x)) == QQ.frac_field(x) assert QQ.frac_field(x).unify(QQ.frac_field(x)) == QQ.frac_field(x) assert ZZ.frac_field(x, y).unify(ZZ.frac_field(x)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(QQ.frac_field(x)) == QQ.frac_field(x, y) assert QQ.frac_field(x, y).unify(ZZ.frac_field(x)) == QQ.frac_field(x, y) assert QQ.frac_field(x, y).unify(QQ.frac_field(x)) == QQ.frac_field(x, y) assert ZZ.frac_field(x).unify(ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x).unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert QQ.frac_field(x).unify(ZZ.frac_field(x, y)) == QQ.frac_field(x, y) assert QQ.frac_field(x).unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(ZZ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert ZZ.frac_field(x, y).unify(QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert QQ.frac_field(x, y).unify(ZZ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert QQ.frac_field(x, y).unify(QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert ZZ.poly_ring(x).unify(ZZ.frac_field(x)) == ZZ.frac_field(x) assert ZZ.poly_ring(x).unify(QQ.frac_field(x)) == EX # QQ.frac_field(x) assert QQ.poly_ring(x).unify(ZZ.frac_field(x)) == EX # QQ.frac_field(x) assert QQ.poly_ring(x).unify(QQ.frac_field(x)) == QQ.frac_field(x) assert ZZ.poly_ring(x, y).unify(ZZ.frac_field(x)) == ZZ.frac_field(x, y) assert ZZ.poly_ring(x, y).unify( QQ.frac_field(x)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x, y).unify( ZZ.frac_field(x)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x, y).unify(QQ.frac_field(x)) == QQ.frac_field(x, y) assert ZZ.poly_ring(x).unify(ZZ.frac_field(x, y)) == ZZ.frac_field(x, y) assert ZZ.poly_ring(x).unify(QQ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x).unify(ZZ.frac_field(x, y)) == EX # QQ.frac_field(x,y) assert QQ.poly_ring(x).unify(QQ.frac_field(x, y)) == QQ.frac_field(x, y) assert ZZ.poly_ring(x, y).unify(ZZ.frac_field(x, z)) == ZZ.frac_field(x, y, z) assert ZZ.poly_ring(x, y).unify(QQ.frac_field( x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.poly_ring(x, y).unify(ZZ.frac_field( x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.poly_ring(x, y).unify(QQ.frac_field(x, z)) == QQ.frac_field(x, y, z) assert ZZ.frac_field(x).unify(ZZ.poly_ring(x)) == ZZ.frac_field(x) assert ZZ.frac_field(x).unify(QQ.poly_ring(x)) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(ZZ.poly_ring(x)) == EX # QQ.frac_field(x) assert QQ.frac_field(x).unify(QQ.poly_ring(x)) == QQ.frac_field(x) assert ZZ.frac_field(x, y).unify(ZZ.poly_ring(x)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x, y).unify( QQ.poly_ring(x)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify( ZZ.poly_ring(x)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x, y).unify(QQ.poly_ring(x)) == QQ.frac_field(x, y) assert ZZ.frac_field(x).unify(ZZ.poly_ring(x, y)) == ZZ.frac_field(x, y) assert ZZ.frac_field(x).unify(QQ.poly_ring(x, y)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x).unify(ZZ.poly_ring(x, y)) == EX # QQ.frac_field(x,y) assert QQ.frac_field(x).unify(QQ.poly_ring(x, y)) == QQ.frac_field(x, y) assert ZZ.frac_field(x, y).unify(ZZ.poly_ring(x, z)) == ZZ.frac_field(x, y, z) assert ZZ.frac_field(x, y).unify(QQ.poly_ring( x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.frac_field(x, y).unify(ZZ.poly_ring( x, z)) == EX # QQ.frac_field(x,y,z) assert QQ.frac_field(x, y).unify(QQ.poly_ring(x, z)) == QQ.frac_field(x, y, z) alg = QQ.algebraic_field(sqrt(5)) assert alg.unify(alg[x, y]) == alg[x, y] assert alg[x, y].unify(alg) == alg[x, y] assert alg.unify(alg.frac_field(x, y)) == alg.frac_field(x, y) assert alg.frac_field(x, y).unify(alg) == alg.frac_field(x, y) ext = QQ.algebraic_field(sqrt(7)) raises(NotImplementedError, lambda: alg.unify(ext)) raises(UnificationFailed, lambda: ZZ.poly_ring(x, y).unify(ZZ, gens=(y, z))) raises(UnificationFailed, lambda: ZZ.unify(ZZ.poly_ring(x, y), gens=(y, z)))