From cb6e73070df4acd9a40a61f6159068418e1a5c61 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 14 Mar 2018 20:38:29 +0300 Subject: [PATCH] Removed old, Expr-derived AlgebraicNumber class There are little regression in supporting simplifications of algebraic numbers. Former AlgebraicNumber._eval_simplify() method was naive and not very powerful. --- diofant/core/__init__.py | 2 +- diofant/core/add.py | 4 - diofant/core/basic.py | 1 - diofant/core/mul.py | 7 - diofant/core/numbers.py | 180 +------------ diofant/core/tests/test_args.py | 10 +- diofant/core/tests/test_numbers.py | 22 +- diofant/domains/algebraicfield.py | 3 +- diofant/polys/numberfields.py | 16 +- diofant/polys/polyclasses.py | 13 +- diofant/polys/tests/test_numberfields.py | 252 ++----------------- diofant/printing/mathematica.py | 6 +- diofant/printing/pretty/pretty.py | 9 +- diofant/printing/pretty/tests/test_pretty.py | 30 +-- diofant/printing/repr.py | 4 + diofant/printing/str.py | 4 +- diofant/printing/tests/test_mathematica.py | 12 +- diofant/printing/tests/test_repr.py | 20 +- diofant/printing/tests/test_str.py | 15 +- diofant/simplify/tests/test_simplify.py | 6 + diofant/tests/test_wester.py | 26 +- diofant/utilities/tests/test_pickling.py | 9 +- docs/modules/core.rst | 5 - docs/release/notes-0.10.rst | 5 +- docs/release/notes-0.9.rst | 4 +- 25 files changed, 119 insertions(+), 546 deletions(-) diff --git a/diofant/core/__init__.py b/diofant/core/__init__.py index 8134bcc380..0be7608afd 100644 --- a/diofant/core/__init__.py +++ b/diofant/core/__init__.py @@ -9,7 +9,7 @@ from .symbol import Symbol, Wild, Dummy, symbols, var # noqa: F401 from .numbers import (Number, Float, Rational, Integer, # noqa: F401 NumberSymbol, igcd, ilcm, seterr, E, I, nan, oo, - pi, zoo, AlgebraicNumber, comp, mod_inverse) + pi, zoo, comp, mod_inverse) from .power import Pow, integer_nthroot # noqa: F401 from .mul import Mul, prod # noqa: F401 from .add import Add # noqa: F401 diff --git a/diofant/core/add.py b/diofant/core/add.py index 2999b4e4b2..1bc496bd97 100644 --- a/diofant/core/add.py +++ b/diofant/core/add.py @@ -82,10 +82,6 @@ def flatten(cls, seq): o # XXX "peephole" optimization, http://bugs.python.org/issue2506 continue - elif o.is_AlgebraicNumber: - coeff += o - continue - elif o is zoo: if coeff.is_finite is False: # we know for sure the result will be nan diff --git a/diofant/core/basic.py b/diofant/core/basic.py index a5698098a4..64a833d00b 100644 --- a/diofant/core/basic.py +++ b/diofant/core/basic.py @@ -36,7 +36,6 @@ class Basic(object): is_Derivative = False is_Piecewise = False is_Poly = False - is_AlgebraicNumber = False is_Relational = False is_Equality = False is_Boolean = False diff --git a/diofant/core/mul.py b/diofant/core/mul.py index 38a929fc4a..98ca9ecb7c 100644 --- a/diofant/core/mul.py +++ b/diofant/core/mul.py @@ -19,7 +19,6 @@ class NC_Marker: is_Order = False is_Mul = False is_Number = False - is_AlgebraicNumber = False is_Poly = False is_commutative = False @@ -251,15 +250,9 @@ def flatten(cls, seq): if coeff is nan: # we know for sure the result will be nan return [nan], [], None - elif coeff.is_AlgebraicNumber: - coeff *= o o # XXX "peephole" optimization, http://bugs.python.org/issue2506 continue - elif o.is_AlgebraicNumber: - coeff *= o - continue - elif o is zoo: if not coeff: # 0 * zoo = NaN diff --git a/diofant/core/numbers.py b/diofant/core/numbers.py index bd05604a77..67feb39633 100644 --- a/diofant/core/numbers.py +++ b/diofant/core/numbers.py @@ -1184,7 +1184,7 @@ def __neg__(self): def __add__(self, other): if isinstance(other, Rational): return Rational(self.p*other.q + self.q*other.p, self.q*other.q) - elif isinstance(other, (Float, AlgebraicNumber)): + elif isinstance(other, Float): return other + self else: return Number.__add__(self, other) @@ -1193,7 +1193,7 @@ def __add__(self, other): def __sub__(self, other): if isinstance(other, Rational): return Rational(self.p*other.q - self.q*other.p, self.q*other.q) - elif isinstance(other, (Float, AlgebraicNumber)): + elif isinstance(other, Float): return -other + self else: return Number.__sub__(self, other) @@ -1202,7 +1202,7 @@ def __sub__(self, other): def __mul__(self, other): if isinstance(other, Rational): return Rational(self.p*other.p, self.q*other.q) - elif isinstance(other, (Float, AlgebraicNumber)): + elif isinstance(other, Float): return other*self else: return Number.__mul__(self, other) @@ -1638,180 +1638,6 @@ def __rfloordiv__(self, other): converter[int] = Integer -class AlgebraicNumber(Expr): - r"""Class for algebraic numbers in Diofant. - - Represents the algebraic number in the field `\mathbb Q[\theta]` - given by - - .. math:: - c_n \theta^n + c_{n-1} \theta^{n-1} + \dots + c_0 - - Parameters - ========== - - expr : Expr - A generator `\theta` for the algebraic number. - - coeffs : tuple, optional - A tuple of rational coefficients `(c_n, c_{n-1},\dots,c_0)`. - The default is ``(1, 0)``. - - See Also - ======== - - diofant.polys.rootoftools.RootOf - """ - - is_AlgebraicNumber = True - is_algebraic = True - is_number = True - - def __new__(cls, expr, coeffs=(1, 0), **kwargs): - """Construct a new algebraic number. """ - from ..polys import Poly - from ..polys.polyclasses import DMP - from ..polys.numberfields import minimal_polynomial - - expr = sympify(expr) - - if isinstance(expr, (tuple, Tuple)): - minpoly, root = expr - - if not minpoly.is_Poly: - minpoly = Poly(minpoly) - elif expr.is_AlgebraicNumber: - minpoly, root = expr.minpoly, expr.root - else: - if expr.free_symbols: - raise ValueError("Not a number: %s" % expr) - - minpoly, root = minimal_polynomial(expr), expr - if kwargs.get('gen'): - minpoly = minpoly.replace(kwargs.get('gen')) - - dom = minpoly.domain.field - - if isinstance(coeffs, DMP): - rep = coeffs - else: - rep = DMP.from_diofant_list(sympify(coeffs), 0, dom) - - if rep.degree() >= minpoly.degree(): - rep = rep.rem(minpoly.rep) - - coeffs = Tuple(*rep.all_coeffs()) - args = root, coeffs - - obj = Expr.__new__(cls, *args) - - obj.rep = rep - obj.root = root - obj.minpoly = minpoly - - return obj - - @property - def free_symbols(self): - return set() - - def _eval_power(self, expt): - if expt.is_Integer: - A = self.rep.domain.algebraic_field(self.root) - r = A(self.rep.rep)**int(expt) - return self.func(self, r.rep) - - @_sympifyit('other', NotImplemented) - def __add__(self, other): - if other.is_Rational: - other = self.func(self, (other,)) - - if other.is_AlgebraicNumber: - if self.minpoly == other.minpoly and self.root == other.root: - return self.func(self, self.rep + other.rep) - else: - return Add(self, other, evaluate=False) - else: - return Number.__add__(self, other) - - @_sympifyit('other', NotImplemented) - def __sub__(self, other): - if other.is_Rational: - other = self.func(self, (other,)) - - if other.is_AlgebraicNumber: - if self.minpoly == other.minpoly and self.root == other.root: - return self.func(self, self.rep - other.rep) - else: - return Add(self, -other, evaluate=False) - else: - return Number.__sub__(self, other) - - @_sympifyit('other', NotImplemented) - def __mul__(self, other): - if other.is_Rational: - other = self.func(self, (other,)) - - if other.is_AlgebraicNumber: - if self.minpoly == other.minpoly and self.root == other.root: - return self.func(self, self.rep * other.rep) - else: - return Mul(self, other, evaluate=False) - else: - return Number.__mul__(self, other) - - def _eval_evalf(self, prec): - return self.as_expr()._evalf(prec) - - def as_poly(self, x=None): - """Create a Poly instance from ``self``. """ - from .symbol import Dummy - from ..polys import Poly, PurePoly - if x is not None: - return Poly.new(self.rep, x) - else: - return PurePoly.new(self.rep, Dummy('x')) - - def as_expr(self, x=None): - """Create a Basic expression from ``self``. """ - return self.as_poly(x or self.root).as_expr().expand() - - def coeffs(self): - """Returns all Diofant coefficients of an algebraic number. """ - return [self.rep.domain.to_expr(c) for c in self.rep.all_coeffs()] - - def native_coeffs(self): - """Returns all native coefficients of an algebraic number. """ - return self.rep.all_coeffs() - - def to_algebraic_integer(self): - """Convert ``self`` to an algebraic integer. """ - from ..polys import Poly - f = self.minpoly - - if f.LC() == 1: - return self - - coeff = f.LC()**(f.degree() - 1) - poly = f.compose(Poly(f.gen/f.LC())) - - minpoly = poly*coeff - root = f.LC()*self.root - - return AlgebraicNumber((minpoly, root), self.coeffs()) - - def _eval_simplify(self, ratio, measure): - from ..polys import RootOf, minimal_polynomial - from .symbol import Dummy - - for r in [r for r in self.minpoly.all_roots() if r.func != RootOf]: - if minimal_polynomial(self.root - r)(Dummy()).is_Symbol: - # use the matching root if it's simpler - if measure(r) < ratio*measure(self.root): - return AlgebraicNumber(r) - return self - - class RationalConstant(Rational): """ Abstract base class for rationals with specific behaviors diff --git a/diofant/core/tests/test_args.py b/diofant/core/tests/test_args.py index 16fc6a1bfe..cd10433071 100644 --- a/diofant/core/tests/test_args.py +++ b/diofant/core/tests/test_args.py @@ -8,8 +8,8 @@ import re import warnings -from diofant import (ITE, Add, Adjoint, AlgebraicNumber, And, Atom, AtomicExpr, - Basic, BlockDiagMatrix, BlockMatrix, Complement, Contains, +from diofant import (ITE, Add, Adjoint, And, Atom, AtomicExpr, Basic, + BlockDiagMatrix, BlockMatrix, Complement, Contains, DeferredVector, Derivative, Determinant, DiagonalMatrix, DiagonalOf, Dict, Dummy, Equality, Equivalent, Expr, FiniteSet, Float, FunctionMatrix, GrayCode, GreaterThan, @@ -25,7 +25,7 @@ StrictLessThan, Subs, Subset, Sum, Symbol, SymmetricDifference, Trace, Transpose, Tuple, Unequality, Union, Wild, WildFunction, Xor, ZeroMatrix, divisor_sigma, - false, mobius, oo, sin, sqrt, symbols, totient, true) + false, mobius, oo, sin, symbols, totient, true) from diofant.abc import a, b, c, w, x, y, z from diofant.concrete.expr_with_intlimits import ExprWithIntLimits from diofant.concrete.expr_with_limits import AddWithLimits, ExprWithLimits @@ -1849,10 +1849,6 @@ def test_diofant__matrices__expressions__factorizations__Factorization(): pass -def test_diofant__core__numbers__AlgebraicNumber(): - assert _test_args(AlgebraicNumber(sqrt(2), [1, 2, 3])) - - def test_diofant__polys__polytools__GroebnerBasis(): assert _test_args(GroebnerBasis([x, y, z], x, y, z)) diff --git a/diofant/core/tests/test_numbers.py b/diofant/core/tests/test_numbers.py index 9690a13286..912c074bc1 100644 --- a/diofant/core/tests/test_numbers.py +++ b/diofant/core/tests/test_numbers.py @@ -8,11 +8,10 @@ from mpmath import mpf from mpmath.libmp.libmpf import _normalize, finf, fnan, fninf -from diofant import (AlgebraicNumber, Catalan, E, EulerGamma, Float, Ge, - GoldenRatio, Gt, I, Integer, Le, Lt, Mul, Number, Pow, - Rational, Symbol, cbrt, cos, exp, factorial, false, latex, - log, nan, nextprime, oo, pi, root, simplify, sin, sqrt, - true, zoo) +from diofant import (Catalan, E, EulerGamma, Float, Ge, GoldenRatio, Gt, I, + Integer, Le, Lt, Mul, Number, Pow, Rational, Symbol, cbrt, + cos, exp, factorial, false, latex, log, nan, nextprime, + oo, pi, root, sin, sqrt, true, zoo) from diofant.core.cache import clear_cache from diofant.core.numbers import (comp, igcd, igcdex, ilcm, mod_inverse, mpf_norm, seterr) @@ -1495,19 +1494,6 @@ def test_sympyissue_7742(): assert -oo % 1 == nan -def test_simplify_AlgebraicNumber(): - A = AlgebraicNumber - e = root(3, 6)*(3 + (135 + 78*sqrt(3))**Rational(2, 3))/cbrt(45 + 26*sqrt(3)) - assert simplify(A(e)) == A(12) # wester test_C20 - assert simplify(A(12)) == A(12) - - e = root(41 + 29*sqrt(2), 5) - assert simplify(A(e)) == A(1 + sqrt(2)) # wester test_C21 - - e = (3 + 4*I)**Rational(3, 2) - assert simplify(A(e)) == A(2 + 11*I) # issue sympy/sympy#4401 - - def test_Float_idempotence(): x = Float('1.23', '') y = Float(x) diff --git a/diofant/domains/algebraicfield.py b/diofant/domains/algebraicfield.py index 67742737c4..0435c8569a 100644 --- a/diofant/domains/algebraicfield.py +++ b/diofant/domains/algebraicfield.py @@ -10,6 +10,7 @@ from ..polys.densetools import dmp_compose from ..polys.euclidtools import dup_invert from ..polys.polyerrors import CoercionFailed, DomainError, NotAlgebraic +from ..printing.defaults import DefaultPrinting from .characteristiczero import CharacteristicZero from .domainelement import DomainElement from .field import Field @@ -140,7 +141,7 @@ def is_nonnegative(self, a): return self.domain.is_nonnegative(a.LC()) -class AlgebraicElement(DomainElement, CantSympify): +class AlgebraicElement(DomainElement, CantSympify, DefaultPrinting): """Dense Algebraic Number Polynomials over a field. """ def __init__(self, rep): diff --git a/diofant/polys/numberfields.py b/diofant/polys/numberfields.py index deeb71b6a6..6b0818a677 100644 --- a/diofant/polys/numberfields.py +++ b/diofant/polys/numberfields.py @@ -5,8 +5,8 @@ import mpmath -from ..core import (Add, AlgebraicNumber, Dummy, E, GoldenRatio, I, Integer, - Mul, Rational, S, pi, prod, sympify) +from ..core import (Add, Dummy, E, GoldenRatio, I, Mul, Rational, S, pi, prod, + sympify) from ..core.exprtools import Factors from ..core.function import _mexpand from ..domains import QQ, ZZ, AlgebraicField @@ -513,8 +513,6 @@ def _minpoly_compose(ex, x, dom): res = _minpoly_cos(ex, x) elif ex.__class__ is RootOf: res = _minpoly_rootof(ex, x) - elif ex.__class__ is AlgebraicNumber: - res = minpoly_groebner(ex, x, dom) else: raise NotAlgebraic("%s doesn't seem to be an algebraic element" % ex) return res @@ -634,16 +632,6 @@ def bottom_up_scan(ex): bmp = PurePoly(minpoly_groebner(1/base, x, domain=domain), x) base, exp = update_mapping(1/base, bmp), -exp return update_mapping(ex, exp.q, -base**exp.p) - elif ex.is_AlgebraicNumber: - base = update_mapping(ex.root, ex.minpoly) - res = Integer(0) - for exp, coeff in ex.rep.terms(): - exp = Integer(exp[0]) - if exp: - res += coeff*update_mapping(base**exp, 1, -base**exp) - else: - res += coeff - return res elif isinstance(ex, RootOf) and ex.poly.domain.is_IntegerRing: return update_mapping(ex, ex.poly) diff --git a/diofant/polys/polyclasses.py b/diofant/polys/polyclasses.py index 741c40ad97..daab2827bc 100644 --- a/diofant/polys/polyclasses.py +++ b/diofant/polys/polyclasses.py @@ -9,10 +9,10 @@ dmp_rem, dmp_sqr, dmp_sub, dmp_sub_ground) from .densebasic import (dmp_convert, dmp_deflate, dmp_degree, dmp_degree_in, dmp_degree_list, dmp_eject, dmp_exclude, - dmp_from_dict, dmp_from_diofant, dmp_ground, - dmp_ground_LC, dmp_ground_nth, dmp_ground_p, - dmp_ground_TC, dmp_inject, dmp_list_terms, dmp_one_p, - dmp_permute, dmp_slice_in, dmp_terms_gcd, dmp_to_dict, + dmp_from_dict, dmp_ground, dmp_ground_LC, + dmp_ground_nth, dmp_ground_p, dmp_ground_TC, + dmp_inject, dmp_list_terms, dmp_one_p, dmp_permute, + dmp_slice_in, dmp_terms_gcd, dmp_to_dict, dmp_to_tuple, dmp_validate, dmp_zero_p) from .densetools import (dmp_clear_denoms, dmp_compose, dmp_diff_in, dmp_eval_in, dmp_ground_content, dmp_ground_monic, @@ -104,11 +104,6 @@ def from_list(cls, rep, lev, dom): """Create an instance of ``cls`` given a list of native coefficients. """ return cls(dmp_convert(rep, lev, None, dom), dom, lev) - @classmethod - def from_diofant_list(cls, rep, lev, dom): - """Create an instance of ``cls`` given a list of Diofant coefficients. """ - return cls(dmp_from_diofant(rep, lev, dom), dom, lev) - def to_dict(self, zero=False): """Convert ``self`` to a dict representation with native coefficients. """ return dmp_to_dict(self.rep, self.lev, self.domain, zero=zero) diff --git a/diofant/polys/tests/test_numberfields.py b/diofant/polys/tests/test_numberfields.py index 4073b34c78..705aa3cbaa 100644 --- a/diofant/polys/tests/test_numberfields.py +++ b/diofant/polys/tests/test_numberfields.py @@ -2,16 +2,14 @@ import pytest -from diofant import (Add, GoldenRatio, I, Integer, Mul, Poly, PurePoly, - Rational, Tuple, cbrt, cos, exp, exp_polar, expand, - expand_multinomial, nsimplify, oo, pi, root, sin, solve, - sqrt) +from diofant import (Add, GoldenRatio, I, Integer, PurePoly, Rational, cbrt, + cos, exp, exp_polar, expand, expand_multinomial, + nsimplify, oo, pi, root, sin, solve, sqrt) from diofant.abc import x, y, z from diofant.domains import QQ -from diofant.polys.numberfields import (AlgebraicNumber, field_isomorphism, +from diofant.polys.numberfields import (field_isomorphism, is_isomorphism_possible, minimal_polynomial, primitive_element) -from diofant.polys.polyclasses import DMP from diofant.polys.polyerrors import CoercionFailed, NotAlgebraic from diofant.polys.polytools import degree from diofant.polys.rootoftools import RootOf @@ -81,10 +79,9 @@ def test_minimal_polynomial(): assert minimal_polynomial(sqrt(2)) == PurePoly(x**2 - 2) assert minimal_polynomial(sqrt(2), method='groebner') == PurePoly(x**2 - 2) - a = AlgebraicNumber(sqrt(2)) - b = AlgebraicNumber(sqrt(3)) + a = sqrt(2) + b = sqrt(3) - assert minimal_polynomial(a)(x) == x**2 - 2 assert minimal_polynomial(b)(x) == x**2 - 3 assert minimal_polynomial(a) == PurePoly(x**2 - 2) @@ -96,15 +93,18 @@ def test_minimal_polynomial(): assert minimal_polynomial(sqrt(b/2 + 17))(x) == 4*x**4 - 136*x**2 + 1153 # issue diofant/diofant#431 - theta = AlgebraicNumber(sqrt(2), (Rational(1, 2), 17)) + K = QQ.algebraic_field(sqrt(2)) + theta = K.to_expr(K([Rational(1, 2), 17])) assert minimal_polynomial(theta)(x) == 2*x**2 - 68*x + 577 - theta = AlgebraicNumber(RootOf(x**7 + x - 1, 3), (1, 2, 0, 0, 1)) + K = QQ.algebraic_field(RootOf(x**7 + x - 1, 3)) + theta = K.to_expr(K([1, 2, 0, 0, 1])) ans = minimal_polynomial(theta)(x) assert ans == (x**7 - 7*x**6 + 19*x**5 - 27*x**4 + 63*x**3 - 115*x**2 + 82*x - 147) - assert minimal_polynomial(theta.as_expr(), method='groebner')(x) == ans - theta = AlgebraicNumber(RootOf(x**5 + 5*x - 1, 2), (1, -1, 1)) + assert minimal_polynomial(theta, method='groebner')(x) == ans + K = QQ.algebraic_field(RootOf(x**5 + 5*x - 1, 2)) + theta = K.to_expr(K([1, -1, 1])) ans = (x**30 - 15*x**28 - 10*x**27 + 135*x**26 + 330*x**25 - 705*x**24 - 150*x**23 + 3165*x**22 - 6850*x**21 + 7182*x**20 + 3900*x**19 + 4435*x**18 + 11970*x**17 - 259725*x**16 - 18002*x**15 + @@ -113,11 +113,10 @@ def test_minimal_polynomial(): 5302000*x**6 - 2405376*x**5 + 1016640*x**4 - 804480*x**3 + 257280*x**2 - 53760*x + 1280) assert minimal_polynomial(sqrt(theta) + root(theta, 3))(x) == ans - theta = sqrt(1 + 1/(AlgebraicNumber(RootOf(x**3 + 4*x - 15, 1), - (1, 0, 1)) + - 1/(sqrt(3) + - AlgebraicNumber(RootOf(x**3 - x + 1, 0), - (1, 2, -1))))) + K1 = QQ.algebraic_field(RootOf(x**3 + 4*x - 15, 1)) + K2 = QQ.algebraic_field(RootOf(x**3 - x + 1, 0)) + theta = sqrt(1 + 1/(K1.to_expr(K([1, 0, 1])) + + 1/(sqrt(3) + K2.to_expr(K2([1, 2, -1]))))) ans = (2262264837876687263*x**36 - 38939909597855051866*x**34 + 315720420314462950715*x**32 - 1601958657418182606114*x**30 + 5699493671077371036494*x**28 - 15096777696140985506150*x**26 + @@ -130,17 +129,16 @@ def test_minimal_polynomial(): 551322649782053543) assert minimal_polynomial(theta)(x) == ans - a, b = sqrt(2)/3 + 7, AlgebraicNumber(sqrt(2)/3 + 7) - + a = sqrt(2)/3 + 7 f = 81*x**8 - 2268*x**6 - 4536*x**5 + 22644*x**4 + 63216*x**3 - \ 31608*x**2 - 189648*x + 141358 assert minimal_polynomial(sqrt(a) + sqrt(sqrt(a)))(x) == f - assert minimal_polynomial(sqrt(b) + sqrt(sqrt(b)))(x) == f assert minimal_polynomial(a**Rational(3, 2))(x) == 729*x**4 - 506898*x**2 + 84604519 - a = AlgebraicNumber(RootOf(x**3 + x - 1, 0)) + K = QQ.algebraic_field(RootOf(x**3 + x - 1, 0)) + a = K.to_expr(K([1, 0])) assert minimal_polynomial(1/a**2)(x) == x**3 - x**2 - 2*x - 1 # issue sympy/sympy#5994 @@ -534,217 +532,19 @@ def test_to_number_field(): B = A.algebraic_field(sqrt(3)) assert B.convert(sqrt(2) + sqrt(3)) == B([1, 0]) - a = AlgebraicNumber(sqrt(2) + sqrt(3), [Rational(1, 2), Integer(0), -Rational(9, 2), Integer(0)]) + K = QQ.algebraic_field(sqrt(2) + sqrt(3)) + a = K([Rational(1, 2), Integer(0), -Rational(9, 2), Integer(0)]) - assert B.convert(sqrt(2)) == B(a.coeffs()) + assert B.from_expr(sqrt(2)) == a pytest.raises(CoercionFailed, lambda: QQ.algebraic_field(sqrt(3)).convert(sqrt(2))) - # issue sympy/sympy#5649 - assert AlgebraicNumber(1).rep.rep == QQ.algebraic_field(1).convert(1).rep - assert AlgebraicNumber(sqrt(2)).rep.rep == A.convert(sqrt(2)).rep - p = x**6 - 6*x**4 - 6*x**3 + 12*x**2 - 36*x + 1 r0, r1 = p.as_poly(x).all_roots()[:2] - a = AlgebraicNumber(r0, [Rational(-96, 755), Rational(-54, 755), - Rational(128, 151), Rational(936, 755), - Rational(-1003, 755), Rational(2184, 755)]) A = QQ.algebraic_field(r0) - assert A.convert(r1) == A(a.coeffs()) - - -def test_AlgebraicNumber(): - minpoly, root = x**2 - 2, sqrt(2) - - a = AlgebraicNumber(root, gen=x) - - assert a.rep == DMP([QQ(1), QQ(0)], QQ) - assert a.root == root - assert a.minpoly == minpoly - assert a.is_number - - assert a.coeffs() == [Integer(1), Integer(0)] - assert a.native_coeffs() == [QQ(1), QQ(0)] - - a = AlgebraicNumber(root, gen=x) - - assert a.rep == DMP([QQ(1), QQ(0)], QQ) - assert a.root == root - assert a.minpoly == minpoly - assert a.is_number - - a = AlgebraicNumber(root, gen=x) - - assert a.rep == DMP([QQ(1), QQ(0)], QQ) - assert a.root == root - assert a.minpoly == minpoly - assert a.is_number - - assert AlgebraicNumber(sqrt(2), []).rep == DMP([], QQ) - - assert AlgebraicNumber(sqrt(2), [8]).rep == DMP([QQ(8)], QQ) - assert AlgebraicNumber(sqrt(2), [Rational(8, 3)]).rep == DMP([QQ(8, 3)], QQ) - - assert AlgebraicNumber(sqrt(2), [7, 3]).rep == DMP([QQ(7), QQ(3)], QQ) - assert AlgebraicNumber( - sqrt(2), [Rational(7, 9), Rational(3, 2)]).rep == DMP([QQ(7, 9), QQ(3, 2)], QQ) - - assert AlgebraicNumber(sqrt(2), [1, 2, 3]).rep == DMP([QQ(2), QQ(5)], QQ) - - a = AlgebraicNumber(AlgebraicNumber(root, gen=x), [1, 2]) - - assert a.rep == DMP([QQ(1), QQ(2)], QQ) - assert a.root == root - assert a.minpoly == minpoly - assert a.is_number - - assert a.coeffs() == [Integer(1), Integer(2)] - assert a.native_coeffs() == [QQ(1), QQ(2)] - - a = AlgebraicNumber((minpoly, root), [1, 2]) - - assert a.rep == DMP([QQ(1), QQ(2)], QQ) - assert a.root == root - assert a.minpoly == minpoly - assert a.is_number - - a = AlgebraicNumber((Poly(minpoly), root), [1, 2]) - - assert a.rep == DMP([QQ(1), QQ(2)], QQ) - assert a.root == root - assert a.minpoly == minpoly - assert a.is_number - - assert AlgebraicNumber( sqrt(3)).rep == DMP([ QQ(1), QQ(0)], QQ) - assert AlgebraicNumber(-sqrt(3)).rep == DMP([ QQ(1), QQ(0)], QQ) - - a = AlgebraicNumber(sqrt(2)) - b = AlgebraicNumber(sqrt(2)) - - assert a == b - - c = AlgebraicNumber(sqrt(2), gen=x) - - assert a == b - assert a == c - - a = AlgebraicNumber(sqrt(2), [1, 2]) - b = AlgebraicNumber(sqrt(2), [1, 3]) - - assert a != b and a != sqrt(2) + 3 - - assert (a == x) is False and (a != x) is True - - a = AlgebraicNumber(sqrt(2), [1, 0]) - - assert a.as_poly(x) == Poly(x) - - assert a.as_expr() == sqrt(2) - assert a.as_expr(x) == x - - a = AlgebraicNumber(sqrt(2), [2, 3]) - - p = a.as_poly() - - assert p == Poly(2*p.gen + 3) - - assert a.as_poly(x) == Poly(2*x + 3) - - assert a.as_expr() == 2*sqrt(2) + 3 - assert a.as_expr(x) == 2*x + 3 - - A = QQ.algebraic_field(AlgebraicNumber(sqrt(2))) - a = A([1, 0]) - b = A.convert(sqrt(2)) - assert a == b - - a = AlgebraicNumber(sqrt(2), [1, 2, 3]) - assert a.args == (sqrt(2), Tuple(2, 5)) - - pytest.raises(ValueError, lambda: AlgebraicNumber(RootOf(x**3 + y*x + 1, - x, 0))) - - a = AlgebraicNumber(RootOf(x**3 + 2*x - 1, 1)) - assert a.free_symbols == set() - - # integer powers: - assert a**0 == 1 - assert a**2 == AlgebraicNumber(a, (1, 0, 0)) - assert a**5 == AlgebraicNumber(a, (1, 0, 0, 0, 0, 0)) - assert a**110 == AlgebraicNumber(a, ([1] + [0]*110)) - assert (a**pi).is_Pow - - b = AlgebraicNumber(sqrt(3)) - assert b + 1 == AlgebraicNumber(sqrt(3), (1, 1)) - assert (b + 1) + b == AlgebraicNumber(sqrt(3), (2, 1)) - - assert (2*b + 1)**3 == 30*b + 37 - assert 1/b == b/3 - - b = AlgebraicNumber(RootOf(x**7 - x + 1, 1), (1, 2, -1)) - t = AlgebraicNumber(b.root) - assert b**7 == 490*t**6 - 119*t**5 - 196*t**4 - 203*t**3 - 265*t**2 + 637*t - 198 - - b = AlgebraicNumber(sqrt(2), (1, 0)) - c = b + 1 - assert c**2 == 2*b + 3 - assert c**5 == 29*b + 41 - assert c**-2 == 3 - 2*b - assert c**-11 == 5741*b - 8119 - - # arithmetics - assert a**3 == -2*a + 1 == a*(-2) + 1 == 1 + (-2)*a == 1 - 2*a - assert a**5 == a**2 + 4*a - 2 - assert a**4 == -2*a**2 + a == a - 2*a**2 - assert a**110 == (-2489094528619081871*a**2 + 3737645722703173544*a - - 1182958048412500088) - - assert a + a == 2*a - assert 2*a - a == a - assert Integer(1) - a == (-a) + 1 - - assert (a + pi).is_Add - assert (pi + a).is_Add - assert (a - pi).is_Add - assert (pi - a).is_Add - assert (a*pi).is_Mul - assert (pi*a).is_Mul - - a = AlgebraicNumber(sqrt(2), (5, 7)) - b = AlgebraicNumber(sqrt(2), (-4, -6)) - assert a*b == AlgebraicNumber(sqrt(2), (-58, -82)) - - # different extensions - a = AlgebraicNumber(sqrt(2)) - b = AlgebraicNumber(sqrt(3)) - assert a + b == Add(a, +b, evaluate=False) - assert a * b == Mul(a, +b, evaluate=False) - assert a - b == Add(a, -b, evaluate=False) - - -def test_to_algebraic_integer(): - a = AlgebraicNumber(sqrt(3), gen=x).to_algebraic_integer() - - assert a.minpoly == x**2 - 3 - assert a.root == sqrt(3) - assert a.rep == DMP([QQ(1), QQ(0)], QQ) - - a = AlgebraicNumber(2*sqrt(3), gen=x).to_algebraic_integer() - assert a.minpoly == x**2 - 12 - assert a.root == 2*sqrt(3) - assert a.rep == DMP([QQ(1), QQ(0)], QQ) - - a = AlgebraicNumber(sqrt(3)/2, gen=x).to_algebraic_integer() - - assert a.minpoly == x**2 - 12 - assert a.root == 2*sqrt(3) - assert a.rep == DMP([QQ(1), QQ(0)], QQ) - - a = AlgebraicNumber(sqrt(3)/2, [Rational(7, 19), 3], gen=x).to_algebraic_integer() - - assert a.minpoly == x**2 - 12 - assert a.root == 2*sqrt(3) - assert a.rep == DMP([QQ(7, 19), QQ(3)], QQ) + a = A([Rational(-96, 755), Rational(-54, 755), Rational(128, 151), Rational(936, 755), + Rational(-1003, 755), Rational(2184, 755)]) + assert A.from_expr(r1) == a def test_minpoly_fraction_field(): diff --git a/diofant/printing/mathematica.py b/diofant/printing/mathematica.py index 071c741638..a92518267f 100644 --- a/diofant/printing/mathematica.py +++ b/diofant/printing/mathematica.py @@ -186,9 +186,9 @@ def _print_RootSum(self, expr): return "RootSum[%s, %s]" % (self.doprint(Lambda(p.gens, p.as_expr())), self.doprint(f)) - def _print_AlgebraicNumber(self, expr): - coeffs = list(reversed(expr.coeffs())) - return "AlgebraicNumber[%s, %s]" % (self.doprint(expr.root), + def _print_AlgebraicElement(self, expr): + coeffs = list(reversed(expr.rep)) + return "AlgebraicNumber[%s, %s]" % (self.doprint(expr.parent.ext), self.doprint(coeffs)) def _print_Dummy(self, expr): diff --git a/diofant/printing/pretty/pretty.py b/diofant/printing/pretty/pretty.py index 0471dfb91e..d929958232 100644 --- a/diofant/printing/pretty/pretty.py +++ b/diofant/printing/pretty/pretty.py @@ -1158,11 +1158,6 @@ def pretty_negative(pform, index): elif term.is_Number and term < 0: pform = self._print(-term) pforms.append(pretty_negative(pform, i)) - elif term.is_AlgebraicNumber and term.coeffs()[0] < 0: - new_coeffs = term.coeffs() - new_coeffs[0] = -new_coeffs[0] - pform = self._print(term.func(term.root, new_coeffs)) - pforms.append(pretty_negative(pform, i)) elif term.is_Relational: pforms.append(prettyForm(*self._print(term).parens())) else: @@ -1498,8 +1493,8 @@ def _print_PolyElement(self, poly): def _print_FracElement(self, frac): return prettyForm(sstr(frac)) - def _print_AlgebraicNumber(self, expr): - return self._print(expr.as_expr()) + def _print_AlgebraicElement(self, expr): + return self._print(expr.parent.to_expr(expr)) def _print_RootOf(self, expr): args = [self._print_Add(expr.expr, order='lex')] diff --git a/diofant/printing/pretty/tests/test_pretty.py b/diofant/printing/pretty/tests/test_pretty.py index e94d410e32..a0e80280a8 100644 --- a/diofant/printing/pretty/tests/test_pretty.py +++ b/diofant/printing/pretty/tests/test_pretty.py @@ -4,16 +4,15 @@ import pytest -from diofant import (FF, QQ, RR, ZZ, Add, AlgebraicNumber, And, Basic, - Complement, Contains, Derivative, Dict, Eq, Equivalent, - EulerGamma, FiniteSet, Float, Function, Ge, GoldenRatio, - Gt, I, Implies, Integer, Integral, Intersection, Interval, - Lambda, Le, Limit, Lt, Matrix, MatrixSymbol, Mod, Mul, - Nand, Ne, Nor, Not, O, Or, Pow, Product, Range, Rational, - Ray, RealField, RootOf, RootSum, S, Segment, Subs, Sum, - Symbol, SymmetricDifference, Trace, Tuple, Union, Xor, - cbrt, conjugate, grlex, groebner, ilex, oo, pi, root, - symbols) +from diofant import (FF, QQ, RR, ZZ, Add, And, Basic, Complement, Contains, + Derivative, Dict, Eq, Equivalent, EulerGamma, FiniteSet, + Float, Function, Ge, GoldenRatio, Gt, I, Implies, Integer, + Integral, Intersection, Interval, Lambda, Le, Limit, Lt, + Matrix, MatrixSymbol, Mod, Mul, Nand, Ne, Nor, Not, O, Or, + Pow, Product, Range, Rational, Ray, RealField, RootOf, + RootSum, S, Segment, Subs, Sum, Symbol, + SymmetricDifference, Trace, Tuple, Union, Xor, cbrt, + conjugate, grlex, groebner, ilex, oo, pi, root, symbols) from diofant.abc import a, b, c, d, e, f, k, l, lamda, m, n, t, w, x, y, z from diofant.core.trace import Tr from diofant.diffgeom import BaseVectorField @@ -5017,8 +5016,9 @@ def test_MatrixElement(): assert upretty(Matrix([[X[0, 0], 1], [2, 3]])) == ucode_str -def test_AlgebraicNumber(): - a = AlgebraicNumber(sqrt(2), (1, 1)) +def test_AlgebraicElement(): + K = QQ.algebraic_field(sqrt(2)) + a = K([1, 1]) ucode_str = \ """\ ___\n\ @@ -5026,12 +5026,6 @@ def test_AlgebraicNumber(): """ assert upretty(a) == ucode_str - ucode_str = \ - """\ -x - 1 + ⅈ\ -""" - assert upretty(AlgebraicNumber(I, (-1, 1)) + x) == ucode_str - def test_sympyissue_11801(): assert pretty(Symbol("")) == "" diff --git a/diofant/printing/repr.py b/diofant/printing/repr.py index 1ba77d6c7b..bd00fe0aea 100644 --- a/diofant/printing/repr.py +++ b/diofant/printing/repr.py @@ -181,6 +181,10 @@ def _print_AlgebraicField(self, expr): return "AlgebraicField(%s, %s)" % (self._print(expr.domain), self._print(expr.ext.as_expr())) + def _print_AlgebraicElement(self, expr): + return "%s(%s)" % (self._print(expr.parent), + self._print(list(map(expr.domain.to_expr, expr.rep)))) + def srepr(expr, **settings): """return expr in repr form""" diff --git a/diofant/printing/str.py b/diofant/printing/str.py index 99d1356823..ba0920d8b4 100644 --- a/diofant/printing/str.py +++ b/diofant/printing/str.py @@ -431,8 +431,8 @@ def _print_Poly(self, expr): def _print_ProductSet(self, p): return ' x '.join(self._print(set) for set in p.sets) - def _print_AlgebraicNumber(self, expr): - return self._print(expr.as_expr()) + def _print_AlgebraicElement(self, expr): + return self._print(expr.parent.to_expr(expr)) def _print_Pow(self, expr, rational=False): PREC = precedence(expr) diff --git a/diofant/printing/tests/test_mathematica.py b/diofant/printing/tests/test_mathematica.py index 63713e7853..7a4e053e15 100644 --- a/diofant/printing/tests/test_mathematica.py +++ b/diofant/printing/tests/test_mathematica.py @@ -1,11 +1,12 @@ import pytest +from diofant import QQ from diofant import mathematica_code as mcode from diofant.abc import x, y, z from diofant.concrete import Sum -from diofant.core import (AlgebraicNumber, Catalan, Derivative, Dummy, E, Eq, - EulerGamma, Function, Gt, Integer, Lambda, Le, Ne, - Rational, Tuple, oo, pi, symbols) +from diofant.core import (Catalan, Derivative, Dummy, E, Eq, EulerGamma, + Function, Gt, Integer, Lambda, Le, Ne, Rational, + Tuple, oo, pi, symbols) from diofant.functions import (Max, Min, Piecewise, acos, asin, atan, atanh, binomial, cos, cosh, cot, coth, csch, erfc, exp, hyper, log, meijerg, sech, sign, sin, sinh, tan, @@ -194,9 +195,10 @@ def test_RootSum(): "Function[{y}, Log[y*z]]]") -def test_AlgebraicNumber(): +def test_AlgebraicElement(): r = RootOf(x**7 + 3*x - 1, 3) - a = AlgebraicNumber(r, (1, 2, 3, 0, 1)) + K = QQ.algebraic_field(r) + a = K([1, 2, 3, 0, 1]) assert mcode(a) == ('AlgebraicNumber[Root[#^7 + 3*# - 1 &, 4],' ' {1, 0, 3, 2, 1}]') diff --git a/diofant/printing/tests/test_repr.py b/diofant/printing/tests/test_repr.py index 5eba51c563..c3c58ed12d 100644 --- a/diofant/printing/tests/test_repr.py +++ b/diofant/printing/tests/test_repr.py @@ -1,9 +1,9 @@ import pytest -from diofant import (Abs, AlgebraicNumber, Catalan, Dummy, E, EulerGamma, - Float, Function, GoldenRatio, I, ImmutableMatrix, Integer, - Matrix, Rational, Symbol, Wild, WildFunction, false, nan, - ones, oo, pi, root, sin, sqrt, true, zoo) +from diofant import (Abs, Catalan, Dummy, E, EulerGamma, Float, Function, + GoldenRatio, I, ImmutableMatrix, Integer, Matrix, + Rational, Symbol, Wild, WildFunction, false, nan, ones, + oo, pi, root, sin, sqrt, true, zoo) from diofant.abc import x, y from diofant.domains import QQ, ZZ from diofant.geometry import Ellipse, Point @@ -108,11 +108,13 @@ def test_Rational(): sT(Rational(-1, 3), "Rational(-1, 3)") -def test_AlgebraicNumber(): - a = AlgebraicNumber(sqrt(2)) - sT(a, "AlgebraicNumber(Pow(Integer(2), Rational(1, 2)), Tuple(Integer(1), Integer(0)))") - a = AlgebraicNumber(root(-2, 3)) - sT(a, "AlgebraicNumber(Pow(Integer(-2), Rational(1, 3)), Tuple(Integer(1), Integer(0)))") +def test_AlgebraicElement(): + K = QQ.algebraic_field(sqrt(2)) + a = K.root + sT(a, "AlgebraicField(%s, Pow(Integer(2), Rational(1, 2)))([Integer(1), Integer(0)])" % repr(QQ)) + K = QQ.algebraic_field(root(-2, 3)) + a = K.root + sT(a, "AlgebraicField(%s, Pow(Integer(-2), Rational(1, 3)))([Integer(1), Integer(0)])" % repr(QQ)) def test_Float(): diff --git a/diofant/printing/tests/test_str.py b/diofant/printing/tests/test_str.py index eaf0fa127e..84e055c7a6 100644 --- a/diofant/printing/tests/test_str.py +++ b/diofant/printing/tests/test_str.py @@ -1,10 +1,10 @@ import pytest -from diofant import (Abs, Add, AlgebraicNumber, And, Catalan, Complement, - Derivative, Dict, Dummy, E, Equivalent, EulerGamma, - FiniteSet, Float, Function, GoldenRatio, I, Integer, - Integral, Interval, Lambda, Limit, Matrix, MatrixSymbol, - Mul, O, Pow, Rational, Rel, S, SparseMatrix, Sum, Symbol, +from diofant import (Abs, Add, And, Catalan, Complement, Derivative, Dict, + Dummy, E, Equivalent, EulerGamma, FiniteSet, Float, + Function, GoldenRatio, I, Integer, Integral, Interval, + Lambda, Limit, Matrix, MatrixSymbol, Mul, O, Pow, + Rational, Rel, S, SparseMatrix, Sum, Symbol, SymmetricDifference, Tuple, Wild, WildFunction, Xor, cbrt, cos, exp, factor, factorial, factorial2, false, nan, oo, pi, root, sin, sqrt, subfactorial, summation, symbols, @@ -719,5 +719,6 @@ def test_SymmetricDifference(): 'SymmetricDifference([2, 3], [3, 4])' -def test_AlgebraicNumber(): - assert str(AlgebraicNumber(sqrt(2))) == 'sqrt(2)' +def test_AlgebraicElement(): + K = QQ.algebraic_field(sqrt(2)) + assert str(K([1, 0])) == 'sqrt(2)' diff --git a/diofant/simplify/tests/test_simplify.py b/diofant/simplify/tests/test_simplify.py index 4f74f9b34b..b4675d7676 100644 --- a/diofant/simplify/tests/test_simplify.py +++ b/diofant/simplify/tests/test_simplify.py @@ -698,3 +698,9 @@ def test_sympyissue_13115(): assert Mqs.subs({q_1: 0, q_2: 0, q_3: 0}) == Matrix([[2.5, 0, 0], [0, 2.5, 0.75], [0, 0.75, 0.25]]) + + +@pytest.mark.xfail +def test_simplify_algebraic_numbers(): + e = (3 + 4*I)**Rational(3, 2) + assert simplify(e) == 2 + 11*I # issue sympy/sympy#4401 diff --git a/diofant/tests/test_wester.py b/diofant/tests/test_wester.py index 07cc900904..b988e8470f 100644 --- a/diofant/tests/test_wester.py +++ b/diofant/tests/test_wester.py @@ -11,13 +11,12 @@ import pytest from mpmath import mpc, mpi -from diofant import (ZZ, AlgebraicNumber, And, Complement, Derivative, - DiracDelta, E, EulerGamma, FiniteSet, Function, - GoldenRatio, I, Lambda, LambertW, Le, Lt, Max, Mul, N, O, - Or, Piecewise, Poly, Rational, Subs, Symbol, acos, acot, - apart, asin, asinh, assoc_legendre, atan, bernoulli, - besselj, binomial, cbrt, ceiling, chebyshevt, combsimp, - conjugate) +from diofant import (ZZ, And, Complement, Derivative, DiracDelta, E, + EulerGamma, FiniteSet, Function, GoldenRatio, I, Lambda, + LambertW, Le, Lt, Max, Mul, N, O, Or, Piecewise, Poly, + Rational, Subs, Symbol, acos, acot, apart, asin, asinh, + assoc_legendre, atan, bernoulli, besselj, binomial, cbrt, + ceiling, chebyshevt, combsimp, conjugate) from diofant import continued_fraction_convergents as cf_c from diofant import continued_fraction_iterator as cf_i from diofant import continued_fraction_periodic as cf_p @@ -184,18 +183,19 @@ def test_C18(): @pytest.mark.xfail def test_C19(): - assert radsimp(simplify((90 + 34*sqrt(7)) ** R(1, 3))) == 3 + sqrt(7) + assert simplify(root(90 + 34*sqrt(7), 3)) == 3 + sqrt(7) +@pytest.mark.xfail def test_C20(): - inside = (135 + 78*sqrt(3)) - test = AlgebraicNumber((inside**R(2, 3) + 3) * sqrt(3) / inside**R(1, 3)) - assert simplify(test) == AlgebraicNumber(12) + inside = 135 + 78*sqrt(3) + test = (inside**Rational(2, 3) + 3)*sqrt(3)/root(inside, 3) + assert simplify(test) == 12 +@pytest.mark.xfail def test_C21(): - assert simplify(AlgebraicNumber((41 + 29*sqrt(2)) ** R(1, 5))) == \ - AlgebraicNumber(1 + sqrt(2)) + assert simplify(root(41 + 29*sqrt(2), 5)) == 1 + sqrt(2) @pytest.mark.xfail diff --git a/diofant/utilities/tests/test_pickling.py b/diofant/utilities/tests/test_pickling.py index f2dcfb6d34..fc4e83e196 100644 --- a/diofant/utilities/tests/test_pickling.py +++ b/diofant/utilities/tests/test_pickling.py @@ -39,8 +39,7 @@ erf, exp, factorial, ff, fibonacci, floor, gamma, harmonic, hermite, im, legendre, ln, log, loggamma, lowergamma, lucas, polygamma, re, rf, - sign, sin, sinh, sqrt, tan, tanh, uppergamma, - zeta) + sign, sin, sinh, tan, tanh, uppergamma, zeta) from diofant.geometry.ellipse import Circle, Ellipse from diofant.geometry.entity import GeometryEntity from diofant.geometry.line import Line, LinearEntity, Ray, Segment @@ -52,7 +51,6 @@ from diofant.plotting.plot import Plot from diofant.polys.fields import FractionField from diofant.polys.monomials import Monomial -from diofant.polys.numberfields import AlgebraicNumber from diofant.polys.orderings import (GradedLexOrder, InverseOrder, LexOrder, ProductOrder, ReversedGradedLexOrder) from diofant.polys.polyclasses import DMP @@ -390,11 +388,6 @@ def test_pickling_polys_domains(): check(c) -def test_pickling_polys_numberfields(): - for c in (AlgebraicNumber, AlgebraicNumber(sqrt(3))): - check(c) - - def first_two(m): return m[:2] diff --git a/docs/modules/core.rst b/docs/modules/core.rst index e2bd99a3ca..8fa54c5570 100644 --- a/docs/modules/core.rst +++ b/docs/modules/core.rst @@ -108,11 +108,6 @@ Integer .. autoclass:: Integer :members: -AlgebraicNumber -^^^^^^^^^^^^^^^ -.. autoclass:: AlgebraicNumber - :members: - NumberSymbol ^^^^^^^^^^^^ .. autoclass:: NumberSymbol diff --git a/docs/release/notes-0.10.rst b/docs/release/notes-0.10.rst index 36e578b6af..b8e851f616 100644 --- a/docs/release/notes-0.10.rst +++ b/docs/release/notes-0.10.rst @@ -7,10 +7,11 @@ Not Released Yet New features ============ +* New representation for elements of :class:`~diofant.domains.AlgebraicField`, see :pull:`619` and :pull:`631`. + Major changes ============= -* New representation for elements of :class:`~diofant.domains.AlgebraicField`, see :pull:`619`. * Stable enumeration of polynomial roots in :class:`~diofant.polys.rootoftools.RootOf`, see :pull:`633`. Compatibility breaks @@ -24,7 +25,6 @@ Compatibility breaks * Removed ``PolyRing`` class, see :pull:`621`. * ``get_ring()`` method for domains, derived from :class:`~diofant.domains.ring.Ring`, now is a property, e.g. :attr:`~diofant.domains.ring.Ring.ring`, see :pull:`621`. * Removed ``compose`` option for :func:`~diofant.polys.numberfields.minimal_polynomial`, use ``method`` instead, see :pull:`624`. -* Removed ``alias`` option for :class:`~diofant.core.numbers.AlgebraicNumber`, see :pull:`626`. * :func:`~diofant.polys.numberfields.field_isomorphism` take fields as arguments, see :pull:`627`. * Functions :func:`~diofant.polys.numberfields.minimal_polynomial` and :func:`~diofant.polys.numberfields.primitive_element` return :class:`~diofant.polys.polytools.PurePoly` instances, see :pull:`628`. * Removed ``ANP`` class, see :pull:`619`. @@ -37,6 +37,7 @@ Compatibility breaks * ``from_()`` methods of :class:`~diofant.domains.domain.Domain` now are private, see :pull:`637`. * Method :meth:`~diofant.domains.domain.Domain.from_expr` was renamed from ``from_diofant()``, see :pull:`637`. * Method :meth:`~diofant.domains.domain.Domain.to_expr` was renamed from ``to_diofant()``, see :pull:`637`. +* Removed ``AlgebraicNumber`` class, see :pull:`631`. Minor changes ============= diff --git a/docs/release/notes-0.9.rst b/docs/release/notes-0.9.rst index baf99ad1bf..b3b1b2779d 100644 --- a/docs/release/notes-0.9.rst +++ b/docs/release/notes-0.9.rst @@ -77,8 +77,8 @@ Minor changes * Added support for limits of relational expressions, see :pull:`414`. * Make :class:`~diofant.matrices.expressions.MatrixSymbol` truly atomic, see :pull:`415`. * Support rewriting :class:`~diofant.functions.elementary.miscellaneous.Min` and :class:`~diofant.functions.elementary.miscellaneous.Max` as :class:`~diofant.functions.elementary.piecewise.Piecewise`, see :pull:`426`. -* :func:`~diofant.polys.numberfields.minimal_polynomial` fixed to support generic :class:`~diofant.core.numbers.AlgebraicNumber`'s, see :pull:`433` and :pull:`438`. -* :class:`~diofant.core.numbers.AlgebraicNumber` now support arithmetic operations, see :pull:`428` and :pull:`485`. +* :func:`~diofant.polys.numberfields.minimal_polynomial` fixed to support generic ``AlgebraicNumber``'s, see :pull:`433` and :pull:`438`. +* ``AlgebraicNumber`` now support arithmetic operations, see :pull:`428` and :pull:`485`. * Support rewrite :class:`~diofant.polys.rootoftools.RootOf` via radicals, see :pull:`563`. * Export set singletons, see :pull:`577`. * Correct implementation of the trial method (uses Gröbner bases) in :func:`~diofant.polys.numberfields.primitive_element`, see :pull:`608` and :pull:`609`.