diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py index b99d5d7857e..0c360f8acab 100644 --- a/src/sage/calculus/test_sympy.py +++ b/src/sage/calculus/test_sympy.py @@ -156,7 +156,7 @@ sage: t1, t2 (omega + x, omega + x) - sage: e = sympy.sin(var("y"))+sage.all.cos(sympy.Symbol("x")) + sage: e = sympy.sin(var("y")) + sage.functions.trig.cos(sympy.Symbol("x")) sage: type(e) sage: e @@ -166,7 +166,7 @@ sage: e cos(x) + sin(y) - sage: e = sage.all.cos(var("y")**3)**4+var("x")**2 + sage: e = sage.functions.trig.cos(var("y")**3)**4+var("x")**2 sage: e = e._sympy_() sage: e x**2 + cos(y**3)**4 diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx index 0a1439b7530..962b743b0c8 100644 --- a/src/sage/ext/fast_callable.pyx +++ b/src/sage/ext/fast_callable.pyx @@ -576,7 +576,8 @@ def function_name(fn): Given a function, return a string giving a name for the function. For functions we recognize, we use our standard opcode name for the - function (so operator.add becomes 'add', and sage.all.sin becomes 'sin'). + function (so :func:`operator.add` becomes ``'add'``, and :func:`sage.functions.trig.sin` + becomes ``'sin'``). For functions we don't recognize, we try to come up with a name, but the name will be wrapped in braces; this is a signal that diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 5e7f23af8d4..9ef099fa93e 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -117,10 +117,12 @@ from copy import copy +from sage.arith.misc import integer_ceil, integer_floor, xlcm +from sage.arith.srange import xsrange +from sage.misc.functional import log from sage.misc.misc_c import prod import sage.rings.integer_ring as integer_ring import sage.rings.integer -from sage.arith.srange import xsrange # # Lists of names (as strings) which the user may use to identify one @@ -1396,8 +1398,7 @@ def order_from_bounds(P, bounds, d=None, operation='+', if d > 1: Q = multiple(P, d, operation=operation) lb, ub = bounds - bounds = (sage.arith.all.integer_ceil(lb / d), - sage.arith.all.integer_floor(ub / d)) + bounds = (integer_ceil(lb / d), integer_floor(ub / d)) # Use generic bsgs to find n=d*m with lb<=n<=ub and n*P=0 @@ -1486,7 +1487,7 @@ def merge_points(P1, P2, operation='+', if n2.divides(n1): return (g1, n1) - m, k1, k2 = sage.arith.all.xlcm(n1, n2) + m, k1, k2 = xlcm(n1, n2) m1 = n1 // k1 m2 = n2 // k2 g1 = multiple(g1, m1, operation=operation) diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py index 47ff7c34796..bab9b856ae1 100644 --- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py +++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py @@ -117,7 +117,6 @@ def __init__(self, parent, M, check=True, **kwargs): EXAMPLES:: - sage: sage: from sage.modular.modform_hecketriangle.hecke_triangle_groups import HeckeTriangleGroup, HeckeTriangleGroupElement sage: lam = PolynomialRing(ZZ, 'lam').gen() sage: M = matrix([[-1, 0], [-lam^4 + 5*lam^2 + lam - 5, -1]]) diff --git a/src/sage/rings/bernoulli_mod_p.pyx b/src/sage/rings/bernoulli_mod_p.pyx index e9bf4fbf358..ee73d6ad209 100644 --- a/src/sage/rings/bernoulli_mod_p.pyx +++ b/src/sage/rings/bernoulli_mod_p.pyx @@ -23,6 +23,8 @@ AUTHOR: # https://www.gnu.org/licenses/ # **************************************************************************** +from sage.arith.misc import is_prime, primitive_root + cimport sage.rings.fast_arith import sage.rings.fast_arith cdef sage.rings.fast_arith.arith_int arith_int @@ -135,12 +137,12 @@ def bernoulli_mod_p(int p): if p <= 2: raise ValueError("p (=%s) must be a prime >= 3" % p) - if not sage.arith.all.is_prime(p): + if not is_prime(p): raise ValueError("p (=%s) must be a prime" % p) cdef int g, gSqr, gInv, gInvSqr, isOdd - g = sage.arith.all.primitive_root(p) + g = primitive_root(p) gInv = arith_int.c_inverse_mod_int(g, p) gSqr = (( g) * g) % p gInvSqr = (( gInv) * gInv) % p @@ -303,7 +305,7 @@ def bernoulli_mod_p_single(long p, long k): if p <= 2: raise ValueError("p (=%s) must be a prime >= 3" % p) - if not sage.arith.all.is_prime(p): + if not is_prime(p): raise ValueError("p (=%s) must be a prime" % p) cdef long x = bernmm_bern_modp(p, k) diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index e804964f501..4b9e7f2aefa 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -290,7 +290,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): Exact and nearly exact points are still visible:: - sage: # needs sage.plot + sage: # needs sage.plot sage.symbolic sage: plot(CIF(pi, 1), color='red') + plot(CIF(1, e), color='purple') + plot(CIF(-1, -1)) Graphics object consisting of 6 graphics primitives diff --git a/src/sage/rings/continued_fraction.py b/src/sage/rings/continued_fraction.py index a813816ac50..0021dc2745d 100644 --- a/src/sage/rings/continued_fraction.py +++ b/src/sage/rings/continued_fraction.py @@ -208,12 +208,20 @@ import numbers import sage.rings.abc + +from sage.misc.lazy_import import lazy_import from sage.rings.infinity import Infinity from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ from sage.structure.richcmp import rich_to_bool, richcmp_method from sage.structure.sage_object import SageObject +lazy_import('sage.combinat.words.abstract_word', 'Word_class') +lazy_import('sage.combinat.words.finite_word', 'FiniteWord_class') +lazy_import('sage.combinat.words.infinite_word', 'InfiniteWord_class') +lazy_import('sage.combinat.words.word', 'Word') + + ZZ_0 = Integer(0) ZZ_1 = Integer(1) ZZ_m1 = Integer(-1) @@ -2490,7 +2498,10 @@ def continued_fraction_list(x, type="std", partial_convergents=False, cf = None - from sage.rings.real_mpfr import RealLiteral + try: + from sage.rings.real_mpfr import RealLiteral + except ImportError: + RealLiteral = () if isinstance(x, RealLiteral): from sage.rings.real_mpfi import RealIntervalField x = RealIntervalField(x.prec())(x) @@ -2661,7 +2672,6 @@ def continued_fraction(x, value=None): pass # input for finite or ultimately periodic partial quotient expansion - from sage.combinat.words.finite_word import FiniteWord_class if isinstance(x, FiniteWord_class): x = list(x) @@ -2675,12 +2685,10 @@ def continued_fraction(x, value=None): return ContinuedFraction_periodic(x1, x2) # input for infinite partial quotient expansion - from sage.combinat.words.infinite_word import InfiniteWord_class from sage.misc.lazy_list import lazy_list_generic if isinstance(x, (lazy_list_generic, InfiniteWord_class)): return ContinuedFraction_infinite(x, value) - from sage.combinat.words.abstract_word import Word_class if isinstance(x, Word_class): raise ValueError("word with unknown length cannot be converted " "to continued fractions") diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx index 8af0867a9f5..ab029287ba6 100755 --- a/src/sage/rings/finite_rings/element_base.pyx +++ b/src/sage/rings/finite_rings/element_base.pyx @@ -586,8 +586,8 @@ cdef class FinitePolyExtElement(FiniteRingElement): Finite Field in a of size 19^2 sage: b = a**20 sage: p = FinitePolyExtElement.charpoly(b, "x", algorithm="pari") - sage: q = FinitePolyExtElement.charpoly(b, "x", algorithm="matrix") # needs sage.modules - sage: q == p # needs sage.modules + sage: q = FinitePolyExtElement.charpoly(b, "x", algorithm="matrix") # needs sage.modules + sage: q == p # needs sage.modules True sage: p x^2 + 15*x + 4 diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx index 7619ec7185f..a114fa9830d 100644 --- a/src/sage/rings/finite_rings/element_givaro.pyx +++ b/src/sage/rings/finite_rings/element_givaro.pyx @@ -56,10 +56,11 @@ from cysignals.signals cimport sig_on, sig_off from cypari2.paridecl cimport * +import sage.arith.misc + from sage.misc.randstate cimport current_randstate from sage.rings.finite_rings.element_pari_ffelt cimport FiniteFieldElement_pari_ffelt from sage.structure.richcmp cimport richcmp -import sage.arith.all from cypari2.gen cimport Gen from cypari2.stack cimport clear_stack @@ -414,9 +415,6 @@ cdef class Cache_givaro(Cache_base): # Reduce to pari e = e.__pari__() - elif isinstance(e, sage.libs.gap.element.GapElement_FiniteField): - return e.sage(ring=self.parent) - elif isinstance(e, GapElement): from sage.libs.gap.libgap import libgap return libgap(e).sage(ring=self.parent) @@ -434,6 +432,13 @@ cdef class Cache_givaro(Cache_base): return ret else: + try: + from sage.libs.gap.element import GapElement_FiniteField + except ImportError: + pass + else: + if isinstance(e, GapElement_FiniteField): + return e.sage(ring=self.parent) raise TypeError("unable to coerce %r" % type(e)) cdef GEN t @@ -1568,7 +1573,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): raise ArithmeticError("Multiplicative order of 0 not defined.") n = (self._cache).order_c() - 1 order = Integer(1) - for p, e in sage.arith.all.factor(n): + for p, e in sage.arith.misc.factor(n): # Determine the power of p that divides the order. a = self**(n / (p**e)) while a != 1: diff --git a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx index 60d275ea5ae..bb490c163a8 100644 --- a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx +++ b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx @@ -274,7 +274,6 @@ cdef class Cache_ntl_gf2e(Cache_base): cdef FiniteField_ntl_gf2eElement x cdef FiniteField_ntl_gf2eElement g cdef Py_ssize_t i - from sage.libs.gap.element import GapElement_FiniteField if is_IntegerMod(e): e = e.lift() @@ -334,14 +333,18 @@ cdef class Cache_ntl_gf2e(Cache_base): # Reduce to pari e = e.__pari__() - elif isinstance(e, GapElement_FiniteField): - return e.sage(ring=self._parent) - elif isinstance(e, GapElement): from sage.libs.gap.libgap import libgap return libgap(e).sage(ring=self._parent) else: + try: + from sage.libs.gap.element import GapElement_FiniteField + except ImportError: + pass + else: + if isinstance(e, GapElement_FiniteField): + return e.sage(ring=self._parent) raise TypeError("unable to coerce %r" % type(e)) cdef GEN t diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx index ca262f6f668..4f37f6c3043 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx @@ -611,6 +611,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): EXAMPLES:: + sage: # needs sage.modules sage: k. = GF(2^20, impl='pari_ffelt') sage: e = k.random_element() sage: f = loads(dumps(e)) diff --git a/src/sage/rings/finite_rings/galois_group.py b/src/sage/rings/finite_rings/galois_group.py index 293803f1e98..f11b72bc681 100644 --- a/src/sage/rings/finite_rings/galois_group.py +++ b/src/sage/rings/finite_rings/galois_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules sage.rings.finite_rings r""" Galois groups of Finite Fields """ @@ -109,7 +110,7 @@ def _element_constructor_(self, x, check=True): Frob^2 sage: G(G.gens()[0]) Frob - sage: G([(1,3,2)]) + sage: G([(1,3,2)]) # needs sage.libs.gap Frob^2 sage: G(k.hom(k.gen()^3, k)) Frob diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx index e84b303769a..b79416eb1d7 100644 --- a/src/sage/rings/finite_rings/residue_field.pyx +++ b/src/sage/rings/finite_rings/residue_field.pyx @@ -128,7 +128,7 @@ First over a small non-prime field:: Residue field in ubar of Fractional ideal (47, 517/55860*u^5 + 235/3724*u^4 + 9829/13965*u^3 + 54106/13965*u^2 + 64517/27930*u + 755696/13965) - sage: I.groebner_basis() + sage: I.groebner_basis() # needs sage.libs.singular [X + (-19*ubar^2 - 5*ubar - 17)*Y] And now over a large prime field:: @@ -144,11 +144,11 @@ And now over a large prime field:: 4398046511119 sage: S. = PolynomialRing(Rf, order='lex') sage: I = ideal([2*X - Y^2, Y + Z]) - sage: I.groebner_basis() + sage: I.groebner_basis() # needs sage.libs.singular [X + 2199023255559*Z^2, Y + Z] sage: S. = PolynomialRing(Rf, order='deglex') sage: I = ideal([2*X - Y^2, Y + Z]) - sage: I.groebner_basis() + sage: I.groebner_basis() # needs sage.libs.singular [Z^2 + 4398046511117*X, Y + Z] """ diff --git a/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx b/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx index f21a3b8d9bb..e9962c3ccde 100644 --- a/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx @@ -118,7 +118,7 @@ class ResidueFiniteField_pari_ffelt(ResidueField_generic, FiniteField_pari_ffelt sage: R. = GF(5)[]; P = R.ideal(4*t^12 + 3*t^11 + 4*t^10 + t^9 + t^8 + 3*t^7 + 2*t^6 + 3*t^4 + t^3 + 3*t^2 + 2) sage: k. = P.residue_field() - sage: V = k.vector_space(map=False); v = V([1,2,3,4,5,6,7,8,9,0,1,2]); k(v) # indirect doctest # needs sage.modules + sage: V = k.vector_space(map=False); v = V([1,2,3,4,5,6,7,8,9,0,1,2]); k(v) # indirect doctest # needs sage.modules 2*a^11 + a^10 + 4*a^8 + 3*a^7 + 2*a^6 + a^5 + 4*a^3 + 3*a^2 + 2*a + 1 """ try: diff --git a/src/sage/rings/function_field/function_field_rational.py b/src/sage/rings/function_field/function_field_rational.py index e763a673a15..226d87d084c 100644 --- a/src/sage/rings/function_field/function_field_rational.py +++ b/src/sage/rings/function_field/function_field_rational.py @@ -138,7 +138,7 @@ def __init__(self, constant_field, names, category=None): sage: K. = FunctionField(CC); K # needs sage.rings.real_mpfr Rational function field in t over Complex Field with 53 bits of precision - sage: TestSuite(K).run() # long time (5s) # needs sage.rings.real_mpfr + sage: TestSuite(K).run() # long time (5s) # needs sage.rings.real_mpfr sage: FunctionField(QQ[I], 'alpha') # needs sage.rings.number_field Rational function field in alpha over diff --git a/src/sage/rings/generic.py b/src/sage/rings/generic.py index 83f923cee5c..99bf690bef6 100644 --- a/src/sage/rings/generic.py +++ b/src/sage/rings/generic.py @@ -20,6 +20,7 @@ class ProductTree: (the famous *Fast* Fourier Transform) can be implemented as follows using the :meth:`remainders` method of this class:: + sage: # needs sage.rings.finite_rings sage: from sage.rings.generic import ProductTree sage: F = GF(65537) sage: a = F(1111) @@ -62,6 +63,7 @@ class ProductTree: :: + sage: # needs sage.libs.pari sage: vs = prime_range(100) sage: tree = ProductTree(vs) sage: tree.root().factor() @@ -71,7 +73,7 @@ class ProductTree: We can access the individual layers of the tree:: - sage: tree.layers + sage: tree.layers # needs sage.libs.pari [(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97), (6, 35, 143, 323, 667, 1147, 1763, 2491, 3599, 4757, 5767, 7387, 97), (210, 46189, 765049, 4391633, 17120443, 42600829, 97), @@ -87,8 +89,8 @@ def __init__(self, leaves): EXAMPLES:: sage: from sage.rings.generic import ProductTree - sage: vs = prime_range(100) - sage: tree = ProductTree(vs) + sage: vs = prime_range(100) # needs sage.libs.pari + sage: tree = ProductTree(vs) # needs sage.libs.pari """ V = tuple(leaves) self.layers = [V] @@ -182,6 +184,7 @@ def remainders(self, x): EXAMPLES:: + sage: # needs sage.libs.pari sage: from sage.rings.generic import ProductTree sage: vs = prime_range(100) sage: tree = ProductTree(vs) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index c990c200e57..cebbc5b4785 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -4076,7 +4076,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): """ if self.is_zero(): raise ArithmeticError("support of 0 not defined") - return sage.arith.all.prime_factors(self) + from sage.arith.misc import prime_factors + + return prime_factors(self) def coprime_integers(self, m): """ diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index a9cb8eda29e..c65f75a248c 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -1255,7 +1255,7 @@ cdef class RingHomomorphism(RingMap): Ideals in quotient rings over ``QQbar`` do not support reduction yet, so the graph is constructed in the ambient ring instead:: - sage: # needs sage.rings.number_field + sage: # needs sage.libs.singular sage.rings.number_field sage: A. = QQbar['z,w'].quotient('z*w - 1') sage: B. = QQbar['x,y'].quotient('2*x^2 + y^2 - 1') sage: f = A.hom([QQbar(2).sqrt()*x + QQbar(I)*y, @@ -1447,7 +1447,7 @@ cdef class RingHomomorphism(RingMap): An isomorphism between the algebraic torus and the circle over a number field:: - sage: # needs sage.rings.number_field + sage: # needs sage.libs.singular sage.rings.number_field sage: K. = QuadraticField(-1) sage: A. = K['z,w'].quotient('z*w - 1') sage: B. = K['x,y'].quotient('x^2 + y^2 - 1') diff --git a/src/sage/rings/multi_power_series_ring.py b/src/sage/rings/multi_power_series_ring.py index 3d96666e222..8ceaa9c5154 100644 --- a/src/sage/rings/multi_power_series_ring.py +++ b/src/sage/rings/multi_power_series_ring.py @@ -204,24 +204,29 @@ # http://www.gnu.org/licenses/ #***************************************************************************** +import sage.misc.latex as latex -from sage.rings.ring import CommutativeRing -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing +from sage.rings.infinity import infinity +from sage.rings.multi_power_series_ring_element import MPowerSeries from sage.rings.polynomial.polynomial_ring import is_PolynomialRing +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing from sage.rings.polynomial.term_order import TermOrder from sage.rings.power_series_ring import PowerSeriesRing, PowerSeriesRing_generic, is_PowerSeriesRing - -from sage.rings.infinity import infinity -import sage.misc.latex as latex +from sage.rings.ring import CommutativeRing from sage.structure.nonexact import Nonexact -from sage.rings.multi_power_series_ring_element import MPowerSeries from sage.categories.commutative_rings import CommutativeRings _CommutativeRings = CommutativeRings() + from sage.categories.integral_domains import IntegralDomains _IntegralDomains = IntegralDomains() +try: + from sage.rings.laurent_series_ring import LaurentSeriesRing +except ImportError: + LaurentSeriesRing = () + def is_MPowerSeriesRing(x): """ @@ -731,8 +736,8 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): return False if all(v == 0 for v in im_gens): return True - from .laurent_series_ring import is_LaurentSeriesRing - if is_MPowerSeriesRing(codomain) or is_PowerSeriesRing(codomain) or is_LaurentSeriesRing(codomain): + + if is_MPowerSeriesRing(codomain) or is_PowerSeriesRing(codomain) or isinstance(codomain, LaurentSeriesRing): try: B = all(v.valuation() > 0 or v.is_nilpotent() for v in im_gens) except NotImplementedError: diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 77048cd3b79..6e6d0fc36e4 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -82,7 +82,6 @@ import sage.libs.ntl.all as ntl -import sage.interfaces.gap import sage.rings.complex_mpfr from sage.rings.polynomial.polynomial_element import Polynomial @@ -92,14 +91,14 @@ import sage.rings.real_double import sage.rings.real_lazy -from sage.rings.finite_rings.integer_mod import mod - - +from sage.arith.misc import euler_phi, factor, gcd, next_prime from sage.misc.fast_methods import WithEqualityById from sage.misc.functional import is_odd, lift from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod +from sage.misc.sage_eval import sage_eval from sage.rings.infinity import Infinity +from sage.rings.finite_rings.integer_mod import mod from sage.categories.number_fields import NumberFields import sage.rings.ring @@ -204,7 +203,6 @@ def proof_flag(t): from sage.misc.latex import latex -import sage.arith.all as arith import sage.rings.infinity as infinity from sage.rings.rational import Rational from sage.rings.integer import Integer @@ -1311,7 +1309,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField): This example was suggested on sage-nt; see :trac:`18942`:: sage: G = DirichletGroup(80) # needs sage.modular - sage: for chi in G: # long time # needs sage.modular + sage: for chi in G: # long time # needs sage.modular ....: D = ModularSymbols(chi, 2, -1).cuspidal_subspace().new_subspace().decomposition() ....: for f in D: ....: elt = f.q_eigenform(10, 'alpha')[3] @@ -1942,7 +1940,7 @@ def _convert_from_str(self, x): sage: k('theta25^3 + (1/3)*theta25') -1/3*theta25 - 1 """ - w = sage.misc.all.sage_eval(x, locals=self.gens_dict()) + w = sage_eval(x, locals=self.gens_dict()) if not (is_Element(w) and w.parent() is self): return self(w) else: @@ -3319,6 +3317,7 @@ def conductor(self, check_abelian=True): EXAMPLES:: + sage: # needs sage.groups sage: K = CyclotomicField(27) sage: k = K.subfields(9)[0][0] sage: k.conductor() @@ -3389,6 +3388,7 @@ def dirichlet_group(self): EXAMPLES:: + sage: # needs sage.groups sage.modular sage: x = polygen(QQ, 'x') sage: K. = NumberField(x^3 + x^2 - 36*x - 4) sage: K.conductor() @@ -3398,15 +3398,16 @@ def dirichlet_group(self): Dirichlet character modulo 109 of conductor 109 mapping 6 |--> zeta3, Dirichlet character modulo 109 of conductor 109 mapping 6 |--> -zeta3 - 1] + sage: # needs sage.modular sage: K = CyclotomicField(44) sage: L = K.subfields(5)[0][0] - sage: X = L.dirichlet_group() # optional - gap_package_polycyclic - sage: X # optional - gap_package_polycyclic + sage: X = L.dirichlet_group(); X # optional - gap_package_polycyclic [Dirichlet character modulo 11 of conductor 1 mapping 2 |--> 1, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^2, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^3, - Dirichlet character modulo 11 of conductor 11 mapping 2 |--> -zeta5^3 - zeta5^2 - zeta5 - 1] + Dirichlet character modulo 11 of conductor 11 + mapping 2 |--> -zeta5^3 - zeta5^2 - zeta5 - 1] sage: X[4]^2 # optional - gap_package_polycyclic Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^3 sage: X[4]^2 in X # optional - gap_package_polycyclic @@ -3964,10 +3965,8 @@ def primes_of_bounded_norm(self, B): from sage.rings.fast_arith import prime_range if self is QQ: - # return arith.primes(B+1) return prime_range(B + 1, algorithm="pari_isprime") else: - # P = [pp for p in arith.primes(B+1) for pp in self.primes_above(p)] P = (pp for p in prime_range(B + 1, algorithm="pari_isprime") for pp in self.primes_above(p)) P = [p for p in P if p.norm() <= B] @@ -4018,11 +4017,9 @@ def primes_of_bounded_norm_iter(self, B): from sage.rings.fast_arith import prime_range if self is QQ: - # for p in arith.primes(B+1): for p in prime_range(B + 1, algorithm="pari_isprime"): yield p else: - # for p in arith.primes(B+1): for p in prime_range(B + 1, algorithm="pari_isprime"): for pp in self.primes_above(p): if pp.norm() <= B: @@ -4135,7 +4132,7 @@ def completely_split_primes(self, B=200): from sage.rings.fast_arith import prime_range from sage.rings.finite_rings.finite_field_constructor import GF from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing - from sage.arith.misc import factor + split_primes = [] for p in prime_range(B): Fp = GF(p) @@ -4532,7 +4529,8 @@ def _gap_init_(self): """ if not self.is_absolute(): raise NotImplementedError("Currently, only simple algebraic extensions are implemented in gap") - G = sage.interfaces.gap.gap + from sage.interfaces.gap import gap as G + q = self.polynomial() if q.variable_name() != 'E': return 'CallFuncList(function() local %s,E; %s:=Indeterminate(%s,"%s"); E:=AlgebraicExtension(%s,%s,"%s"); return E; end,[])' % (q.variable_name(), q.variable_name(), G(self.base_ring()).name(), q.variable_name(), G(self.base_ring()).name(), repr(self.polynomial()), str(self.gen())) @@ -4610,6 +4608,7 @@ def class_group(self, proof=None, names='c'): Class groups of Hecke polynomials tend to be very small:: + sage: # needs sage.modular sage: f = ModularForms(97, 2).T(2).charpoly() sage: f.factor() (x - 3) * (x^3 + 4*x^2 + 3*x - 1) * (x^4 - 3*x^3 - x^2 + 6*x - 1) @@ -5982,7 +5981,7 @@ def decomposition_type(self, p): sage: R. = ZZ[] sage: K. = NumberField(x^20 + 3*x^18 + 15*x^16 + 28*x^14 + 237*x^12 + 579*x^10 ....: + 1114*x^8 + 1470*x^6 + 2304*x^4 + 1296*x^2 + 729) - sage: K.is_galois() + sage: K.is_galois() # needs sage.groups True sage: K.discriminant().factor() 2^20 * 3^10 * 53^10 @@ -6149,6 +6148,7 @@ def is_galois(self): EXAMPLES:: + sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + 1, 'i').is_galois() True @@ -6175,6 +6175,7 @@ def is_abelian(self): EXAMPLES:: + sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + 1, 'i').is_abelian() True @@ -6235,6 +6236,7 @@ def galois_group(self, type=None, algorithm='pari', names=None, gc_numbering=Non EXAMPLES:: + sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: k. = NumberField(x^2 - 14) # a Galois extension sage: G = k.galois_group(); G @@ -6246,13 +6248,14 @@ def galois_group(self, type=None, algorithm='pari', names=None, gc_numbering=Non sage: G.artin_symbol(k.primes_above(3)[0]) (1,2) - sage: k. = NumberField(x^3 - x + 1) # not Galois + sage: # needs sage.groups + sage: k. = NumberField(x^3 - x + 1) # not Galois sage: G = k.galois_group(names='c'); G Galois group 3T2 (S3) with order 6 of x^3 - x + 1 sage: G.gen(0) (1,2,3)(4,5,6) - sage: NumberField(x^3 + 2*x + 1, 'a').galois_group(algorithm='magma') # optional - magma + sage: NumberField(x^3 + 2*x + 1, 'a').galois_group(algorithm='magma') # optional - magma, needs sage.groups Galois group Transitive group number 2 of degree 3 of the Number Field in a with defining polynomial x^3 + 2*x + 1 @@ -6261,6 +6264,7 @@ def galois_group(self, type=None, algorithm='pari', names=None, gc_numbering=Non :: + sage: # needs sage.groups sage: K. = NumberField(x^3 - 2) sage: L. = K.galois_closure(); L Number Field in b1 with defining polynomial x^6 + 108 @@ -6286,6 +6290,7 @@ def galois_group(self, type=None, algorithm='pari', names=None, gc_numbering=Non change in the future, so it's better to explicitly call :meth:`absolute_field` if that is the desired behavior:: + sage: # needs sage.groups sage: x = polygen(QQ) sage: K. = NumberField(x^2 + 1) sage: R. = PolynomialRing(K) @@ -6300,6 +6305,7 @@ def galois_group(self, type=None, algorithm='pari', names=None, gc_numbering=Non We check that the changes in :trac:`28782` won't break code that used v1 Galois groups:: + sage: # needs sage.groups sage: G = NumberField(x^3 - 2, 'a').galois_group(type="pari") ...DeprecationWarning: the different Galois types have been merged into one class See https://github.com/sagemath/sage/issues/28782 for details. @@ -7429,6 +7435,7 @@ def S_unit_solutions(self, S=[], prec=106, include_exponents=False, include_boun EXAMPLES:: + sage: # needs sage.rings.padics sage: x = polygen(QQ, 'x') sage: K. = NumberField(x^2 + x + 1) sage: S = K.primes_above(3) @@ -7437,7 +7444,8 @@ def S_unit_solutions(self, S=[], prec=106, include_exponents=False, include_boun You can get the exponent vectors:: - sage: K.S_unit_solutions(S, include_exponents=True) # random, due to ordering + sage: # needs sage.rings.padics + sage: K.S_unit_solutions(S, include_exponents=True) # random, due to ordering [((2, 1), (4, 0), xi + 2, -xi - 1), ((5, -1), (4, -1), 1/3*xi + 2/3, -1/3*xi + 1/3), ((5, 0), (1, 0), -xi, xi + 1), @@ -7445,6 +7453,7 @@ def S_unit_solutions(self, S=[], prec=106, include_exponents=False, include_boun And the computed bound:: + sage: # needs sage.rings.padics sage: solutions, bound = K.S_unit_solutions(S, prec=100, include_bound=True) sage: bound 7 @@ -7547,7 +7556,7 @@ def zeta(self, n=2, all=False): # First check if the degree of K is compatible # with an inclusion QQ(\zeta_n) -> K. - if sage.arith.all.euler_phi(n).divides(K.absolute_degree()): + if euler_phi(n).divides(K.absolute_degree()): w, zeta_w = self.pari_nf().nfrootsof1() w = w.sage() zeta_w = K(zeta_w) @@ -7788,17 +7797,17 @@ def valuation(self, prime): sage: x = polygen(QQ, 'x') sage: K. = NumberField(x^2 + 1) - sage: K.valuation(2) + sage: K.valuation(2) # needs sage.rings.padics 2-adic valuation It can also be unramified in ``R``:: - sage: K.valuation(3) + sage: K.valuation(3) # needs sage.rings.padics 3-adic valuation A ``prime`` that factors into pairwise distinct factors, results in an error:: - sage: K.valuation(5) + sage: K.valuation(5) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation Gauss valuation induced by 5-adic valuation does not @@ -7807,12 +7816,12 @@ def valuation(self, prime): The valuation can also be selected by giving a valuation on the base ring that extends uniquely:: - sage: CyclotomicField(5).valuation(ZZ.valuation(5)) + sage: CyclotomicField(5).valuation(ZZ.valuation(5)) # needs sage.rings.padics 5-adic valuation When the extension is not unique, this does not work:: - sage: K.valuation(ZZ.valuation(5)) + sage: K.valuation(ZZ.valuation(5)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation Gauss valuation induced by 5-adic valuation does not @@ -7823,6 +7832,7 @@ def valuation(self, prime): `G` to infinity. This lets us specify which extension of the 5-adic valuation we care about in the above example:: + sage: # needs sage.rings.padics sage: R. = QQ[] sage: G5 = GaussValuation(R, QQ.valuation(5)) sage: v = K.valuation(G5.augmentation(x + 2, infinity)) @@ -7833,6 +7843,7 @@ def valuation(self, prime): Note that you get the same valuation, even if you write down the pseudo-valuation differently:: + sage: # needs sage.rings.padics sage: ww = K.valuation(G5.augmentation(x + 3, infinity)) sage: w is ww True @@ -7843,6 +7854,7 @@ def valuation(self, prime): completion, i.e., if it is not possible to write down one of the factors within the number field:: + sage: # needs sage.rings.padics sage: v = G5.augmentation(x + 3, 1) sage: K.valuation(v) [ 5-adic valuation, v(x + 3) = 1 ]-adic valuation @@ -7850,7 +7862,7 @@ def valuation(self, prime): Finally, ``prime`` can also be a fractional ideal of a number field if it singles out an extension of a `p`-adic valuation of the base field:: - sage: K.valuation(K.fractional_ideal(a + 1)) + sage: K.valuation(K.fractional_ideal(a + 1)) # needs sage.rings.padics 2-adic valuation .. SEEALSO:: @@ -9123,6 +9135,7 @@ def _galois_closure_and_embedding(self, names=None): For medium-sized Galois groups of fields with small discriminants, this computation is feasible:: + sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: K. = NumberField(x^6 + 4*x^2 + 2) sage: K.galois_group().order() @@ -9170,6 +9183,7 @@ def galois_closure(self, names=None, map=False): EXAMPLES:: + sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: K. = NumberField(x^4 - 2) sage: M = K.galois_closure('b'); M @@ -9181,12 +9195,14 @@ def galois_closure(self, names=None, map=False): :: + sage: # needs sage.groups sage: phi = K.embeddings(L)[0] sage: phi(K.0) 1/120*a2^5 + 19/60*a2 sage: phi(K.0).minpoly() x^4 - 2 + sage: # needs sage.groups sage: L, phi = K.galois_closure('b', map=True) sage: L Number Field in b with defining polynomial x^8 + 28*x^4 + 2500 @@ -9198,6 +9214,7 @@ def galois_closure(self, names=None, map=False): A cyclotomic field is already Galois:: + sage: # needs sage.groups sage: K. = NumberField(cyclotomic_polynomial(23)) sage: L. = K.galois_closure() sage: L @@ -9209,6 +9226,7 @@ def galois_closure(self, names=None, map=False): Let's make sure we're renaming correctly:: + sage: # needs sage.groups sage: K. = NumberField(x^4 - 2) sage: L, phi = K.galois_closure('cc', map=True) sage: L @@ -9293,6 +9311,7 @@ def embeddings(self, K): EXAMPLES:: + sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: K. = NumberField(x^3 - 2) sage: L. = K.galois_closure(); L @@ -10942,6 +10961,7 @@ def _gap_init_(self): TESTS:: + sage: # needs sage.libs.gap sage: K = CyclotomicField(8) sage: gap(K) # indirect doctest CF(8) @@ -10955,13 +10975,15 @@ def _gap_init_(self): a genuine representation of cyclotomic fields in the GAP interface -- see :trac:`5618`. :: + sage: # needs sage.groups sage: H = AlternatingGroup(4) sage: g = H((1,4,3)) sage: K = H.subgroup([g]) sage: z = CyclotomicField(3).an_element(); z zeta3 sage: c = K.character([1,z,z**2]); c - Character of Subgroup generated by [(1,4,3)] of (Alternating group of order 4!/2 as a permutation group) + Character of Subgroup generated by [(1,4,3)] of + (Alternating group of order 4!/2 as a permutation group) sage: c(g^2); z^2 zeta3 -zeta3 - 1 @@ -10974,10 +10996,11 @@ def _libgap_(self): TESTS:: + sage: # needs sage.libs.gap sage: K = CyclotomicField(8) - sage: K._libgap_() # needs sage.libs.gap + sage: K._libgap_() CF(8) - sage: libgap(K) # indirect doctest # needs sage.libs.gap + sage: libgap(K) # indirect doctest CF(8) """ from sage.libs.gap.libgap import libgap @@ -11610,7 +11633,7 @@ def embeddings(self, K): # zeta not defined return super().embeddings(K) else: - X = (m for m in range(n) if arith.gcd(m, n) == 1) + X = (m for m in range(n) if gcd(m, n) == 1) v = [self.hom([z**i], check=False) for i in X] else: v = [] @@ -11781,7 +11804,7 @@ def next_split_prime(self, p=2): """ n = self._n() while True: - p = arith.next_prime(p) + p = next_prime(p) if p % n == 1: return p @@ -11855,7 +11878,7 @@ def _multiplicative_order_table(self): zeta = self.zeta(n) # todo: this desperately needs to be optimized!!! for i in range(n): - t[x.polynomial()] = n // arith.GCD(m, n) # multiplicative_order of (zeta_n)**m + t[x.polynomial()] = n // gcd(m, n) # multiplicative_order of (zeta_n)**m x *= zeta m += 1 self.__multiplicative_order_table = t @@ -12278,7 +12301,7 @@ def hilbert_class_field_defining_polynomial(self, name='x'): Note that this polynomial is not the actual Hilbert class polynomial: see ``hilbert_class_polynomial``:: - sage: K.hilbert_class_polynomial() + sage: K.hilbert_class_polynomial() # needs sage.schemes x^3 + 3491750*x^2 - 5151296875*x + 12771880859375 :: @@ -12331,11 +12354,11 @@ def hilbert_class_polynomial(self, name='x'): EXAMPLES:: sage: K. = QuadraticField(-3) - sage: K.hilbert_class_polynomial() + sage: K.hilbert_class_polynomial() # needs sage.schemes x sage: K. = QuadraticField(-31) - sage: K.hilbert_class_polynomial(name='z') + sage: K.hilbert_class_polynomial(name='z') # needs sage.schemes z^3 + 39491307*z^2 - 58682638134*z + 1566028350940383 """ D = self.discriminant() @@ -12711,7 +12734,7 @@ def _splitting_classes_gens_(K, m, d): sage: from sage.rings.number_field.number_field import _splitting_classes_gens_ sage: K = CyclotomicField(101) sage: L = K.subfields(20)[0][0] - sage: L.conductor() + sage: L.conductor() # needs sage.groups 101 sage: _splitting_classes_gens_(L,101,20) # needs sage.libs.gap # optional - gap_package_polycyclic [95] @@ -12728,7 +12751,7 @@ def _splitting_classes_gens_(K, m, d): sage: L Number Field in zeta44_0 with defining polynomial x^5 - 2*x^4 - 16*x^3 + 24*x^2 + 48*x - 32 with zeta44_0 = 3.837971894457990? - sage: L.conductor() + sage: L.conductor() # needs sage.groups 11 sage: _splitting_classes_gens_(L,11,5) # needs sage.libs.gap # optional - gap_package_polycyclic [10] @@ -12748,7 +12771,7 @@ def map_Zmstar_to_Zm(h): Hgens = [] H = Zmstar.subgroup([]) p = 0 - Horder = arith.euler_phi(m) / d + Horder = euler_phi(m) / d for g in Zmstar: if H.order() == Horder: break diff --git a/src/sage/rings/number_field/totallyreal_rel.py b/src/sage/rings/number_field/totallyreal_rel.py index 47ee18456f7..9b416d2ad02 100644 --- a/src/sage/rings/number_field/totallyreal_rel.py +++ b/src/sage/rings/number_field/totallyreal_rel.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.libs.linbox sage.modules sage.rings.number_field r""" Enumeration of totally real fields: relative extensions diff --git a/src/sage/rings/padics/padic_extension_leaves.py b/src/sage/rings/padics/padic_extension_leaves.py index ef0ed071a2c..d63dc734097 100644 --- a/src/sage/rings/padics/padic_extension_leaves.py +++ b/src/sage/rings/padics/padic_extension_leaves.py @@ -303,7 +303,7 @@ class UnramifiedExtensionRingFixedMod(UnramifiedExtensionGeneric, pAdicFixedModR TESTS:: sage: R. = ZqFM(27,1000) # needs sage.libs.flint - sage: TestSuite(R).run(skip='_test_log',max_runs=4) # long time # needs sage.libs.flint + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # long time # needs sage.libs.flint """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): """ diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index cb0207c10d4..d1590d0391f 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -1360,7 +1360,7 @@ class pAdicFromLimitValuation(FiniteExtensionFromLimitValuation, pAdicValuation_ TESTS:: - sage: TestSuite(v).run(skip='_test_shift') # long time # needs sage.rings.number_field + sage: TestSuite(v).run(skip='_test_shift') # long time # needs sage.rings.number_field The ``_test_shift`` test fails because the parent of the shift is incorrect, see :trac:`23971`:: diff --git a/src/sage/rings/polynomial/complex_roots.py b/src/sage/rings/polynomial/complex_roots.py index cbbd42c8ccf..4c66eeca40c 100644 --- a/src/sage/rings/polynomial/complex_roots.py +++ b/src/sage/rings/polynomial/complex_roots.py @@ -21,7 +21,11 @@ sage: x = polygen(ZZ) sage: (x^5 - x - 1).roots(ring=CIF) - [(1.167303978261419?, 1), (-0.764884433600585? - 0.352471546031727?*I, 1), (-0.764884433600585? + 0.352471546031727?*I, 1), (0.181232444469876? - 1.083954101317711?*I, 1), (0.181232444469876? + 1.083954101317711?*I, 1)] + [(1.167303978261419?, 1), + (-0.764884433600585? - 0.352471546031727?*I, 1), + (-0.764884433600585? + 0.352471546031727?*I, 1), + (0.181232444469876? - 1.083954101317711?*I, 1), + (0.181232444469876? + 1.083954101317711?*I, 1)] """ #***************************************************************************** @@ -61,9 +65,13 @@ def interval_roots(p, rts, prec): sage: rts = [CC.zeta(3)^i for i in range(0, 3)] sage: from sage.rings.polynomial.complex_roots import interval_roots sage: interval_roots(p, rts, 53) - [1, -0.500000000000000? + 0.866025403784439?*I, -0.500000000000000? - 0.866025403784439?*I] + [1, -0.500000000000000? + 0.866025403784439?*I, + -0.500000000000000? - 0.866025403784439?*I] sage: interval_roots(p, rts, 200) - [1, -0.500000000000000000000000000000000000000000000000000000000000? + 0.866025403784438646763723170752936183471402626905190314027904?*I, -0.500000000000000000000000000000000000000000000000000000000000? - 0.866025403784438646763723170752936183471402626905190314027904?*I] + [1, -0.500000000000000000000000000000000000000000000000000000000000? + + 0.866025403784438646763723170752936183471402626905190314027904?*I, + -0.500000000000000000000000000000000000000000000000000000000000? + - 0.866025403784438646763723170752936183471402626905190314027904?*I] """ CIF = ComplexIntervalField(prec) @@ -172,15 +180,19 @@ def complex_roots(p, skip_squarefree=False, retval='interval', min_prec=0): sage: from sage.rings.polynomial.complex_roots import complex_roots sage: x = polygen(ZZ) sage: complex_roots(x^5 - x - 1) - [(1.167303978261419?, 1), (-0.764884433600585? - 0.352471546031727?*I, 1), (-0.764884433600585? + 0.352471546031727?*I, 1), (0.181232444469876? - 1.083954101317711?*I, 1), (0.181232444469876? + 1.083954101317711?*I, 1)] - sage: v=complex_roots(x^2 + 27*x + 181) + [(1.167303978261419?, 1), + (-0.764884433600585? - 0.352471546031727?*I, 1), + (-0.764884433600585? + 0.352471546031727?*I, 1), + (0.181232444469876? - 1.083954101317711?*I, 1), + (0.181232444469876? + 1.083954101317711?*I, 1)] + sage: v = complex_roots(x^2 + 27*x + 181) Unfortunately due to numerical noise there can be a small imaginary part to each root depending on CPU, compiler, etc, and that affects the printing order. So we verify the real part of each root and check that the imaginary part is small in both cases:: - sage: v # random + sage: v # random [(-14.61803398874990?..., 1), (-12.3819660112501...? + 0.?e-27*I, 1)] sage: sorted((v[0][0].real(),v[1][0].real())) [-14.61803398874989?, -12.3819660112501...?] @@ -227,11 +239,16 @@ def complex_roots(p, skip_squarefree=False, retval='interval', min_prec=0): ....: if tiny(x.imag()): return x.real() ....: if tiny(x.real()): return CIF(0, x.imag()) sage: rts = complex_roots(p); type(rts[0][0]), sorted(map(smash, rts)) - (, [-1.618033988749895?, -0.618033988749895?*I, 1.618033988749895?*I, 0.618033988749895?]) + (, + [-1.618033988749895?, -0.618033988749895?*I, + 1.618033988749895?*I, 0.618033988749895?]) sage: rts = complex_roots(p, retval='algebraic'); type(rts[0][0]), sorted(map(smash, rts)) - (, [-1.618033988749895?, -0.618033988749895?*I, 1.618033988749895?*I, 0.618033988749895?]) + (, + [-1.618033988749895?, -0.618033988749895?*I, + 1.618033988749895?*I, 0.618033988749895?]) sage: rts = complex_roots(p, retval='algebraic_real'); type(rts[0][0]), rts - (, [(-1.618033988749895?, 1), (0.618033988749895?, 1)]) + (, + [(-1.618033988749895?, 1), (0.618033988749895?, 1)]) TESTS: diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index d4e2b115e39..f5c1b0e480c 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -2075,8 +2075,9 @@ def factor(self, proof=None): Check that we can factor over the algebraic field (:trac:`25390`):: - sage: R. = PolynomialRing(QQbar) # needs sage.rings.number_field - sage: factor(x^2 + y^2) # needs sage.rings.number_field + sage: # needs sage.libs.singular sage.rings.number_field + sage: R. = PolynomialRing(QQbar) + sage: factor(x^2 + y^2) (x + (-1*I)*y) * (x + 1*I*y) Check that the global proof flag for polynomials is honored:: @@ -2123,7 +2124,7 @@ def factor(self, proof=None): sage: R. = PolynomialRing(CC,1) # needs sage.rings.real_mpfr sage: f = z^4 - 6*z + 3 # needs sage.rings.real_mpfr - sage: f.factor() # needs sage.rings.real_mpfr + sage: f.factor() # needs sage.libs.pari sage.rings.real_mpfr (z - 1.60443920904349) * (z - 0.511399619393097) * (z + 1.05791941421830 - 1.59281852704435*I) * (z + 1.05791941421830 + 1.59281852704435*I) @@ -2252,7 +2253,7 @@ def quo_rem(self, right): ((2*b + 1)*y, (2*b + 1)*y + (-a^2 + 3)*z + a) sage: R. = Qp(5)[] # needs sage.rings.padics - sage: x.quo_rem(y) # needs sage.rings.padics + sage: x.quo_rem(y) # needs sage.libs.singular sage.rings.padics Traceback (most recent call last): ... TypeError: no conversion of this ring to a Singular ring defined @@ -2265,7 +2266,7 @@ def quo_rem(self, right): sage: R. = QQbar[] # needs sage.rings.number_field sage: f = y*x^2 + x + 1 # needs sage.rings.number_field - sage: f.quo_rem(x) # needs sage.rings.number_field + sage: f.quo_rem(x) # needs sage.libs.singular sage.rings.number_field (x*y + 1, 1) """ R = self.parent() @@ -2326,7 +2327,7 @@ def resultant(self, other, variable=None): Check that :trac:`15061` is fixed:: sage: R. = AA[] # needs sage.rings.number_field - sage: (x^2 + 1).resultant(x^2 - y) # needs sage.rings.number_field + sage: (x^2 + 1).resultant(x^2 - y) # needs sage.libs.singular sage.rings.number_field y^2 + 2*y + 1 Test for :trac:`2693`:: @@ -2334,7 +2335,7 @@ def resultant(self, other, variable=None): sage: R. = RR[] sage: p = x + y sage: q = x*y - sage: p.resultant(q) # needs sage.modules + sage: p.resultant(q) # needs sage.libs.singular sage.modules -y^2 Check that this method works over QQbar (:trac:`25351`):: @@ -2343,9 +2344,9 @@ def resultant(self, other, variable=None): sage: P. = QQbar[] sage: a = x + y sage: b = x^3 - y^3 - sage: a.resultant(b) + sage: a.resultant(b) # needs sage.libs.singular sage.modules (-2)*y^3 - sage: a.resultant(b, y) + sage: a.resultant(b, y) # needs sage.libs.singular sage.modules 2*x^3 """ R = self.parent() @@ -2375,7 +2376,7 @@ def subresultants(self, other, variable=None): EXAMPLES:: - sage: # needs sage.rings.number_field + sage: # needs sage.libs.singular sage.rings.number_field sage: R. = QQbar[] sage: p = (y^2 + 6)*(x - 1) - y*(x^2 + 1) sage: q = (x^2 + 6)*(y - 1) - x*(y^2 + 1) @@ -2413,9 +2414,9 @@ def reduce(self, I): sage: f3 = -x^2 + y^2 sage: F = Ideal([f1, f2, f3]) sage: g = x*y - 3*x*y^2 - sage: g.reduce(F) + sage: g.reduce(F) # needs sage.libs.singular (-6)*y^2 + 2*y - sage: g.reduce(F.gens()) + sage: g.reduce(F.gens()) # needs sage.libs.singular (-6)*y^2 + 2*y :: diff --git a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx index 44946845b83..7c86cf4a646 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx @@ -797,7 +797,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): EXAMPLES:: - sage: # needs sage.rings.number_field + sage: # needs sage.libs.gap sage.rings.number_field sage: F = CyclotomicField(8) sage: P. = F[] sage: gap(P) # indirect doctest diff --git a/src/sage/rings/polynomial/ore_function_element.py b/src/sage/rings/polynomial/ore_function_element.py index 3afaff91a10..78d9ee831be 100644 --- a/src/sage/rings/polynomial/ore_function_element.py +++ b/src/sage/rings/polynomial/ore_function_element.py @@ -76,6 +76,7 @@ def _repr_(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -85,6 +86,7 @@ def _repr_(self): TESTS:: + sage: # needs sage.rings.finite_rings sage: f = 1/x^3; f x^(-3) sage: f * x^5 @@ -139,6 +141,7 @@ def __hash__(self): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -156,12 +159,12 @@ def _richcmp_(self, other, op): TESTS:: + sage: # needs sage.rings.function_field sage: R. = QQ[] sage: sigma = R.hom([t+1]) sage: der = R.derivation(1, twist=sigma) sage: S. = R['delta', der] sage: K = S.fraction_field() - sage: P = K.random_element() sage: Q = K.random_element() sage: D = K.random_element() @@ -197,18 +200,19 @@ def left_denominator(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: s = x + a sage: t = x^2 + a*x + a^2 - sage: f = s^(-1) * t sage: f.left_denominator() x + a In the example below, a simplification occurs:: + sage: # needs sage.rings.finite_rings sage: u = S.random_element(degree=2) sage: g = (u*s)^(-1) * (u*t) sage: g.left_denominator() @@ -222,13 +226,13 @@ def left_denominator(self): sage: S. = R['x', sigma] sage: s = (x + z)^2 sage: t = (x + z) * (x^2 + z^2) - sage: f = s^(-1) * t - sage: f.left_denominator() + sage: f = s^(-1) * t # needs sage.rings.function_field + sage: f.left_denominator() # needs sage.rings.function_field x^2 + (z^2 + z)*x + z^2 However, the following always holds true:: - sage: f == f.left_denominator()^(-1) * f.right_numerator() + sage: f == f.left_denominator()^(-1) * f.right_numerator() # needs sage.rings.function_field True .. SEEALSO:: @@ -258,18 +262,19 @@ def right_numerator(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: s = x + a sage: t = x^2 + a*x + a^2 - sage: f = s^(-1) * t sage: f.right_numerator() x^2 + a*x + a^2 In the example below, a simplification occurs:: + sage: # needs sage.rings.finite_rings sage: u = S.random_element(degree=2) sage: g = (u*s)^(-1) * (u*t) sage: g.right_numerator() @@ -290,11 +295,11 @@ def _reverse_fraction(self): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(11^3) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a+1, twist=Frob) sage: S. = k['x', der] - sage: P = S.random_element(degree=5) sage: Q = S.random_element(degree=5) sage: f = P / Q @@ -330,18 +335,19 @@ def right_denominator(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: s = x + a sage: t = x^2 + a*x + a^2 - sage: f = t/s sage: f.right_denominator() x + a In the example below, a simplification occurs:: + sage: # needs sage.rings.finite_rings sage: u = S.random_element(degree=2) sage: g = (t*u) / (s*u) sage: g.right_denominator() @@ -356,11 +362,12 @@ def right_denominator(self): sage: R. = GF(11)[] sage: sigma = R.hom([z^2]) sage: S. = R['x', sigma] - sage: f = (x + z) / (x - z) - sage: f.right_denominator() + sage: f = (x + z) / (x - z) # needs sage.rings.function_field + sage: f.right_denominator() # needs sage.rings.function_field Traceback (most recent call last): ... - NotImplementedError: inversion of the twisting morphism Ring endomorphism of Fraction Field of Univariate Polynomial Ring in z over Finite Field of size 11 + NotImplementedError: inversion of the twisting morphism Ring endomorphism + of Fraction Field of Univariate Polynomial Ring in z over Finite Field of size 11 Defn: z |--> z^2 """ return self._reverse_fraction()[1] @@ -384,18 +391,19 @@ def left_numerator(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: s = x + a sage: t = x^2 + a*x + a^2 - sage: f = t/s sage: f.left_numerator() x^2 + a*x + a^2 In the example below, a simplification occurs:: + sage: # needs sage.rings.finite_rings sage: u = S.random_element(degree=2) sage: g = (t*u) / (s*u) sage: g.left_numerator() @@ -430,12 +438,12 @@ def _add_(self, other): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^2) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) sage: S. = k['x', der] sage: K = S.fraction_field() - sage: f = K.random_element() sage: g = K.random_element() sage: h = K.random_element() @@ -458,12 +466,12 @@ def _sub_(self, other): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^2) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) sage: S. = k['x', der] sage: K = S.fraction_field() - sage: f = K.random_element() sage: g = K.random_element() sage: h = K.random_element() @@ -480,12 +488,12 @@ def _neg_(self): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^2) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) sage: S. = k['x', der] sage: K = S.fraction_field() - sage: f = K.random_element() sage: g = -f sage: (f+g).is_zero() @@ -503,12 +511,12 @@ def _mul_(self, other): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^2) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) sage: S. = k['x', der] sage: K = S.fraction_field() - sage: f = K.random_element() sage: g = K.random_element() sage: h = K.random_element() @@ -538,18 +546,17 @@ def _div_(self, other): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^2) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) sage: S. = k['x', der] sage: K = S.fraction_field() - sage: f = K.random_element() sage: g = K.random_element() sage: h = K.random_element() sage: g == 0 or h == 0 or f / (g / h) == f*h / g True - sage: 0/f 0 sage: f/0 @@ -559,7 +566,7 @@ def _div_(self, other): We check that :trac:`32109` is fixed:: - sage: K(0)/K(0) + sage: K(0)/K(0) # needs sage.rings.finite_rings Traceback (most recent call last): ... ZeroDivisionError: cannot divide by zero @@ -579,17 +586,16 @@ def __invert__(self): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^2) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) sage: S. = k['x', der] sage: K = S.fraction_field() - sage: f = K.random_element() sage: g = ~f sage: f * g 1 - sage: ~K(0) Traceback (most recent call last): ... @@ -629,23 +635,24 @@ def hilbert_shift(self, s, var=None): When the twisting morphism is not trivial, the output lies in a different Ore polynomial ring:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() - sage: f = (x-a)^(-2) sage: g = f.hilbert_shift(a); g x^(-2) - sage: g.parent() - Ore Function Field in x over Finite Field in a of size 5^3 twisted by a |--> a^5 and a*([a |--> a^5] - id) + Ore Function Field in x over Finite Field in a of size 5^3 + twisted by a |--> a^5 and a*([a |--> a^5] - id) sage: g.parent() is S False This behavior ensures that the Hilbert shift by a fixed element defines an homomorphism of fields:: + sage: # needs sage.rings.finite_rings sage: U = K.random_element(degree=5) sage: V = K.random_element(degree=5) sage: s = k.random_element() @@ -669,17 +676,17 @@ class ConstantOreFunctionSection(Map): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.rings.polynomial.ore_polynomial_element import ConstantOrePolynomialSection sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() - sage: iota = K.coerce_map_from(k) - sage: sigma = iota.section() - sage: sigma + sage: sigma = iota.section(); sigma Generic map: - From: Ore Function Field in x over Finite Field in a of size 5^3 twisted by a |--> a^5 + From: Ore Function Field in x over Finite Field in a of size 5^3 + twisted by a |--> a^5 To: Finite Field in a of size 5^3 """ def _call_(self, x): @@ -693,14 +700,12 @@ def _call_(self, x): sage: F = R.fraction_field() sage: sigma = R.hom([t^2]) sage: S. = R['x', sigma] - sage: P = S._random_nonzero_element() - sage: f = (t*P) / P - sage: F(f) + sage: f = (t*P) / P # needs sage.rings.function_field + sage: F(f) # needs sage.rings.function_field t - - sage: g = x / (x+t) - sage: F(g) + sage: g = x / (x+t) # needs sage.rings.function_field + sage: F(g) # needs sage.rings.function_field Traceback (most recent call last): ... TypeError: not a constant function @@ -727,9 +732,8 @@ def __init__(self, domain, codomain): sage: R. = QQ[] sage: sigma = R.hom([t+1]) sage: S. = R['x',sigma] - sage: K = S.fraction_field() - - sage: K.coerce_map_from(K.base_ring()) # indirect doctest + sage: K = S.fraction_field() # needs sage.rings.function_field + sage: K.coerce_map_from(K.base_ring()) # indirect doctest # needs sage.rings.function_field Ore Function base injection morphism: From: Fraction Field of Univariate Polynomial Ring in t over Rational Field To: Ore Function Field in x over Fraction Field of Univariate Polynomial Ring in t over Rational Field twisted by t |--> t + 1 @@ -746,6 +750,7 @@ def an_element(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -766,6 +771,7 @@ def _call_(self, x): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -789,6 +795,7 @@ def section(self): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -796,7 +803,8 @@ def section(self): sage: m = K.coerce_map_from(k) sage: m.section() Generic map: - From: Ore Function Field in x over Finite Field in t of size 5^3 twisted by t |--> t^5 + From: Ore Function Field in x over Finite Field in t of size 5^3 + twisted by t |--> t^5 To: Finite Field in t of size 5^3 """ return ConstantOreFunctionSection(self.codomain(), self.domain()) @@ -812,12 +820,12 @@ class OreFunction_with_large_center(OreFunction): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() sage: f = K.random_element() - sage: from sage.rings.polynomial.ore_function_element import OreFunction_with_large_center sage: isinstance(f, OreFunction_with_large_center) True @@ -835,11 +843,11 @@ def reduced_trace(self, var=None): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() - sage: a = 1 / (x^2 + t) sage: tr = a.reduced_trace(); tr 3/(z^2 + 2) @@ -847,6 +855,7 @@ def reduced_trace(self, var=None): The reduced trace lies in the center of `S`, which is the fraction field of a univariate polynomial ring in the variable `z = x^3` over `GF(5)`:: + sage: # needs sage.rings.finite_rings sage: tr.parent() Fraction Field of Univariate Polynomial Ring in z over Finite Field of size 5 sage: tr.parent() is K.center() @@ -854,7 +863,7 @@ def reduced_trace(self, var=None): We can use explicit conversion to view ``tr`` as a Ore function:: - sage: K(tr) + sage: K(tr) # needs sage.rings.finite_rings (x^6 + 2)^(-1) * 3 By default, the name of the central variable is usually ``z`` (see @@ -862,13 +871,14 @@ def reduced_trace(self, var=None): for more details about this). However, the user can specify a different variable name if desired:: - sage: a.reduced_trace(var='u') + sage: a.reduced_trace(var='u') # needs sage.rings.finite_rings 3/(u^2 + 2) TESTS: We check that the reduced trace is additive:: + sage: # needs sage.rings.finite_rings sage: a = K.random_element(degree=5) sage: b = K.random_element(degree=7) sage: a.reduced_trace() + b.reduced_trace() == (a+b).reduced_trace() @@ -876,7 +886,7 @@ def reduced_trace(self, var=None): :: - sage: (a*b).reduced_trace() == (b*a).reduced_trace() + sage: (a*b).reduced_trace() == (b*a).reduced_trace() # needs sage.rings.finite_rings True """ ring = self.parent()._ring @@ -896,11 +906,11 @@ def reduced_norm(self, var=None): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() - sage: a = (x + t) / (x^2 + t^2) sage: N = a.reduced_norm(); N (z + 2)/(z^2 + 4) @@ -908,6 +918,7 @@ def reduced_norm(self, var=None): The reduced norm lies in the center of `S`, which is the fraction field of a univariate polynomial ring in the variable `z = x^3` over `GF(5)`. :: + sage: # needs sage.rings.finite_rings sage: N.parent() Fraction Field of Univariate Polynomial Ring in z over Finite Field of size 5 sage: N.parent() is K.center() @@ -915,7 +926,7 @@ def reduced_norm(self, var=None): We can use explicit conversion to view ``N`` as a skew polynomial:: - sage: K(N) + sage: K(N) # needs sage.rings.finite_rings (x^6 + 4)^(-1) * (x^3 + 2) By default, the name of the central variable is usually ``z`` (see @@ -923,13 +934,14 @@ def reduced_norm(self, var=None): for more details about this). However, the user can specify a different variable name if desired:: - sage: a.reduced_norm(var='u') + sage: a.reduced_norm(var='u') # needs sage.rings.finite_rings (u + 2)/(u^2 + 4) TESTS: We check that the reduced norm is a multiplicative map:: + sage: # needs sage.rings.finite_rings sage: a = K.random_element() sage: b = K.random_element() sage: a.reduced_norm() * b.reduced_norm() == (a*b).reduced_norm() diff --git a/src/sage/rings/polynomial/ore_function_field.py b/src/sage/rings/polynomial/ore_function_field.py index 5a50e7c22b0..6fd7d5ffc5a 100644 --- a/src/sage/rings/polynomial/ore_function_field.py +++ b/src/sage/rings/polynomial/ore_function_field.py @@ -12,7 +12,8 @@ sage: A. = R['d', der] sage: K = A.fraction_field() sage: K - Ore Function Field in d over Fraction Field of Univariate Polynomial Ring in t over Rational Field twisted by d/dt + Ore Function Field in d over Fraction Field of Univariate Polynomial Ring in t + over Rational Field twisted by d/dt The simplest way to build elements in `K` is to use the division operator over Ore polynomial rings:: @@ -57,6 +58,7 @@ the latter assumption is not fulfilled (or actually if Sage cannot invert the twisting morphism), computing the left numerator and the right denominator fails:: + sage: # needs sage.rings.function_field sage: sigma = R.hom([t^2]) sage: S. = R['x', sigma] sage: F = S.fraction_field() @@ -66,13 +68,15 @@ sage: f.left_numerator() Traceback (most recent call last): ... - NotImplementedError: inversion of the twisting morphism Ring endomorphism of Fraction Field of Univariate Polynomial Ring in t over Rational Field + NotImplementedError: inversion of the twisting morphism + Ring endomorphism of Fraction Field of Univariate Polynomial Ring in t over Rational Field Defn: t |--> t^2 On a related note, fractions are systematically simplified when the twisting morphism is bijective but they are not otherwise. As an example, compare the two following computations:: + sage: # needs sage.rings.function_field sage: P = d^2 + t*d + 1 sage: Q = d + t^2 sage: D = d^3 + t^2 + 1 @@ -83,6 +87,7 @@ sage: g (d^2 + t*d + 1)^(-1) * (d + t^2) + sage: # needs sage.rings.function_field sage: P = x^2 + t*x + 1 sage: Q = x + t^2 sage: D = x^3 + t^2 + 1 @@ -91,7 +96,8 @@ (x^2 + t*x + 1)^(-1) * (x + t^2) sage: g = (D*P)^(-1) * (D*Q) sage: g - (x^5 + t^8*x^4 + x^3 + (t^2 + 1)*x^2 + (t^3 + t)*x + t^2 + 1)^(-1) * (x^4 + t^16*x^3 + (t^2 + 1)*x + t^4 + t^2) + (x^5 + t^8*x^4 + x^3 + (t^2 + 1)*x^2 + (t^3 + t)*x + t^2 + 1)^(-1) + * (x^4 + t^16*x^3 + (t^2 + 1)*x + t^4 + t^2) sage: f == g True @@ -99,6 +105,7 @@ Basic arithmetical operations are available:: + sage: # needs sage.rings.function_field sage: f = 1 / d sage: g = 1 / (d + t) sage: u = f + g; u @@ -115,6 +122,7 @@ Of course, multiplication remains noncommutative:: + sage: # needs sage.rings.function_field sage: g * f (d^2 + t*d + 1)^(-1) sage: g^(-1) * f @@ -171,6 +179,7 @@ def __init__(self, ring, category=None): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(11^3) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) @@ -201,11 +210,11 @@ def _element_constructor_(self, *args, **kwds): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() - sage: f = K(x^2 + a, x + a^2) # indirect doctest sage: f (x + a^2)^(-1) * (x^2 + a) @@ -218,6 +227,7 @@ def _coerce_map_from_base_ring(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(11^2) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -225,7 +235,8 @@ def _coerce_map_from_base_ring(self): sage: K.coerce_map_from(k) # indirect doctest Ore Function base injection morphism: From: Finite Field in t of size 11^2 - To: Ore Function Field in x over Finite Field in t of size 11^2 twisted by t |--> t^11 + To: Ore Function Field in x over Finite Field in t of size 11^2 + twisted by t |--> t^11 """ return OreFunctionBaseringInjection(self.base_ring(), self) @@ -261,12 +272,12 @@ def _repr_(self): sage: R. = QQ[] sage: sigma = R.hom([t+1]) sage: S. = OrePolynomialRing(R, sigma) - sage: S.fraction_field() + sage: S.fraction_field() # needs sage.rings.function_field Ore Function Field in x over Fraction Field of Univariate Polynomial Ring in t over Rational Field twisted by t |--> t + 1 sage: der = R.derivation() sage: T. = OrePolynomialRing(R, der) - sage: T.fraction_field() + sage: T.fraction_field() # needs sage.rings.function_field Ore Function Field in d over Fraction Field of Univariate Polynomial Ring in t over Rational Field twisted by d/dt """ s = "Ore Function Field in %s over %s twisted by " % (self.variable_name(), self.base_ring()) @@ -286,6 +297,7 @@ def _latex_(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -321,13 +333,13 @@ def change_var(self, var): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: R. = OrePolynomialRing(k,Frob) sage: K = R.fraction_field() sage: K Ore Function Field in x over Finite Field in t of size 5^3 twisted by t |--> t^5 - sage: Ky = K.change_var('y'); Ky Ore Function Field in y over Finite Field in t of size 5^3 twisted by t |--> t^5 sage: Ky is K.change_var('y') @@ -344,13 +356,14 @@ def characteristic(self): sage: R. = QQ[] sage: sigma = R.hom([t+1]) sage: S = R['x',sigma] - sage: S.fraction_field().characteristic() + sage: S.fraction_field().characteristic() # needs sage.rings.function_field 0 + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S = k['y',Frob] - sage: S.fraction_field().characteristic() + sage: S.fraction_field().characteristic() # needs sage.rings.function_field 5 """ return self.base_ring().characteristic() @@ -369,9 +382,10 @@ def twisting_morphism(self, n=1): sage: R. = QQ[] sage: sigma = R.hom([t+1]) sage: S. = R['x', sigma] - sage: K = S.fraction_field() - sage: K.twisting_morphism() - Ring endomorphism of Fraction Field of Univariate Polynomial Ring in t over Rational Field + sage: K = S.fraction_field() # needs sage.rings.function_field + sage: K.twisting_morphism() # needs sage.rings.function_field + Ring endomorphism of + Fraction Field of Univariate Polynomial Ring in t over Rational Field Defn: t |--> t + 1 When the Ore polynomial ring is only twisted by a derivation, this @@ -379,8 +393,8 @@ def twisting_morphism(self, n=1): sage: der = R.derivation() sage: A. = R['x', der] - sage: F = A.fraction_field() - sage: F.twisting_morphism() + sage: F = A.fraction_field() # needs sage.rings.function_field + sage: F.twisting_morphism() # needs sage.rings.function_field .. SEEALSO:: @@ -404,6 +418,7 @@ def twisting_derivation(self): sage: F.twisting_derivation() d/dt + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -428,6 +443,7 @@ def gen(self, n=0): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^4) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -446,11 +462,11 @@ def gens_dict(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: R. = ZZ[] sage: sigma = R.hom([t+1]) sage: S. = OrePolynomialRing(R, sigma) sage: K = S.fraction_field() - sage: K.gens_dict() {'x': x} """ @@ -462,6 +478,7 @@ def is_finite(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: k.is_finite() True @@ -480,6 +497,7 @@ def is_exact(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -487,6 +505,7 @@ def is_exact(self): sage: K.is_exact() True + sage: # needs sage.rings.padics sage: k. = Qq(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -508,6 +527,7 @@ def is_sparse(self): EXAMPLES:: + sage: # needs sage.rings.function_field sage.rings.real_mpfr sage: R. = RR[] sage: sigma = R.hom([t+1]) sage: S. = R['x', sigma] @@ -524,6 +544,7 @@ def ngens(self): EXAMPLES:: + sage: # needs sage.rings.function_field sage.rings.real_mpfr sage: R. = RR[] sage: sigma = R.hom([t+1]) sage: S. = R['x',sigma] @@ -550,19 +571,24 @@ def random_element(self, degree=2, monic=False, *args, **kwds): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() - sage: K.random_element() # random - (x^2 + (2*t^2 + t + 1)*x + 2*t^2 + 2*t + 3)^(-1) * ((2*t^2 + 3)*x^2 + (4*t^2 + t + 4)*x + 2*t^2 + 2) + (x^2 + (2*t^2 + t + 1)*x + 2*t^2 + 2*t + 3)^(-1) + * ((2*t^2 + 3)*x^2 + (4*t^2 + t + 4)*x + 2*t^2 + 2) sage: K.random_element(monic=True) # random - (x^2 + (4*t^2 + 3*t + 4)*x + 4*t^2 + t)^(-1) * (x^2 + (2*t^2 + t + 3)*x + 3*t^2 + t + 2) + (x^2 + (4*t^2 + 3*t + 4)*x + 4*t^2 + t)^(-1) + * (x^2 + (2*t^2 + t + 3)*x + 3*t^2 + t + 2) sage: K.random_element(degree=3) # random - (x^3 + (2*t^2 + 3)*x^2 + (2*t^2 + 4)*x + t + 3)^(-1) * ((t + 4)*x^3 + (4*t^2 + 2*t + 2)*x^2 + (2*t^2 + 3*t + 3)*x + 3*t^2 + 3*t + 1) + (x^3 + (2*t^2 + 3)*x^2 + (2*t^2 + 4)*x + t + 3)^(-1) + * ((t + 4)*x^3 + (4*t^2 + 2*t + 2)*x^2 + (2*t^2 + 3*t + 3)*x + 3*t^2 + 3*t + 1) sage: K.random_element(degree=[2,5]) # random - (x^2 + (4*t^2 + 2*t + 2)*x + 4*t^2 + t + 2)^(-1) * ((3*t^2 + t + 1)*x^5 + (2*t^2 + 2*t)*x^4 + (t^2 + 2*t + 4)*x^3 + (3*t^2 + 2*t)*x^2 + (t^2 + t + 4)*x) + (x^2 + (4*t^2 + 2*t + 2)*x + 4*t^2 + t + 2)^(-1) + * ((3*t^2 + t + 1)*x^5 + (2*t^2 + 2*t)*x^4 + (t^2 + 2*t + 4)*x^3 + + (3*t^2 + 2*t)*x^2 + (t^2 + t + 4)*x) """ if isinstance(degree, list): degdenom, degnum = degree @@ -579,13 +605,13 @@ def is_commutative(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() sage: K.is_commutative() False - sage: T. = k['y', Frob^3] sage: L = T.fraction_field() sage: L.is_commutative() @@ -599,11 +625,11 @@ def is_field(self, proof=False): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field() - sage: S.is_field() False sage: K.is_field() @@ -613,6 +639,7 @@ def is_field(self, proof=False): We check that :trac:`31470` is fixed:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = k['x', k.frobenius_endomorphism()] sage: K = S.fraction_field() @@ -632,12 +659,14 @@ def fraction_field(self): sage: R. = QQ[] sage: der = R.derivation() sage: A. = R['d', der] - sage: K = A.fraction_field() - - sage: K - Ore Function Field in d over Fraction Field of Univariate Polynomial Ring in t over Rational Field twisted by d/dt + sage: K = A.fraction_field(); K + Ore Function Field in d + over Fraction Field of Univariate Polynomial Ring in t over Rational Field + twisted by d/dt sage: K.fraction_field() - Ore Function Field in d over Fraction Field of Univariate Polynomial Ring in t over Rational Field twisted by d/dt + Ore Function Field in d + over Fraction Field of Univariate Polynomial Ring in t over Rational Field + twisted by d/dt sage: K.fraction_field() is K True """ @@ -658,6 +687,7 @@ def __init__(self, embed): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = OrePolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() @@ -676,6 +706,7 @@ def _call_(self, x): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() @@ -706,13 +737,13 @@ def _richcmp_(self, right, op): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() sage: Z = K.center() sage: iota = K.coerce_map_from(Z) sage: sigma = iota.section() - sage: s = loads(dumps(sigma)) sage: s == sigma True @@ -735,6 +766,7 @@ def __init__(self, domain, codomain, ringembed): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() @@ -753,6 +785,7 @@ def _repr_(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() @@ -771,12 +804,12 @@ def _call_(self, x): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() sage: Z. = K.center() sage: iota = K.coerce_map_from(Z) - sage: iota(1/(z+1)) (x^3 + 1)^(-1) """ @@ -790,12 +823,12 @@ def _richcmp_(self, right, op): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() sage: Z = K.center() sage: iota = K.coerce_map_from(Z) - sage: i = loads(dumps(iota)) sage: i == iota True @@ -812,6 +845,7 @@ def section(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: K = S.fraction_field() @@ -834,6 +868,7 @@ def __init__(self, ring, category=None): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -874,31 +909,32 @@ def center(self, name=None, names=None, default=False): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] sage: K = S.fraction_field() - sage: Z = K.center(); Z Fraction Field of Univariate Polynomial Ring in z over Finite Field of size 5 We can pass in another variable name:: - sage: K.center(name='y') + sage: K.center(name='y') # needs sage.rings.finite_rings Fraction Field of Univariate Polynomial Ring in y over Finite Field of size 5 or use the bracket notation:: - sage: Zy. = K.center(); Zy + sage: Zy. = K.center(); Zy # needs sage.rings.finite_rings Fraction Field of Univariate Polynomial Ring in y over Finite Field of size 5 A coercion map from the center to the Ore function field is set:: - sage: K.has_coerce_map_from(Zy) + sage: K.has_coerce_map_from(Zy) # needs sage.rings.finite_rings True and pushout works:: + sage: # needs sage.rings.finite_rings sage: x.parent() Ore Polynomial Ring in x over Finite Field in t of size 5^3 twisted by t |--> t^5 sage: y.parent() @@ -910,9 +946,9 @@ def center(self, name=None, names=None, default=False): A conversion map in the reverse direction is also set:: + sage: # needs sage.rings.finite_rings sage: Zy(x^(-6) + 2) (2*y^2 + 1)/y^2 - sage: Zy(1/x^2) Traceback (most recent call last): ... @@ -925,11 +961,11 @@ def center(self, name=None, names=None, default=False): However, a variable name is given the first time this method is called, the given name become the default for the next calls:: + sage: # needs sage.rings.finite_rings sage: k. = GF(11^3) sage: phi = k.frobenius_endomorphism() sage: S. = k['X', phi] sage: K = S.fraction_field() - sage: C. = K.center() # first call sage: C Fraction Field of Univariate Polynomial Ring in u over Finite Field of size 11 @@ -939,6 +975,7 @@ def center(self, name=None, names=None, default=False): We can update the default variable name by passing in the argument ``default=True``:: + sage: # needs sage.rings.finite_rings sage: D. = K.center(default=True) sage: D Fraction Field of Univariate Polynomial Ring in v over Finite Field of size 11 diff --git a/src/sage/rings/polynomial/ore_polynomial_element.pyx b/src/sage/rings/polynomial/ore_polynomial_element.pyx index 53c14bbc23f..b1bf64dafa2 100644 --- a/src/sage/rings/polynomial/ore_polynomial_element.pyx +++ b/src/sage/rings/polynomial/ore_polynomial_element.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat r""" Univariate Ore polynomials @@ -639,7 +640,6 @@ cdef class OrePolynomial(AlgebraElement): EXAMPLES:: - sage: # needs sage.rings.finite_rings sage: R. = GF(11)[] sage: der = R.derivation() sage: S. = R['x', der] @@ -667,6 +667,7 @@ cdef class OrePolynomial(AlgebraElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -680,7 +681,7 @@ cdef class OrePolynomial(AlgebraElement): Divisibility by `0` does not make sense:: - sage: c.is_left_divisible_by(S(0)) + sage: c.is_left_divisible_by(S(0)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ZeroDivisionError: division by zero is not valid diff --git a/src/sage/rings/polynomial/ore_polynomial_ring.py b/src/sage/rings/polynomial/ore_polynomial_ring.py index 88db16fd111..eac9c0ca1e3 100644 --- a/src/sage/rings/polynomial/ore_polynomial_ring.py +++ b/src/sage/rings/polynomial/ore_polynomial_ring.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat r""" Univariate Ore polynomial rings @@ -79,10 +80,10 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): We create the Ore ring `\GF{5^3}[x, \text{Frob}]` where Frob is the Frobenius endomorphism:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() - sage: S = OrePolynomialRing(k, Frob, 'x') - sage: S + sage: S = OrePolynomialRing(k, Frob, 'x'); S Ore Polynomial Ring in x over Finite Field in a of size 5^3 twisted by a |--> a^5 In particular, observe that it is not needed to create and pass in @@ -90,8 +91,8 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): As a shortcut, we can use the square brackets notation as follow:: - sage: T. = k['x', Frob] - sage: T + sage: # needs sage.rings.finite_rings + sage: T. = k['x', Frob]; T Ore Polynomial Ring in x over Finite Field in a of size 5^3 twisted by a |--> a^5 sage: T is S True @@ -100,22 +101,23 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): in the right hand side. Indeed, the following fails (it is interpreted by Sage as a classical polynomial ring with variable name ``Frob``):: - sage: T. = k[Frob] + sage: T. = k[Frob] # needs sage.rings.finite_rings Traceback (most recent call last): ... - ValueError: variable name 'Frobenius endomorphism a |--> a^5 on Finite Field in a of size 5^3' is not alphanumeric + ValueError: variable name 'Frobenius endomorphism a |--> a^5 on + Finite Field in a of size 5^3' is not alphanumeric Note moreover that, similarly to the classical case, using the brackets notation also sets the variable:: - sage: x.parent() is S + sage: x.parent() is S # needs sage.rings.finite_rings True We are now ready to carry on computations in the Ore ring:: - sage: x*a + sage: x*a # needs sage.rings.finite_rings (2*a^2 + 4*a + 4)*x - sage: Frob(a)*x + sage: Frob(a)*x # needs sage.rings.finite_rings (2*a^2 + 4*a + 4)*x .. RUBRIC:: The case of a twisting derivation @@ -123,22 +125,23 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): We can similarly create the Ore ring of differential operators over `\QQ[t]`, namely `\QQ[t][d, \frac{d}{dt}]`:: + sage: # needs sage.rings.finite_rings sage: R. = QQ[] sage: der = R.derivation(); der d/dt - sage: A = OrePolynomialRing(R, der, 'd') - sage: A - Ore Polynomial Ring in d over Univariate Polynomial Ring in t over Rational Field twisted by d/dt + sage: A = OrePolynomialRing(R, der, 'd'); A + Ore Polynomial Ring in d over Univariate Polynomial Ring in t + over Rational Field twisted by d/dt Again, the brackets notation is available:: - sage: B. = R['d', der] - sage: A is B + sage: B. = R['d', der] # needs sage.rings.finite_rings + sage: A is B # needs sage.rings.finite_rings True and computations can be carried out:: - sage: d*t + sage: d*t # needs sage.rings.finite_rings t*d + 1 .. RUBRIC:: The combined case @@ -147,15 +150,14 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): `\sigma` and a twisting `\sigma`-derivation can be created as well as follows:: + sage: # needs sage.rings.padics sage: F. = Qq(3^2) sage: sigma = F.frobenius_endomorphism(); sigma Frobenius endomorphism on 3-adic Unramified Extension Field in u defined by x^2 + 2*x + 2 lifting u |--> u^3 on the residue field sage: der = F.derivation(3, twist=sigma); der (3 + O(3^21))*([Frob] - id) - - sage: M. = F['X', der] - sage: M + sage: M. = F['X', der]; M Ore Polynomial Ring in X over 3-adic Unramified Extension Field in u defined by x^2 + 2*x + 2 twisted by Frob and (3 + O(3^21))*([Frob] - id) @@ -163,7 +165,7 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): it already contains in it the datum of the twisting endomorphism. Actually, passing in both twisting maps results in an error:: - sage: F['X', sigma, der] + sage: F['X', sigma, der] # needs sage.rings.padics Traceback (most recent call last): ... ValueError: variable name 'Frobenius endomorphism ...' is not alphanumeric @@ -201,6 +203,7 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): In Sage, there is exactly one Ore polynomial ring for each quadruple (base ring, twisting morphism, twisting derivation, name of the variable):: + sage: # needs sage.rings.finite_rings sage: k. = GF(7^3) sage: Frob = k.frobenius_endomorphism() sage: S = k['x', Frob] @@ -210,45 +213,45 @@ class OrePolynomialRing(UniqueRepresentation, Algebra): Rings with different variables names are different:: - sage: S is k['y', Frob] + sage: S is k['y', Frob] # needs sage.rings.finite_rings False Similarly, varying the twisting morphisms yields to different Ore rings (expect when the morphism coincide):: - sage: S is k['x', Frob^2] + sage: S is k['x', Frob^2] # needs sage.rings.finite_rings False - sage: S is k['x', Frob^3] + sage: S is k['x', Frob^3] # needs sage.rings.finite_rings False - sage: S is k['x', Frob^4] + sage: S is k['x', Frob^4] # needs sage.rings.finite_rings True TESTS: You must specify a variable name:: - sage: SkewPolynomialRing(k, Frob) + sage: SkewPolynomialRing(k, Frob) # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: you must specify the name of the variable Multivariate Ore polynomial rings are not supported:: - sage: S = OrePolynomialRing(k, Frob,names=['x','y']) + sage: S = OrePolynomialRing(k, Frob,names=['x','y']) # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: multivariate Ore polynomials rings not supported Sparse Ore polynomial rings are not implemented:: - sage: S = SkewPolynomialRing(k, Frob, names='x', sparse=True) + sage: S = SkewPolynomialRing(k, Frob, names='x', sparse=True) # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: sparse Ore polynomial rings are not implemented Saving and loading of polynomial rings works:: - sage: loads(dumps(S)) is S + sage: loads(dumps(S)) is S # needs sage.rings.finite_rings True .. TODO:: @@ -294,6 +297,7 @@ def __classcall_private__(cls, base_ring, twist=None, names=None, sparse=False, In certain situations (e.g. when the twisting morphism is the Frobenius over a finite field), even more specialized classes are used:: + sage: # needs sage.rings.finite_rings sage: k. = GF(7^5) sage: Frob = k.frobenius_endomorphism(2) sage: S. = SkewPolynomialRing(k, Frob) @@ -304,6 +308,7 @@ def __classcall_private__(cls, base_ring, twist=None, names=None, sparse=False, `None` ot the identity, a regular `PolynomialRing` is created, unless specified otherwise:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^2) sage: Frob = k.frobenius_endomorphism(2) sage: Frob.is_identity() @@ -424,12 +429,12 @@ def __reduce__(self): r""" TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(11^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: loads(dumps(S)) is S True - sage: der = k.derivation(a, twist=Frob) sage: T. = k['y', der] sage: loads(dumps(T)) is T @@ -561,7 +566,7 @@ def _coerce_map_from_(self, P): True sage: S.has_coerce_map_from(ZZ) True - sage: S.has_coerce_map_from(GF(5^3)) + sage: S.has_coerce_map_from(GF(5^3)) # needs sage.rings.finite_rings False sage: S.coerce_map_from(ZZ) @@ -625,6 +630,7 @@ def _latex_(self) -> str: EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -658,6 +664,7 @@ def change_var(self, var): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: R. = OrePolynomialRing(k,Frob); R @@ -685,6 +692,7 @@ def characteristic(self): sage: R['x',sigma].characteristic() 0 + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: k['y',Frob].characteristic() @@ -720,6 +728,7 @@ def twisting_morphism(self, n=1): If ``n`` in negative, Sage tries to compute the inverse of the twisting morphism:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: T. = k['y',Frob] @@ -735,7 +744,8 @@ def twisting_morphism(self, n=1): sage: T.twisting_morphism(-1) Traceback (most recent call last): ... - NotImplementedError: inverse not implemented for morphisms of Fraction Field of Univariate Polynomial Ring in t over Rational Field + NotImplementedError: inverse not implemented for morphisms of + Fraction Field of Univariate Polynomial Ring in t over Rational Field When the Ore polynomial ring is only twisted by a derivation, this method returns nothing:: @@ -743,12 +753,14 @@ def twisting_morphism(self, n=1): sage: der = R.derivation() sage: A. = R['x', der] sage: A - Ore Polynomial Ring in x over Univariate Polynomial Ring in t over Rational Field twisted by d/dt + Ore Polynomial Ring in x over Univariate Polynomial Ring in t + over Rational Field twisted by d/dt sage: A.twisting_morphism() Here is an example where the twisting morphism is automatically inferred from the derivation:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(1, twist=Frob) @@ -785,6 +797,7 @@ def twisting_derivation(self): sage: A.twisting_derivation() d/dt + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -811,7 +824,8 @@ def gen(self, n=0): sage: R. = QQ[] sage: sigma = R.hom([t+1]) sage: S. = R['x',sigma]; S - Ore Polynomial Ring in x over Univariate Polynomial Ring in t over Rational Field twisted by t |--> t + 1 + Ore Polynomial Ring in x over Univariate Polynomial Ring in t + over Rational Field twisted by t |--> t + 1 sage: y = S.gen(); y x sage: y == x @@ -861,6 +875,7 @@ def is_finite(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: k.is_finite() True @@ -879,6 +894,7 @@ def is_exact(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -886,9 +902,8 @@ def is_exact(self): True sage: S.base_ring().is_exact() True - sage: R. = k[[]] - sage: sigma = R.hom([u+u^2]) + sage: sigma = R.hom([u + u^2]) sage: T. = R['y', sigma] sage: T.is_exact() False @@ -955,6 +970,7 @@ def random_element(self, degree=(-1, 2), monic=False, *args, **kwds): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -965,6 +981,7 @@ def random_element(self, degree=(-1, 2), monic=False, *args, **kwds): Use ``degree`` to obtain polynomials of higher degree:: + sage: # needs sage.rings.finite_rings sage: p = S.random_element(degree=5) # random (t^2 + 3*t)*x^5 + (4*t + 4)*x^3 + (4*t^2 + 4*t)*x^2 + (2*t^2 + 1)*x + 3 sage: p.degree() == 5 @@ -974,7 +991,7 @@ def random_element(self, degree=(-1, 2), monic=False, *args, **kwds): integer will be chosen between the first and second element of the tuple as the degree, both inclusive:: - sage: S.random_element(degree=(2,7)) # random + sage: S.random_element(degree=(2,7)) # random # needs sage.rings.finite_rings (3*t^2 + 1)*x^4 + (4*t + 2)*x^3 + (4*t + 1)*x^2 + (t^2 + 3*t + 3)*x + 3*t^2 + 2*t + 2 @@ -983,14 +1000,14 @@ def random_element(self, degree=(-1, 2), monic=False, *args, **kwds): If the first tuple element is greater than the second, a ``ValueError`` is raised:: - sage: S.random_element(degree=(5,4)) + sage: S.random_element(degree=(5,4)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: first degree argument must be less or equal to the second There is no monic polynomial of negative degree:: - sage: S.random_element(degree=-1, monic=True) + sage: S.random_element(degree=-1, monic=True) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: there is no monic polynomial with negative degree @@ -1040,6 +1057,7 @@ def random_irreducible(self, degree=2, monic=True, *args, **kwds): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -1068,12 +1086,12 @@ def is_commutative(self) -> bool: EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: S.is_commutative() False - sage: T. = k['y', Frob^3] sage: T.is_commutative() True @@ -1083,7 +1101,6 @@ def is_commutative(self) -> bool: sage: A. = R['d', der] sage: A.is_commutative() False - sage: B. = R['b', 5*der] sage: B.is_commutative() True @@ -1097,6 +1114,7 @@ def is_field(self, proof=False) -> bool: EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] @@ -1107,6 +1125,7 @@ def is_field(self, proof=False) -> bool: We check that :trac:`31470` is fixed:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: S. = k['x', k.frobenius_endomorphism()] sage: zero_matrix(S, 2).row(0) @@ -1121,12 +1140,12 @@ def fraction_field(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x', Frob] sage: K = S.fraction_field(); K Ore Function Field in x over Finite Field in a of size 5^3 twisted by a |--> a^5 - sage: f = 1/(x + a); f (x + a)^(-1) sage: f.parent() is K @@ -1138,8 +1157,8 @@ def fraction_field(self): sage: der = R.derivation() sage: A. = R['d', der] sage: A.fraction_field() - Ore Function Field in d over Fraction Field of Univariate Polynomial Ring in t over Rational Field twisted by d/dt - + Ore Function Field in d over Fraction Field of Univariate Polynomial Ring in t + over Rational Field twisted by d/dt sage: f = t/d; f (d - 1/t)^(-1) * t sage: f*d @@ -1171,6 +1190,7 @@ def _pushout_(self, other): TESTS:: + sage: # needs sage.rings.finite_rings sage: from sage.categories.pushout import pushout sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 94d6aac82b5..de438cb122e 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -5451,6 +5451,8 @@ cdef class Polynomial(CommutativePolynomial): if self.degree() <= 1: return R.fraction_field() + from sage.rings.number_field.number_field import is_NumberField, NumberField + if is_IntegerRing(R): from sage.rings.number_field.number_field import NumberField return NumberField(self, names) @@ -6926,7 +6928,7 @@ cdef class Polynomial(CommutativePolynomial): sage: S. = PolynomialRing(R,'y') sage: p = ((1/b^2*d^2+1/a)*x*y^2+a*b/c*y+e+x^2) sage: q = -4*c^2*y^3+1 - sage: p.resultant(q) # needs sage.libs.pari + sage: p.resultant(q) # needs sage.libs.pari sage.modules (16*c^4)*x^6 + (48*c^4)*e*x^4 + (1/(b^6)*d^6 + 3/(a*b^4)*d^4 + (-12*a^3*b*c + 3)/(a^2*b^2)*d^2 + (-12*a^3*b*c + 1)/(a^3))*x^3 + (48*c^4)*e^2*x^2 + ((-12*a*c)/b*d^2*e + (-12*b*c)*e)*x + (16*c^4)*e^3 + (4*a^3*b^3)/c @@ -6938,7 +6940,7 @@ cdef class Polynomial(CommutativePolynomial): sage: R. = PolynomialRing(CDF) sage: f = R(1 - I*x + (0.5)*x^2 + (1.7)*x^3) sage: g = f.derivative() - sage: f.resultant(g) + sage: f.resultant(g) # needs sage.modules 133.92599999999996 + 37.56999999999999*I """ variable = self.variable_name() @@ -7730,7 +7732,7 @@ cdef class Polynomial(CommutativePolynomial): sage: f = x^3 - 1 sage: f.roots() [(1, 1)] - sage: f.roots(ring=CC) # ... - low order bits slightly different on ppc # needs sage.rings.real_mpfr + sage: f.roots(ring=CC) # ... - low order bits slightly different on ppc # needs sage.rings.real_mpfr [(1.00000000000000, 1), (-0.500000000000000 - 0.86602540378443...*I, 1), (-0.500000000000000 + 0.86602540378443...*I, 1)] @@ -8151,11 +8153,11 @@ cdef class Polynomial(CommutativePolynomial): sage: x = polygen(QQ) sage: p = x + bigc - sage: p.roots(ring=RR, algorithm='numpy') # needs numpy + sage: p.roots(ring=RR, algorithm='numpy') # needs numpy sage.rings.real_mpfr Traceback (most recent call last): ... LinAlgError: Array must not contain infs or NaNs - sage: p.roots(ring=RR, algorithm='pari') # needs sage.libs.pari + sage: p.roots(ring=RR, algorithm='pari') # needs sage.libs.pari sage.rings.real_mpfr [(-3.50746621104340e451, 1)] sage: p.roots(ring=AA) # needs sage.rings.number_field [(-3.5074662110434039?e451, 1)] diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 0468efd8c68..0713a334afb 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -41,6 +41,7 @@ from . import polynomial_element import sage.rings.rational_field +from sage.arith.misc import crt from sage.rings.ring import Field, IntegralDomain, CommutativeRing from sage.misc.cachefunc import cached_method @@ -1275,7 +1276,7 @@ def random_element(self, *args, **kwds): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: F1. = GF(2^7) sage: P1. = F1[] sage: F2 = F1.extension(x^2 + x + 1, 'u') @@ -1539,7 +1540,7 @@ def S_class_group(self, S, proof=True): for ideal_gen in clgp_gen.gens(): rel_ideal_gen = back_to_rel(phi(ideal_gen)) prod_ideal_gen = [0]*i + [rel_ideal_gen.lift()] + [0]*(n - i - 1) - poly_ideal_gen = self(sage.arith.all.crt(prod_ideal_gen, moduli)) + poly_ideal_gen = self(crt(prod_ideal_gen, moduli)) ideal_gens.append(poly_ideal_gen) clgp_gens.append((tuple(ideal_gens), gen_order)) @@ -1755,7 +1756,7 @@ def S_units(self, S, proof=True): mul_order = unit.multiplicative_order() rel_unit = back_to_rel(phi(unit)) prod_unit = [1]*i + [rel_unit.lift()] + [1]*(n - i - 1) - poly_unit = self(sage.arith.all.crt(prod_unit, moduli)) + poly_unit = self(crt(prod_unit, moduli)) units.append((poly_unit, mul_order)) return units @@ -1897,7 +1898,7 @@ def selmer_generators(self, S, m, proof=True): for gen in component_selmer_groups[isos[i][1]]: rel_gen = back_to_rel(phi(gen)) prod_gen = [1]*i + [rel_gen.lift()] + [1]*(n - i - 1) - poly_gen = self(sage.arith.all.crt(prod_gen, moduli)) + poly_gen = self(crt(prod_gen, moduli)) gens.append(poly_gen) return gens diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index d99f0d3b98c..4b752edc8b0 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -2109,7 +2109,7 @@ cdef class Polynomial_rational_flint(Polynomial): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.groups sage.libs.pari sage: R. = QQ[] sage: f = x^4 - 17*x^3 - 2*x + 1 sage: G = f.galois_group(); G @@ -2130,7 +2130,7 @@ cdef class Polynomial_rational_flint(Polynomial): sage: f = x^4 - 17*x^3 - 2*x + 1 sage: G = f.galois_group(pari_group=True); G PARI group [24, -1, 5, "S4"] of degree 4 - sage: PermutationGroup(G) + sage: PermutationGroup(G) # needs sage.groups Transitive group number 5 of degree 4 You can use KASH or GAP to compute Galois groups as well. The advantage is diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 8801ed6709c..858df388caf 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -703,7 +703,7 @@ def _coerce_map_from_base_ring(self): To: Univariate Polynomial Ring in x over Rational Field sage: R.coerce_map_from(GF(7)) """ - from .polynomial_element import PolynomialBaseringInjection + from sage.rings.polynomial.polynomial_element import PolynomialBaseringInjection return PolynomialBaseringInjection(self.base_ring(), self) diff --git a/src/sage/rings/polynomial/skew_polynomial_element.pyx b/src/sage/rings/polynomial/skew_polynomial_element.pyx index 3ea7f87bddf..b103ac37508 100644 --- a/src/sage/rings/polynomial/skew_polynomial_element.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_element.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat r""" Univariate skew polynomials @@ -90,6 +91,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -152,6 +154,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -161,18 +164,17 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): x^5 + (2*t^2 + 4)*x^4 + (t^2 + 2)*x^3 + 2*x^2 + (4*t^2 + 2)*x + 2*t^2 + 4*t + 4 sage: b == a * a * a * a * a True - sage: modulus = x^3 + t*x^2 + (t+3)*x - 2 sage: br = a.right_power_mod(5, modulus); br (t + 1)*x^2 + (2*t^2 + t + 1)*x + 2*t^2 + 4*t + 2 sage: br == b % modulus True - sage: a.right_power_mod(100, modulus) (2*t^2 + 3)*x^2 + (t^2 + 4*t + 2)*x + t^2 + 2*t + 1 Negative exponents are supported: + sage: # needs sage.rings.finite_rings sage: a^(-5) (x^5 + (2*t^2 + 4)*x^4 + (t^2 + 2)*x^3 + 2*x^2 + (4*t^2 + 2)*x + 2*t^2 + 4*t + 4)^(-1) sage: b * a^(-5) @@ -180,7 +182,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): However, they cannot be combined with modulus:: - sage: a.right_power_mod(-10, modulus) + sage: a.right_power_mod(-10, modulus) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: modulus cannot be combined with negative exponent @@ -245,6 +247,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -317,6 +320,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: T. = k['x',Frob] @@ -341,6 +345,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: T. = k['x',Frob] @@ -403,10 +408,12 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): sage: b = a.conjugate(-1) Traceback (most recent call last): ... - NotImplementedError: inverse not implemented for morphisms of Fraction Field of Univariate Polynomial Ring in t over Rational Field + NotImplementedError: inverse not implemented for morphisms of + Fraction Field of Univariate Polynomial Ring in t over Rational Field Here is a working example:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: T. = k['y',Frob] @@ -441,6 +448,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -566,6 +574,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] @@ -602,6 +611,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): TESTS:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S. = k['x',Frob] diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx index 99b3b7e64c9..1a176288395 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.rings.finite_rings r""" Univariate dense skew polynomials over finite fields diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx b/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx index 968c45c8453..367ff8713ba 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx @@ -1,4 +1,4 @@ -# sage.doctest: needs sage.rings.finite_rings +# sage.doctest: needs sage.combinat sage.rings.finite_rings r""" Univariate dense skew polynomials over a field with a finite order automorphism diff --git a/src/sage/rings/polynomial/skew_polynomial_ring.py b/src/sage/rings/polynomial/skew_polynomial_ring.py index 2ae48556880..9d3ea67ee46 100644 --- a/src/sage/rings/polynomial/skew_polynomial_ring.py +++ b/src/sage/rings/polynomial/skew_polynomial_ring.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat r""" Univariate skew polynomial rings @@ -438,8 +439,6 @@ def _richcmp_(self, right, op): sage: Z = S.center() sage: iota = S.convert_map_from(Z) sage: sigma = iota.section() - - sage: # needs sage.rings.finite_rings sage: s = loads(dumps(sigma)) sage: s == sigma True @@ -517,8 +516,7 @@ def _call_(self, x): sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: Z. = S.center() sage: iota = S.convert_map_from(Z) - - sage: iota(z) # needs sage.rings.finite_rings + sage: iota(z) x^3 """ k = self._codomain.base_ring() @@ -539,8 +537,6 @@ def _richcmp_(self, right, op): sage: S. = SkewPolynomialRing(k, k.frobenius_endomorphism()) sage: Z = S.center() sage: iota = S.convert_map_from(Z) - - sage: # needs sage.rings.finite_rings sage: i = loads(dumps(iota)) sage: i == iota True @@ -596,8 +592,7 @@ def __init__(self, base_ring, morphism, derivation, name, sparse, category=None) Ore Polynomial Ring in x over Finite Field in t of size 5^3 twisted by t |--> t^5 sage: S.category() Category of algebras over Finite Field in t of size 5^3 - - sage: TestSuite(S).run() # needs sage.rings.finite_rings + sage: TestSuite(S).run() We check that a call to the method :meth:`sage.rings.polynomial.skew_polynomial_finite_order.SkewPolynomial_finite_order.is_central` diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index 00209396614..ec783625140 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -88,7 +88,7 @@ However, when we compute the Groebner basis of I (defined over `\ZZ`), we note that there is a certain integer in the ideal which is not 1:: - sage: gb = d_basis(I); gb + sage: gb = d_basis(I); gb # needs sage.libs.singular [z ..., y ..., x ..., 282687803443] Now for each prime `p` dividing this integer 282687803443, the Groebner @@ -98,19 +98,19 @@ sage: factor(282687803443) 101 * 103 * 27173681 - sage: I.change_ring(P.change_ring(GF(101))).groebner_basis() + sage: I.change_ring(P.change_ring(GF(101))).groebner_basis() # needs sage.libs.singular [z - 33, y + 48, x + 19] - sage: I.change_ring(P.change_ring(GF(103))).groebner_basis() + sage: I.change_ring(P.change_ring(GF(103))).groebner_basis() # needs sage.libs.singular [z - 18, y + 8, x + 39] - sage: I.change_ring(P.change_ring(GF(27173681))).groebner_basis() # needs sage.rings.finite_rings + sage: I.change_ring(P.change_ring(GF(27173681))).groebner_basis() # needs sage.libs.singular sage.rings.finite_rings [z + 10380032, y + 3186055, x - 536027] Of course, modulo any other prime the Groebner basis is trivial so there are no other solutions. For example:: - sage: I.change_ring(P.change_ring(GF(3))).groebner_basis() + sage: I.change_ring(P.change_ring(GF(3))).groebner_basis() # needs sage.libs.singular [1] AUTHOR: diff --git a/src/sage/rings/power_series_mpoly.pyx b/src/sage/rings/power_series_mpoly.pyx index d11eec97269..2846d563a97 100644 --- a/src/sage/rings/power_series_mpoly.pyx +++ b/src/sage/rings/power_series_mpoly.pyx @@ -7,6 +7,12 @@ from sage.rings.polynomial.multi_polynomial_ring_base import is_MPolynomialRing from sage.rings import power_series_poly +try: + from sage.libs.pari.all import PariError +except ImportError: + PariError = () + + cdef class PowerSeries_mpoly(PowerSeries): def __init__(self, parent, f=0, prec=infinity, int check=1, is_gen=0): diff --git a/src/sage/rings/power_series_poly.pyx b/src/sage/rings/power_series_poly.pyx index c651fe03d02..8f2a86efba9 100644 --- a/src/sage/rings/power_series_poly.pyx +++ b/src/sage/rings/power_series_poly.pyx @@ -7,7 +7,12 @@ The class ``PowerSeries_poly`` provides additional methods for univariate power from sage.rings.power_series_ring_element cimport PowerSeries from sage.structure.element cimport Element from sage.rings.infinity import infinity -from sage.libs.pari.all import pari_gen, PariError + +try: + from sage.libs.pari.all import pari_gen, PariError +except ImportError: + pari_gen = () + PariError = () cdef class PowerSeries_poly(PowerSeries): diff --git a/src/sage/rings/power_series_ring.py b/src/sage/rings/power_series_ring.py index 0349bfbe373..739525a9974 100644 --- a/src/sage/rings/power_series_ring.py +++ b/src/sage/rings/power_series_ring.py @@ -152,7 +152,6 @@ from sage.rings.polynomial.multi_polynomial_ring_base import is_MPolynomialRing from sage.rings.polynomial.polynomial_ring import is_PolynomialRing from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.power_series_pari import PowerSeries_pari from sage.structure.category_object import normalize_names from sage.structure.element import Expression, parent from sage.structure.nonexact import Nonexact @@ -168,6 +167,13 @@ from sage.categories.complete_discrete_valuation import CompleteDiscreteValuationRings +try: + from .laurent_series_ring import LaurentSeriesRing + from .laurent_series_ring_element import LaurentSeries +except ImportError: + LaurentSeriesRing = () + LaurentSeries = () + def PowerSeriesRing(base_ring, name=None, arg2=None, names=None, sparse=False, default_prec=None, order='negdeglex', @@ -537,11 +543,11 @@ def __init__(self, base_ring, name=None, default_prec=None, sparse=False, ValueError: default_prec (= -5) must be non-negative """ - from sage.rings.finite_rings.finite_field_pari_ffelt import ( - FiniteField_pari_ffelt, - ) - if implementation is None: + try: + from sage.rings.finite_rings.finite_field_pari_ffelt import FiniteField_pari_ffelt + except ImportError: + FiniteField_pari_ffelt = () if isinstance(base_ring, FiniteField_pari_ffelt): implementation = 'pari' else: @@ -571,6 +577,7 @@ def __init__(self, base_ring, name=None, default_prec=None, sparse=False, assert is_MPolynomialRing(self.__mpoly_ring) self.Element = power_series_mpoly.PowerSeries_mpoly elif implementation == 'pari': + from .power_series_pari import PowerSeries_pari self.Element = PowerSeries_pari else: raise ValueError('unknown power series implementation: %r' % implementation) @@ -579,7 +586,7 @@ def __init__(self, base_ring, name=None, default_prec=None, sparse=False, category=getattr(self, '_default_category', _CommutativeRings)) Nonexact.__init__(self, default_prec) - if self.Element is PowerSeries_pari: + if implementation == 'pari': self.__generator = self.element_class(self, R.gen().__pari__()) else: self.__generator = self.element_class(self, R.gen(), is_gen=True) @@ -805,7 +812,7 @@ def _element_constructor_(self, f, prec=infinity, check=True): if prec >= f.prec(): return f f = f.truncate(prec) - elif isinstance(f, laurent_series_ring_element.LaurentSeries) and f.parent().power_series_ring() is self: + elif isinstance(f, LaurentSeries) and f.parent().power_series_ring() is self: return self(f.power_series(), prec, check=check) elif isinstance(f, MagmaElement) and str(f.Type()) == 'RngSerPowElt': v = sage_eval(f.Eltseq()) @@ -953,9 +960,8 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): return True # this is allowed. if base_map is None and not codomain.has_coerce_map_from(self.base_ring()): return False - from .laurent_series_ring import is_LaurentSeriesRing v = im_gens[0] - if is_PowerSeriesRing(codomain) or is_LaurentSeriesRing(codomain): + if is_PowerSeriesRing(codomain) or isinstance(codomain, LaurentSeriesRing): try: return v.valuation() > 0 or v.is_nilpotent() except NotImplementedError: @@ -1270,8 +1276,10 @@ def laurent_series_ring(self): try: return self.__laurent_series_ring except AttributeError: - self.__laurent_series_ring = laurent_series_ring.LaurentSeriesRing( - self.base_ring(), self.variable_name(), default_prec=self.default_prec(), sparse=self.is_sparse()) + from .laurent_series_ring import LaurentSeriesRing + + self.__laurent_series_ring = LaurentSeriesRing( + self.base_ring(), self.variable_name(), default_prec=self.default_prec(), sparse=self.is_sparse()) return self.__laurent_series_ring diff --git a/src/sage/rings/puiseux_series_ring_element.pyx b/src/sage/rings/puiseux_series_ring_element.pyx index 39edce35bc9..3f50fb45e2e 100644 --- a/src/sage/rings/puiseux_series_ring_element.pyx +++ b/src/sage/rings/puiseux_series_ring_element.pyx @@ -106,7 +106,6 @@ from sage.arith.functions import lcm from sage.arith.misc import gcd from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ -from sage.rings.complex_mpfr import ComplexField from sage.rings.infinity import infinity from sage.rings.laurent_series_ring_element cimport LaurentSeries from sage.structure.element cimport (Element, AlgebraElement) @@ -308,6 +307,7 @@ cdef class PuiseuxSeries(AlgebraElement): if isinstance(x, int): x = ZZ(x) elif isinstance(x, float): + from sage.rings.complex_mpfr import ComplexField x = ComplexField()(x) t = x.nth_root(self._e) p = self._l.__u.polynomial() diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 5fc675ffd83..5f28c7b8302 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -1525,7 +1525,7 @@ def _factor_univariate_polynomial(self, f): (12) * (x - 0.5773502691896258?) * (x + 0.5773502691896258?) sage: AA._factor_univariate_polynomial(12*x^2 + 4) (12) * (x^2 + 0.3333333333333334?) - sage: AA._factor_univariate_polynomial(EllipticCurve('11a1').change_ring(AA).division_polynomial(5)) # needs sage.schemes + sage: AA._factor_univariate_polynomial(EllipticCurve('11a1').change_ring(AA).division_polynomial(5)) # needs sage.schemes (5) * (x - 16.00000000000000?) * (x - 5.000000000000000?) * (x - 1.959674775249769?) * (x + 2.959674775249769?) * (x^2 - 2.854101966249685?*x + 15.47213595499958?) * (x^2 + 1.909830056250526?*x + 1.660606461254312?) * (x^2 + 3.854101966249685?*x + 6.527864045000421?) * (x^2 + 13.09016994374948?*x + 93.33939353874569?) """ diff --git a/src/sage/rings/qqbar_decorators.py b/src/sage/rings/qqbar_decorators.py index c0505b11e8b..e1e3b908c8c 100644 --- a/src/sage/rings/qqbar_decorators.py +++ b/src/sage/rings/qqbar_decorators.py @@ -58,6 +58,7 @@ def wrapper(*args, **kwds): Check that :trac:`29468` is fixed:: + sage: # needs sage.libs.singular sage: J = QQbar['x,y'].ideal('x^2 - y') sage: type(J.groebner_basis()) diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 150e4a523bd..b970456ed9f 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -65,30 +65,41 @@ from cysignals.signals cimport sig_on, sig_off import operator import fractions +import sage.rings.rational_field + from sage.arith.long cimport integer_check_long_py +from sage.categories.morphism cimport Morphism +from sage.categories.map cimport Map from sage.cpython.string cimport char_to_str, str_to_bytes - +from sage.libs.gmp.pylong cimport mpz_set_pylong +from sage.rings.integer cimport Integer, smallInteger +from sage.rings.integer_ring import ZZ +from sage.structure.coerce cimport coercion_model, is_numpy_type +from sage.structure.element cimport Element +from sage.structure.parent cimport Parent from sage.structure.richcmp cimport rich_to_bool_sgn -import sage.rings.rational_field -cimport sage.rings.integer as integer -from sage.rings.integer cimport Integer -from sage.rings.integer_ring import ZZ +RealNumber_classes = () -from sage.structure.coerce cimport is_numpy_type +def _register_real_number_class(cls): + r""" + Register ``cls``. -from sage.libs.gmp.pylong cimport mpz_set_pylong + This is called by ``sage.rings.real_mpfr``, to avoid a cyclic import. + """ + global RealNumber_classes + RealNumber_classes += (cls,) -from sage.structure.coerce cimport coercion_model -from sage.structure.element cimport Element -from sage.structure.parent cimport Parent -from sage.categories.morphism cimport Morphism -from sage.categories.map cimport Map + +RealDouble_classes = (float,) +try: + from sage.rings.real_double import RealDoubleElement + RealDouble_classes += (RealDoubleElement,) +except ImportError: + pass -import sage.rings.real_mpfr -import sage.rings.real_double from libc.stdint cimport uint64_t from sage.libs.gmp.binop cimport mpq_add_z, mpq_mul_z, mpq_div_zz @@ -349,7 +360,7 @@ cpdef rational_power_parts(a, Rational b, factor_limit=10**5) noexcept: c = integer_rational_power(a, b) if c is not None: - return c, integer.smallInteger(1) + return c, smallInteger(1) numer, denom = b.numerator(), b.denominator() if a < factor_limit*factor_limit: @@ -357,7 +368,7 @@ cpdef rational_power_parts(a, Rational b, factor_limit=10**5) noexcept: else: from sage.rings.factorint import factor_trial_division f = factor_trial_division(a, factor_limit) - c = integer.smallInteger(1) + c = smallInteger(1) # The sign is not handled by the loop below. We don't want to # simplify (-1)^(2/3) to 1 (see Issue #15605), so we always move # the sign over to d. Note that the case (-1)^2 is already @@ -367,7 +378,7 @@ cpdef rational_power_parts(a, Rational b, factor_limit=10**5) noexcept: d = c else: # d = -1 - d = integer.smallInteger(-1) + d = smallInteger(-1) for p, e in f: c *= p**((e // denom)*numer) d *= p**(e % denom) @@ -1454,7 +1465,7 @@ cdef class Rational(sage.structure.element.FieldElement): True sage: e.norm() 3/5 - sage: 7.is_norm(K) + sage: 7.is_norm(K) # needs sage.groups Traceback (most recent call last): ... NotImplementedError: is_norm is not implemented unconditionally @@ -2755,7 +2766,7 @@ cdef class Rational(sage.structure.element.FieldElement): sage: (-1/6).sign() -1 """ - return integer.smallInteger(mpq_sgn(self.value)) + return smallInteger(mpq_sgn(self.value)) def mod_ui(Rational self, unsigned long int n): """ @@ -3107,7 +3118,9 @@ cdef class Rational(sage.structure.element.FieldElement): """ if self.is_zero(): raise ArithmeticError("Support of 0 not defined.") - return sage.arith.all.prime_factors(self) + from sage.arith.misc import prime_factors + + return prime_factors(self) def log(self, m=None, prec=None): r""" diff --git a/src/sage/rings/rational_field.py b/src/sage/rings/rational_field.py index 341c0d536d0..8e54c459651 100644 --- a/src/sage/rings/rational_field.py +++ b/src/sage/rings/rational_field.py @@ -18,9 +18,9 @@ sage: RealField(9).pi() # needs sage.rings.real_mpfr 3.1 - sage: QQ(RealField(9).pi()) # needs sage.rings.real_mpfr + sage: QQ(RealField(9).pi()) # needs sage.rings.real_interval_field sage.rings.real_mpfr 22/7 - sage: QQ(RealField().pi()) # needs sage.rings.real_mpfr + sage: QQ(RealField().pi()) # needs sage.rings.real_interval_field sage.rings.real_mpfr 245850922/78256779 sage: QQ(35) 35 diff --git a/src/sage/rings/real_double.pyx b/src/sage/rings/real_double.pyx index 19c9501bcf8..dc854c61e63 100644 --- a/src/sage/rings/real_double.pyx +++ b/src/sage/rings/real_double.pyx @@ -50,6 +50,7 @@ from sage.cpython.python_debug cimport if_Py_TRACE_REFS_then_PyObject_INIT import math +import sage.arith.misc import sage.rings.integer import sage.rings.rational @@ -1955,7 +1956,7 @@ cdef class RealDoubleElement(FieldElement): sage: r.algebraic_dependency(5) # needs sage.libs.pari x^2 - 2 """ - return sage.arith.all.algdep(self,n) + return sage.arith.misc.algdep(self,n) algdep = algebraic_dependency diff --git a/src/sage/rings/real_field.py b/src/sage/rings/real_field.py index 6f424b90fc8..7b8e17eb5b9 100644 --- a/src/sage/rings/real_field.py +++ b/src/sage/rings/real_field.py @@ -35,11 +35,11 @@ def create_RealField(prec=53, type="MPFR", rnd="RNDN", sci_not=0): sage: from sage.rings.real_field import create_RealField sage: create_RealField(30) Real Field with 30 bits of precision - sage: create_RealField(20, 'RDF') # ignores precision + sage: create_RealField(20, 'RDF') # ignores precision Real Double Field - sage: create_RealField(60, 'Interval') + sage: create_RealField(60, 'Interval') # needs sage.rings.real_interval_field Real Interval Field with 60 bits of precision - sage: create_RealField(40, 'RLF') # ignores precision + sage: create_RealField(40, 'RLF') # ignores precision # needs sage.rings.real_interval_field Real Lazy Field """ if type == "RDF": diff --git a/src/sage/rings/real_lazy.pyx b/src/sage/rings/real_lazy.pyx index e765cdfe801..a426a922d6d 100644 --- a/src/sage/rings/real_lazy.pyx +++ b/src/sage/rings/real_lazy.pyx @@ -1,4 +1,4 @@ -# sage.doctest: needs sage.rings.real_mpfr +# sage.doctest: needs sage.rings.real_interval_field sage.rings.real_mpfr """ Lazy real and complex numbers @@ -50,12 +50,16 @@ from sage.rings.integer import Integer cdef QQ, RR, CC, RealField, ComplexField from sage.rings.rational_field import QQ -try: - from sage.rings.real_mpfr import RR, RealField - from sage.rings.complex_mpfr import ComplexField - from sage.rings.cc import CC -except ImportError: - pass +cdef late_import(): + global RR, CC, RealField, ComplexField + if CC is not None: + return + try: + from sage.rings.real_mpfr import RR, RealField + from sage.rings.complex_mpfr import ComplexField + from sage.rings.cc import CC + except ImportError: + pass cdef _QQx = None @@ -1611,6 +1615,9 @@ cdef class LazyAlgebraic(LazyFieldElement): if self._poly.degree() == 2: c, b, a = self._poly.list() self._quadratic_disc = b*b - 4*a*c + + late_import() + if isinstance(parent, RealLazyField_class): if not self._poly.number_of_real_roots(): raise ValueError("%s has no real roots" % self._poly) diff --git a/src/sage/rings/real_mpfi.pyx b/src/sage/rings/real_mpfi.pyx index 58e3d8de737..47c24f7261b 100644 --- a/src/sage/rings/real_mpfi.pyx +++ b/src/sage/rings/real_mpfi.pyx @@ -258,6 +258,8 @@ from cpython.object cimport Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE from cysignals.signals cimport sig_on, sig_off +import sage.arith.misc + from sage.libs.gmp.mpz cimport * from sage.libs.mpfr cimport * from sage.libs.mpfi cimport * @@ -5035,7 +5037,7 @@ cdef class RealIntervalFieldElement(RingElement): known_bits = -self.relative_diameter().log2() - return sage.arith.all.algdep(self.center(), n, known_bits=known_bits) + return sage.arith.misc.algdep(self.center(), n, known_bits=known_bits) def factorial(self): """ diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index ba6a1bda129..a91b58d3268 100644 --- a/src/sage/rings/real_mpfr.pyx +++ b/src/sage/rings/real_mpfr.pyx @@ -117,49 +117,43 @@ Make sure we don't have a new field for every new literal:: # https://www.gnu.org/licenses/ # ***************************************************************************** -import math # for log -import sys +import math # for log +import operator import re +import sys from cpython.object cimport Py_NE, Py_EQ from cysignals.signals cimport sig_on, sig_off +import sage.arith.misc +import sage.misc.weak_dict +import sage.rings.abc +import sage.rings.infinity +import sage.rings.rational_field + +from sage.arith.constants cimport M_LN2_LN10 +from sage.arith.long cimport is_small_python_int +from sage.arith.numerical_approx cimport digits_to_bits +from sage.categories.map cimport Map +from sage.cpython.string cimport char_to_str, str_to_bytes from sage.ext.stdsage cimport PY_NEW -from sage.libs.gmp.pylong cimport mpz_set_pylong from sage.libs.gmp.mpz cimport * +from sage.libs.gmp.pylong cimport mpz_set_pylong from sage.libs.mpfr cimport * +from sage.libs.mpmath.utils cimport mpfr_to_mpfval from sage.misc.randstate cimport randstate, current_randstate -from sage.cpython.string cimport char_to_str, str_to_bytes from sage.misc.superseded import deprecation_cython as deprecation - -from sage.structure.element cimport Element -from sage.structure.element cimport have_same_parent -from sage.structure.richcmp cimport rich_to_bool_sgn -cdef bin_op -from sage.structure.element import bin_op - -import sage.misc.weak_dict - -import operator - -from sage.libs.mpmath.utils cimport mpfr_to_mpfval - from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational - -from sage.categories.map cimport Map - from sage.rings.real_double cimport RealDoubleElement - -import sage.rings.abc -import sage.rings.rational_field - -import sage.rings.infinity from sage.rings.ring import Ring +from sage.structure.element cimport Element +from sage.structure.element cimport have_same_parent +from sage.structure.parent_gens cimport ParentWithGens +from sage.structure.richcmp cimport rich_to_bool_sgn -from sage.arith.numerical_approx cimport digits_to_bits -from sage.arith.constants cimport M_LN2_LN10 -from sage.arith.long cimport is_small_python_int +cdef bin_op +from sage.structure.element import bin_op try: from cypari2 import Gen @@ -1284,6 +1278,7 @@ cdef class RealField_class(sage.rings.abc.RealField): TESTS:: + sage: # needs sage.libs.pari sage: k = RealField(100) sage: R. = k[] sage: k._factor_univariate_polynomial( x ) @@ -5324,7 +5319,7 @@ cdef class RealNumber(sage.structure.element.RingElement): sage: r.algebraic_dependency(5) x^2 - 2 """ - return sage.arith.all.algdep(self,n) + return sage.arith.misc.algdep(self,n) algdep = algebraic_dependency @@ -6013,6 +6008,11 @@ cdef class int_toRR(Map): return y +# Hook into Rational +from sage.rings.rational import _register_real_number_class +_register_real_number_class(RealNumber) + + # Support Python's numbers abstract base class import numbers numbers.Real.register(RealNumber) diff --git a/src/sage/rings/tate_algebra.py b/src/sage/rings/tate_algebra.py index 839d0e05b18..2905efdb7a8 100644 --- a/src/sage/rings/tate_algebra.py +++ b/src/sage/rings/tate_algebra.py @@ -27,9 +27,9 @@ :func:`sage.rings.tate_algebra.TateAlgebra`:: sage: K = Qp(2, 5, print_mode='digits') - sage: A. = TateAlgebra(K) - sage: A - Tate Algebra in x (val >= 0), y (val >= 0) over 2-adic Field with capped relative precision 5 + sage: A. = TateAlgebra(K); A + Tate Algebra in x (val >= 0), y (val >= 0) + over 2-adic Field with capped relative precision 5 As we observe, the default value for the log radii of convergence is `0` (the series then converge on the closed unit disc). @@ -37,13 +37,15 @@ We can specify different log radii using the following syntax:: sage: B. = TateAlgebra(K, log_radii=[1,2]); B - Tate Algebra in u (val >= -1), v (val >= -2) over 2-adic Field with capped relative precision 5 + Tate Algebra in u (val >= -1), v (val >= -2) + over 2-adic Field with capped relative precision 5 Note that if we pass in the ring of integers of `p`-adic field, the same Tate algebra is returned:: sage: A1. = TateAlgebra(K.integer_ring()); A1 - Tate Algebra in x (val >= 0), y (val >= 0) over 2-adic Field with capped relative precision 5 + Tate Algebra in x (val >= 0), y (val >= 0) + over 2-adic Field with capped relative precision 5 sage: A is A1 True @@ -51,9 +53,9 @@ of a Tate algebra, that is the subring consisting of series bounded by `1` on the domain of convergence:: - sage: Ao = A.integer_ring() - sage: Ao - Integer ring of the Tate Algebra in x (val >= 0), y (val >= 0) over 2-adic Field with capped relative precision 5 + sage: Ao = A.integer_ring(); Ao + Integer ring of the Tate Algebra in x (val >= 0), y (val >= 0) + over 2-adic Field with capped relative precision 5 Now we can build elements:: @@ -67,7 +69,8 @@ sage: f + g ...00001*x^3*y + ...00101 + ...000010*x*y^3 + ...000010*x*y + ...0000100*x^2*y^2 sage: f * g - ...00101*x^3*y + ...000010*x^4*y^4 + ...001010*x*y + ...0000100*x^5*y^3 + ...0000100*x^2*y^4 + ...00001000*x^3*y^3 + ...00101*x^3*y + ...000010*x^4*y^4 + ...001010*x*y + + ...0000100*x^5*y^3 + ...0000100*x^2*y^4 + ...00001000*x^3*y^3 An element in the integer ring is invertible if and only if its reduction modulo `p` is a nonzero constant. In our example, @@ -193,7 +196,8 @@ class TateAlgebraFactory(UniqueFactory): sage: R = Zp(2, 10, print_mode='digits'); R 2-adic Ring with capped relative precision 10 sage: A. = TateAlgebra(R, order='lex'); A - Tate Algebra in x (val >= 0), y (val >= 0) over 2-adic Field with capped relative precision 10 + Tate Algebra in x (val >= 0), y (val >= 0) + over 2-adic Field with capped relative precision 10 We observe that the result is the Tate algebra over the fraction field of `R` and not `R` itself:: @@ -207,7 +211,8 @@ class TateAlgebraFactory(UniqueFactory): we must use the method :meth:`integer_ring`:: sage: Ao = A.integer_ring(); Ao - Integer ring of the Tate Algebra in x (val >= 0), y (val >= 0) over 2-adic Field with capped relative precision 10 + Integer ring of the Tate Algebra in x (val >= 0), y (val >= 0) + over 2-adic Field with capped relative precision 10 sage: Ao.base_ring() 2-adic Ring with capped relative precision 10 sage: Ao.base_ring() is R @@ -847,15 +852,19 @@ def _pushout_(self, R): sage: A. = TateAlgebra(R, log_radii=[1,2]) sage: A1 = pushout(A, R1); A1 - Tate Algebra in u (val >= -1), v (val >= -2) over 2-adic Unramified Extension Field in a defined by x^2 + x + 1 + Tate Algebra in u (val >= -1), v (val >= -2) + over 2-adic Unramified Extension Field in a defined by x^2 + x + 1 sage: A2 = pushout(A, R2); A2 - Tate Algebra in u (val >= -2), v (val >= -4) over 2-adic Eisenstein Extension Field in pi defined by x^2 - 2 + Tate Algebra in u (val >= -2), v (val >= -4) + over 2-adic Eisenstein Extension Field in pi defined by x^2 - 2 sage: Ao = A.integer_ring() sage: pushout(Ao, R1) - Integer ring of the Tate Algebra in u (val >= -1), v (val >= -2) over 2-adic Unramified Extension Field in a defined by x^2 + x + 1 + Integer ring of the Tate Algebra in u (val >= -1), v (val >= -2) + over 2-adic Unramified Extension Field in a defined by x^2 + x + 1 sage: pushout(Ao, R2.fraction_field()) - Tate Algebra in u (val >= -2), v (val >= -4) over 2-adic Eisenstein Extension Field in pi defined by x^2 - 2 + Tate Algebra in u (val >= -2), v (val >= -4) + over 2-adic Eisenstein Extension Field in pi defined by x^2 - 2 TESTS:: @@ -1243,20 +1252,23 @@ def random_element(self, degree=2, terms=5, integral=False, prec=None): sage: R = Zp(2, prec=10, print_mode="digits") sage: A. = TateAlgebra(R) sage: A.random_element() # random - (...00101000.01)*y + ...1111011111*x^2 + ...0010010001*x*y + ...110000011 + ...010100100*y^2 + (...00101000.01)*y + ...1111011111*x^2 + ...0010010001*x*y + + ...110000011 + ...010100100*y^2 sage: A.random_element(degree=5, terms=3) # random (...0101100.01)*x^2*y + (...01000011.11)*y^2 + ...00111011*x*y sage: A.random_element(integral=True) # random - ...0001111101*x + ...1101110101 + ...00010010110*y + ...101110001100*x*y + ...000001100100*y^2 + ...0001111101*x + ...1101110101 + ...00010010110*y + + ...101110001100*x*y + ...000001100100*y^2 Note that if we are already working on the ring of integers, specifying ``integral=False`` has no effect:: sage: Ao = A.integer_ring() sage: f = Ao.random_element(integral=False); f # random - ...1100111011*x^2 + ...1110100101*x + ...1100001101*y + ...1110110001 + ...01011010110*y^2 + ...1100111011*x^2 + ...1110100101*x + ...1100001101*y + + ...1110110001 + ...01011010110*y^2 sage: f in Ao True @@ -1265,7 +1277,9 @@ def random_element(self, degree=2, terms=5, integral=False, prec=None): sage: B. = TateAlgebra(R, log_radii=[-1,-2]) sage: B.random_element(integral=True) # random - (...1111111.001)*x*y + (...111000101.1)*x + (...11010111.01)*y^2 + ...0010011011*y + ...0010100011000 + (...1111111.001)*x*y + (...111000101.1)*x + (...11010111.01)*y^2 + + ...0010011011*y + ...0010100011000 + """ if integral or self._integral: polring = self._polynomial_ring.change_ring(self._field.integer_ring()) diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py index 62c5dac33d7..0121f6a6b25 100644 --- a/src/sage/rings/valuation/valuation.py +++ b/src/sage/rings/valuation/valuation.py @@ -481,7 +481,7 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru [ Gauss valuation induced by (x + 1)-adic valuation, v(y) = 7/2 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y^13 + y^12 + y^10 + y^7 + y^6 + y^3 + 1) = 1 ]] sage: v0 = valuations.FunctionFieldValuation(K, GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x^3+x^2+1,1)) - sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed # needs sage.rings.function_field + sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed [[ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y + x^3 + x^2 + x) = 2, v(y^2 + (x^6 + x^4 + 1)*y + x^14 + x^10 + x^9 + x^8 + x^5 + x^4 + x^3 + x^2 + x) = 5 ], [ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y^2 + (x^2 + x)*y + 1) = 1 ], [ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y^3 + (x + 1)*y^2 + (x + 1)*y + x^2 + x + 1) = 1 ], diff --git a/src/sage/symbolic/expression_conversion_sympy.py b/src/sage/symbolic/expression_conversion_sympy.py index 4a3b1556ce1..c2c1b3e2634 100644 --- a/src/sage/symbolic/expression_conversion_sympy.py +++ b/src/sage/symbolic/expression_conversion_sympy.py @@ -129,7 +129,6 @@ def symbol(self, ex): """ EXAMPLES:: - sage: sage: from sage.symbolic.expression_conversions import SympyConverter sage: s = SympyConverter() sage: s.symbol(x) @@ -144,7 +143,6 @@ def relation(self, ex, op): """ EXAMPLES:: - sage: sage: import operator sage: from sage.symbolic.expression_conversions import SympyConverter sage: s = SympyConverter() diff --git a/src/sage/topology/simplicial_complex_examples.py b/src/sage/topology/simplicial_complex_examples.py index 304ea7ec8aa..2b1af7cbbe4 100644 --- a/src/sage/topology/simplicial_complex_examples.py +++ b/src/sage/topology/simplicial_complex_examples.py @@ -1423,7 +1423,6 @@ def RandomTwoSphere(n): EXAMPLES:: - sage: sage: G = simplicial_complexes.RandomTwoSphere(6); G Simplicial complex with vertex set (0, 1, 2, 3, 4, 5) and 8 facets sage: G.homology() # needs sage.modules diff --git a/src/sage/topology/simplicial_set.py b/src/sage/topology/simplicial_set.py index e33465f1153..9b707a62916 100644 --- a/src/sage/topology/simplicial_set.py +++ b/src/sage/topology/simplicial_set.py @@ -2382,7 +2382,6 @@ def coproduct(self, *others): sage: Y = S2.unset_base_point() sage: Z = K.unset_base_point() - sage: sage: S2.coproduct(K).is_pointed() True sage: S2.coproduct(K)