diff --git a/src/sage/rings/function_field/differential.py b/src/sage/rings/function_field/differential.py index ba2144d910b..4442a63bd22 100644 --- a/src/sage/rings/function_field/differential.py +++ b/src/sage/rings/function_field/differential.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.modules +# sage.doctest: needs sage.modules """ Differentials of function fields diff --git a/src/sage/rings/function_field/divisor.py b/src/sage/rings/function_field/divisor.py index f3dddb48d7c..30d99d920d4 100644 --- a/src/sage/rings/function_field/divisor.py +++ b/src/sage/rings/function_field/divisor.py @@ -1,5 +1,5 @@ -# sage.doctest: optional - sage.rings.finite_rings (because all doctests use finite fields) -# sage.doctest: optional - sage.rings.function_field (because almost all doctests use function field extensions) +# sage.doctest: needs sage.rings.finite_rings (because all doctests use finite fields) +# sage.doctest: needs sage.rings.function_field (because almost all doctests use function field extensions) """ Divisors of function fields diff --git a/src/sage/rings/function_field/drinfeld_modules/action.py b/src/sage/rings/function_field/drinfeld_modules/action.py index cfa9774058a..6fca6225d60 100644 --- a/src/sage/rings/function_field/drinfeld_modules/action.py +++ b/src/sage/rings/function_field/drinfeld_modules/action.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" The module action induced by a Drinfeld module diff --git a/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py index 958347113c0..55b4cfab326 100644 --- a/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Drinfeld modules diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 5c834733321..470dfc495d7 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Finite Drinfeld modules diff --git a/src/sage/rings/function_field/drinfeld_modules/homset.py b/src/sage/rings/function_field/drinfeld_modules/homset.py index 9ca53442cf5..d50e943686b 100644 --- a/src/sage/rings/function_field/drinfeld_modules/homset.py +++ b/src/sage/rings/function_field/drinfeld_modules/homset.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Set of morphisms between two Drinfeld modules diff --git a/src/sage/rings/function_field/drinfeld_modules/morphism.py b/src/sage/rings/function_field/drinfeld_modules/morphism.py index dfed15f778c..c7e1f6c3bfe 100644 --- a/src/sage/rings/function_field/drinfeld_modules/morphism.py +++ b/src/sage/rings/function_field/drinfeld_modules/morphism.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Drinfeld module morphisms diff --git a/src/sage/rings/function_field/element.pyx b/src/sage/rings/function_field/element.pyx index a5699080814..5e8254e8294 100644 --- a/src/sage/rings/function_field/element.pyx +++ b/src/sage/rings/function_field/element.pyx @@ -187,7 +187,7 @@ cdef class FunctionFieldElement(FieldElement): Now an example in a nontrivial extension of a rational function field:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: y.matrix() @@ -199,7 +199,7 @@ cdef class FunctionFieldElement(FieldElement): An example in a relative extension, where neither function field is rational:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) @@ -222,7 +222,7 @@ cdef class FunctionFieldElement(FieldElement): We show that this matrix does indeed work as expected when making a vector space from a function field:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^5 - (x^3 + 2*x*y + 1/x)) @@ -254,7 +254,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: y.trace() # needs sage.modules sage.rings.function_field + sage: y.trace() # needs sage.rings.function_field x """ return self.matrix().trace() @@ -267,7 +267,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: y.norm() # needs sage.modules sage.rings.function_field + sage: y.norm() # needs sage.rings.function_field 4*x^3 The norm is relative:: @@ -275,9 +275,9 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3); R. = L[] # needs sage.rings.function_field sage: M. = L.extension(z^3 - y^2*z + x) # needs sage.rings.function_field - sage: z.norm() # needs sage.modules sage.rings.function_field + sage: z.norm() # needs sage.rings.function_field -x - sage: z.norm().parent() # needs sage.modules sage.rings.function_field + sage: z.norm().parent() # needs sage.rings.function_field Function field in y defined by y^2 - x*y + 4*x^3 """ return self.matrix().determinant() @@ -326,13 +326,15 @@ cdef class FunctionFieldElement(FieldElement): EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3); R. = L[] # needs sage.rings.function_field - sage: M. = L.extension(z^3 - y^2*z + x) # needs sage.rings.function_field sage: x.characteristic_polynomial('W') # needs sage.modules W - x - sage: y.characteristic_polynomial('W') # needs sage.modules sage.rings.function_field + + sage: # needs sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3); R. = L[] + sage: M. = L.extension(z^3 - y^2*z + x) + sage: y.characteristic_polynomial('W') W^2 - x*W + 4*x^3 - sage: z.characteristic_polynomial('W') # needs sage.modules sage.rings.function_field + sage: z.characteristic_polynomial('W') W^3 + (-x*y + 4*x^3)*W + x """ return self.matrix().characteristic_polynomial(*args, **kwds) @@ -347,13 +349,15 @@ cdef class FunctionFieldElement(FieldElement): EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3); R. = L[] # needs sage.rings.function_field - sage: M. = L.extension(z^3 - y^2*z + x) # needs sage.rings.function_field sage: x.minimal_polynomial('W') # needs sage.modules W - x - sage: y.minimal_polynomial('W') # needs sage.modules sage.rings.function_field + + sage: # needs sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3); R. = L[] + sage: M. = L.extension(z^3 - y^2*z + x) + sage: y.minimal_polynomial('W') W^2 - x*W + 4*x^3 - sage: z.minimal_polynomial('W') # needs sage.modules sage.rings.function_field + sage: z.minimal_polynomial('W') W^3 + (-x*y + 4*x^3)*W + x """ return self.matrix().minimal_polynomial(*args, **kwds) @@ -366,7 +370,7 @@ cdef class FunctionFieldElement(FieldElement): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: y.is_integral() @@ -396,7 +400,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(4)); _. = K[] # needs sage.rings.finite_rings sage: L. = K.extension(Y^2 + Y + x +1/x) # needs sage.rings.finite_rings sage.rings.function_field - sage: (y^3 + x).differential() # needs sage.modules sage.rings.finite_rings sage.rings.function_field + sage: (y^3 + x).differential() # needs sage.rings.finite_rings sage.rings.function_field (((x^2 + 1)/x^2)*y + (x^4 + x^3 + 1)/x^3) d(x) TESTS: @@ -404,16 +408,17 @@ cdef class FunctionFieldElement(FieldElement): Verify that :issue:`27712` is resolved:: sage: K. = FunctionField(GF(31)) - sage: R. = K[] - sage: L. = K.extension(y^2 - x) # needs sage.rings.function_field - sage: R. = L[] # needs sage.rings.function_field - sage: M. = L.extension(z^2 - y) # needs sage.rings.function_field - sage: x.differential() # needs sage.modules d(x) - sage: y.differential() # needs sage.modules sage.rings.function_field + + sage: # needs sage.rings.function_field + sage: R. = K[] + sage: L. = K.extension(y^2 - x) + sage: R. = L[] + sage: M. = L.extension(z^2 - y) + sage: y.differential() (16/x*y) d(x) - sage: z.differential() # needs sage.modules sage.rings.function_field + sage: z.differential() (8/x*z) d(x) """ F = self.parent() @@ -436,7 +441,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(4)); _. = K[] # needs sage.rings.finite_rings sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.finite_rings sage.rings.function_field - sage: (y^3 + x).derivative() # needs sage.modules sage.rings.finite_rings sage.rings.function_field + sage: (y^3 + x).derivative() # needs sage.rings.finite_rings sage.rings.function_field ((x^2 + 1)/x^2)*y + (x^4 + x^3 + 1)/x^3 """ D = self.parent().derivation() @@ -458,14 +463,14 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(2)) sage: f = t^2 - sage: f.higher_derivative(2) # needs sage.modules sage.rings.function_field + sage: f.higher_derivative(2) # needs sage.rings.function_field 1 :: sage: K. = FunctionField(GF(4)); _. = K[] # needs sage.rings.finite_rings sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.finite_rings sage.rings.function_field - sage: (y^3 + x).higher_derivative(2) # needs sage.modules sage.rings.finite_rings sage.rings.function_field + sage: (y^3 + x).higher_derivative(2) # needs sage.rings.finite_rings sage.rings.function_field 1/x^3*y + (x^6 + x^4 + x^3 + x^2 + x + 1)/x^5 """ D = self.parent().higher_derivation() @@ -489,7 +494,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(2)); _. = K[] sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: y.divisor() # needs sage.modules sage.rings.function_field + sage: y.divisor() # needs sage.rings.function_field - Place (1/x, 1/x*y) - Place (x, x*y) + 2*Place (x + 1, x*y) @@ -517,7 +522,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(4)); _. = K[] # needs sage.rings.finite_rings sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.finite_rings sage.rings.function_field - sage: (x/y).divisor_of_zeros() # needs sage.modules sage.rings.finite_rings sage.rings.function_field + sage: (x/y).divisor_of_zeros() # needs sage.rings.finite_rings sage.rings.function_field 3*Place (x, x*y) """ if self.is_zero(): @@ -544,7 +549,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(4)); _. = K[] # needs sage.rings.finite_rings sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.finite_rings sage.rings.function_field - sage: (x/y).divisor_of_poles() # needs sage.modules sage.rings.finite_rings sage.rings.function_field + sage: (x/y).divisor_of_poles() # needs sage.rings.finite_rings sage.rings.function_field Place (1/x, 1/x*y) + 2*Place (x + 1, x*y) """ if self.is_zero(): @@ -570,7 +575,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(4)); _. = K[] # needs sage.rings.finite_rings sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.finite_rings sage.rings.function_field - sage: (x/y).zeros() # needs sage.modules sage.rings.finite_rings sage.rings.function_field + sage: (x/y).zeros() # needs sage.rings.finite_rings sage.rings.function_field [Place (x, x*y)] """ return self.divisor_of_zeros().support() @@ -590,7 +595,7 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(4)); _. = K[] # needs sage.rings.finite_rings sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.finite_rings sage.rings.function_field - sage: (x/y).poles() # needs sage.modules sage.rings.finite_rings sage.rings.function_field + sage: (x/y).poles() # needs sage.rings.finite_rings sage.rings.function_field [Place (1/x, 1/x*y), Place (x + 1, x*y)] """ return self.divisor_of_poles().support() @@ -607,8 +612,8 @@ cdef class FunctionFieldElement(FieldElement): sage: K. = FunctionField(GF(2)); _. = K[] sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_infinite()[0] # needs sage.modules sage.rings.function_field - sage: y.valuation(p) # needs sage.modules sage.rings.function_field + sage: p = L.places_infinite()[0] # needs sage.rings.function_field + sage: y.valuation(p) # needs sage.rings.function_field -1 :: diff --git a/src/sage/rings/function_field/element_polymod.pyx b/src/sage/rings/function_field/element_polymod.pyx index 7a75bfe978e..55e887ea491 100644 --- a/src/sage/rings/function_field/element_polymod.pyx +++ b/src/sage/rings/function_field/element_polymod.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.function_field +# sage.doctest: needs sage.rings.function_field r""" Elements of function fields: extension """ diff --git a/src/sage/rings/function_field/element_rational.pyx b/src/sage/rings/function_field/element_rational.pyx index 40d0d9734ef..5ad0d81341d 100644 --- a/src/sage/rings/function_field/element_rational.pyx +++ b/src/sage/rings/function_field/element_rational.pyx @@ -74,10 +74,11 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): sage: K. = FunctionField(GF(7)) sage: t.element() t - sage: type(t.element()) # needs sage.rings.finite_rings + sage: type(t.element()) # needs sage.libs.ntl <... 'sage.rings.fraction_field_FpT.FpTElement'> - sage: K. = FunctionField(GF(131101)) # needs sage.libs.pari + sage: # needs sage.rings.finite_rings + sage: K. = FunctionField(GF(131101)) sage: t.element() t sage: type(t.element()) @@ -392,9 +393,9 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): True sage: f.is_nth_power(3) # needs sage.modules False - sage: (f^3).is_nth_power(3) + sage: (f^3).is_nth_power(3) # needs sage.modules True - sage: (f^9).is_nth_power(-9) + sage: (f^9).is_nth_power(-9) # needs sage.modules True """ if n == 1: @@ -437,7 +438,6 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): EXAMPLES:: - sage: # needs sage.rings.finite_rings sage: K. = FunctionField(GF(3)) sage: f = (x+1)/(x+2) sage: f.nth_root(1) @@ -446,9 +446,9 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): Traceback (most recent call last): ... ValueError: element is not an n-th power - sage: (f^3).nth_root(3) + sage: (f^3).nth_root(3) # needs sage.modules (x + 1)/(x + 2) - sage: (f^9).nth_root(-9) + sage: (f^9).nth_root(-9) # needs sage.modules (x + 2)/(x + 1) """ if n == 0: diff --git a/src/sage/rings/function_field/function_field.py b/src/sage/rings/function_field/function_field.py index 5e8105db36a..315f58cdc39 100644 --- a/src/sage/rings/function_field/function_field.py +++ b/src/sage/rings/function_field/function_field.py @@ -190,7 +190,7 @@ The gap numbers for Weierstrass places are of course not ordinary:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: p1,p2,p3 = L.weierstrass_places()[:3] sage: p1.gaps() [1, 2, 4] @@ -532,9 +532,9 @@ def order(self, x, check=True): sage: O.basis() # needs sage.modules (1, y, y^2) - sage: Z = K.order(x); Z # needs sage.modules sage.rings.function_field + sage: Z = K.order(x); Z # needs sage.rings.function_field Order in Rational function field in x over Rational Field - sage: Z.basis() # needs sage.modules sage.rings.function_field + sage: Z.basis() # needs sage.rings.function_field (1,) Orders with multiple generators are not yet supported:: @@ -619,7 +619,7 @@ def order_infinite(self, x, check=True): sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^3 + x^3 + 4*x + 1) # needs sage.rings.function_field - sage: L.order_infinite(y) # not implemented # needs sage.modules sage.rings.function_field + sage: L.order_infinite(y) # not implemented # needs sage.rings.function_field sage: Z = K.order(x); Z # needs sage.modules Order in Rational function field in x over Rational Field @@ -1016,7 +1016,7 @@ def space_of_differentials(self): sage: K. = FunctionField(GF(5)); _. = K[] sage: L. = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2)) # needs sage.rings.function_field - sage: L.space_of_differentials() # needs sage.modules sage.rings.function_field + sage: L.space_of_differentials() # needs sage.rings.function_field Space of differentials of Function field in y defined by y^3 + (4*x^3 + 1)/(x^3 + 3) """ @@ -1040,7 +1040,7 @@ def space_of_holomorphic_differentials(self): sage: K. = FunctionField(GF(5)); _. = K[] sage: L. = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2)) # needs sage.rings.function_field - sage: L.space_of_holomorphic_differentials() # needs sage.modules sage.rings.function_field + sage: L.space_of_holomorphic_differentials() # needs sage.rings.function_field (Vector space of dimension 4 over Finite Field of size 5, Linear map: From: Vector space of dimension 4 over Finite Field of size 5 @@ -1067,7 +1067,7 @@ def basis_of_holomorphic_differentials(self): sage: K. = FunctionField(GF(5)); _. = K[] sage: L. = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2)) # needs sage.rings.function_field - sage: L.basis_of_holomorphic_differentials() # needs sage.modules sage.rings.function_field + sage: L.basis_of_holomorphic_differentials() # needs sage.rings.function_field [((x/(x^3 + 4))*y) d(x), ((1/(x^3 + 4))*y) d(x), ((x/(x^3 + 4))*y^2) d(x), @@ -1089,12 +1089,12 @@ def divisor_group(self): sage: _. = K[] sage: L. = K.extension(Y^3 - (t^3 - 1)/(t^3 - 2)) # needs sage.rings.function_field - sage: L.divisor_group() # needs sage.modules sage.rings.function_field + sage: L.divisor_group() # needs sage.rings.function_field Divisor group of Function field in y defined by y^3 + (-t^3 + 1)/(t^3 - 2) sage: K. = FunctionField(GF(5)); _. = K[] sage: L. = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2)) # needs sage.rings.function_field - sage: L.divisor_group() # needs sage.modules sage.rings.function_field + sage: L.divisor_group() # needs sage.rings.function_field Divisor group of Function field in y defined by y^3 + (4*x^3 + 1)/(x^3 + 3) """ from .divisor import DivisorGroup diff --git a/src/sage/rings/function_field/function_field_polymod.py b/src/sage/rings/function_field/function_field_polymod.py index ef72935eba6..fd8c975e682 100644 --- a/src/sage/rings/function_field/function_field_polymod.py +++ b/src/sage/rings/function_field/function_field_polymod.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.function_field +# sage.doctest: needs sage.rings.function_field r""" Function Fields: extension """ diff --git a/src/sage/rings/function_field/function_field_rational.py b/src/sage/rings/function_field/function_field_rational.py index 2226c086b00..bb2075b1ecf 100644 --- a/src/sage/rings/function_field/function_field_rational.py +++ b/src/sage/rings/function_field/function_field_rational.py @@ -102,7 +102,7 @@ class RationalFunctionField(FunctionField): sage: R. = FunctionField(QQ) sage: L. = R[] sage: F. = R.extension(y^2 - (x^2+1)) # needs sage.rings.function_field - sage: (y/x).divisor() # needs sage.modules sage.rings.function_field + sage: (y/x).divisor() # needs sage.rings.function_field - Place (x, y - 1) - Place (x, y + 1) + Place (x^2 + 1, y) @@ -112,15 +112,13 @@ class RationalFunctionField(FunctionField): sage: NF. = NumberField(z^2 + 1) sage: R. = FunctionField(NF) sage: L. = R[] - sage: F. = R.extension(y^2 - (x^2+1)) # needs sage.modules sage.rings.function_field - - sage: (x/y*x.differential()).divisor() # needs sage.modules sage.rings.function_field sage.rings.number_field + sage: F. = R.extension(y^2 - (x^2+1)) # needs sage.rings.function_field + sage: (x/y*x.differential()).divisor() # needs sage.rings.function_field -2*Place (1/x, 1/x*y - 1) - 2*Place (1/x, 1/x*y + 1) + Place (x, y - 1) + Place (x, y + 1) - - sage: (x/y).divisor() # needs sage.modules sage.rings.function_field sage.rings.number_field + sage: (x/y).divisor() # needs sage.rings.function_field - Place (x - i, y) + Place (x, y - 1) + Place (x, y + 1) @@ -135,7 +133,6 @@ def __init__(self, constant_field, names, category=None): EXAMPLES:: - 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 diff --git a/src/sage/rings/function_field/ideal.py b/src/sage/rings/function_field/ideal.py index 47fba9754f7..00450c60533 100644 --- a/src/sage/rings/function_field/ideal.py +++ b/src/sage/rings/function_field/ideal.py @@ -455,14 +455,14 @@ def divisor(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: K. = FunctionField(GF(4)) sage: O = K.maximal_order() sage: I = O.ideal(x*(x + 1)^2/(x^2 + x + 1)) sage: I.divisor() Place (x) + 2*Place (x + 1) - Place (x + z2) - Place (x + z2 + 1) - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: Oinf = K.maximal_order_infinite() sage: I = Oinf.ideal((x + 1)/(x^3 + 1)) sage: I.divisor() @@ -528,7 +528,7 @@ def divisor_of_zeros(self): sage: I.divisor_of_zeros() 2*Place (1/x) - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] sage: L. = K.extension(Y^2 + Y + x + 1/x) sage: O = L.maximal_order() @@ -565,7 +565,7 @@ def divisor_of_poles(self): sage: I.divisor_of_poles() 0 - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] sage: L. = K.extension(Y^2 + Y + x + 1/x) sage: O = L.maximal_order() diff --git a/src/sage/rings/function_field/ideal_polymod.py b/src/sage/rings/function_field/ideal_polymod.py index da45bc508cf..83a1370e493 100644 --- a/src/sage/rings/function_field/ideal_polymod.py +++ b/src/sage/rings/function_field/ideal_polymod.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.function_field +# sage.doctest: needs sage.rings.function_field r""" Ideals of function fields: extension """ diff --git a/src/sage/rings/function_field/maps.py b/src/sage/rings/function_field/maps.py index dedd3d2a998..2863a953f20 100644 --- a/src/sage/rings/function_field/maps.py +++ b/src/sage/rings/function_field/maps.py @@ -72,7 +72,7 @@ class FunctionFieldVectorSpaceIsomorphism(Morphism): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -85,7 +85,7 @@ def _repr_(self) -> str: EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -109,7 +109,7 @@ def is_injective(self) -> bool: EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -124,7 +124,7 @@ def is_surjective(self) -> bool: EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -191,7 +191,7 @@ class MapVectorSpaceToFunctionField(FunctionFieldVectorSpaceIsomorphism): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space(); f @@ -203,7 +203,7 @@ def __init__(self, V, K): """ EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space(); type(f) @@ -224,7 +224,7 @@ def _call_(self, v): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) @@ -236,7 +236,7 @@ def _call_(self, v): Test that this map is a bijection for some random inputs:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: R. = L[] sage: M. = L.extension(z^3 - y - x) sage: for F in [K, L, M]: @@ -270,7 +270,7 @@ def domain(self): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -285,7 +285,7 @@ def codomain(self): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -301,7 +301,7 @@ class MapFunctionFieldToVectorSpace(FunctionFieldVectorSpaceIsomorphism): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space(); t @@ -321,7 +321,7 @@ def __init__(self, K, V): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -339,7 +339,7 @@ def _call_(self, x): EXAMPLES:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^2 - x*y + 4*x^3) sage: V, f, t = L.vector_space() @@ -350,7 +350,7 @@ def _call_(self, x): Test that this map is a bijection for some random inputs:: - sage: # needs sage.modules sage.rings.function_field + sage: # needs sage.rings.function_field sage: R. = L[] sage: M. = L.extension(z^3 - y - x) sage: for F in [K, L, M]: diff --git a/src/sage/rings/function_field/order.py b/src/sage/rings/function_field/order.py index 6ffe40c5faf..0afeaa5f526 100644 --- a/src/sage/rings/function_field/order.py +++ b/src/sage/rings/function_field/order.py @@ -274,7 +274,7 @@ def _repr_(self): sage: K. = FunctionField(GF(2)); R. = PolynomialRing(K) sage: F. = K.extension(t^3 - x^2*(x^2+x+1)^2) # needs sage.rings.function_field - sage: F.maximal_order_infinite() # needs sage.modules sage.rings.function_field + sage: F.maximal_order_infinite() # needs sage.rings.function_field Maximal infinite order of Function field in y defined by y^3 + x^6 + x^4 + x^2 """ return "Maximal infinite order of %s" % (self.function_field(),) diff --git a/src/sage/rings/function_field/order_polymod.py b/src/sage/rings/function_field/order_polymod.py index d6831fa7248..ad760aad0b6 100644 --- a/src/sage/rings/function_field/order_polymod.py +++ b/src/sage/rings/function_field/order_polymod.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.function_field +# sage.doctest: needs sage.rings.function_field r""" Orders of function fields: extension """ diff --git a/src/sage/rings/function_field/order_rational.py b/src/sage/rings/function_field/order_rational.py index 99da2af1ebd..b21712bcf2c 100644 --- a/src/sage/rings/function_field/order_rational.py +++ b/src/sage/rings/function_field/order_rational.py @@ -129,7 +129,7 @@ def _residue_field(self, ideal, name=None): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: F. = FunctionField(GF(2)) sage: O = F.maximal_order() sage: I = O.ideal(x^2 + x + 1) @@ -150,7 +150,7 @@ def _residue_field(self, ideal, name=None): sage: to_R(e2).parent() is R True - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: F. = FunctionField(GF(2)) sage: O = F.maximal_order() sage: I = O.ideal(x + 1) @@ -171,20 +171,21 @@ def _residue_field(self, ideal, name=None): sage: to_R(e2).parent() is R True + sage: # needs sage.modules sage.rings.number_field sage: F. = FunctionField(QQ) sage: O = F.maximal_order() sage: I = O.ideal(x^2 + x + 1) - sage: R, fr_R, to_R = O._residue_field(I) # needs sage.rings.number_field - sage: R # needs sage.rings.number_field + sage: R, fr_R, to_R = O._residue_field(I) + sage: R Number Field in a with defining polynomial x^2 + x + 1 - sage: e1, e2 = fr_R(R.random_element()), fr_R(R.random_element()) # needs sage.rings.number_field - sage: to_R(e1 * e2) == to_R(e1) * to_R(e2) # needs sage.rings.number_field + sage: e1, e2 = fr_R(R.random_element()), fr_R(R.random_element()) + sage: to_R(e1 * e2) == to_R(e1) * to_R(e2) True - sage: to_R(e1 + e2) == to_R(e1) + to_R(e2) # needs sage.rings.number_field + sage: to_R(e1 + e2) == to_R(e1) + to_R(e2) True - sage: to_R(e1).parent() is R # needs sage.rings.number_field + sage: to_R(e1).parent() is R True - sage: to_R(e2).parent() is R # needs sage.rings.number_field + sage: to_R(e2).parent() is R True sage: F. = FunctionField(QQ) diff --git a/src/sage/rings/function_field/place.py b/src/sage/rings/function_field/place.py index efff8d4305e..a17c97b7316 100644 --- a/src/sage/rings/function_field/place.py +++ b/src/sage/rings/function_field/place.py @@ -252,7 +252,7 @@ def __radd__(self, other): sage: k. = GF(2) sage: K. = FunctionField(k) - sage: sum(K.places_finite()) # needs sage.libs.pari + sage: sum(K.places_finite()) # needs sage.libs.pari sage.modules Place (x) + Place (x + 1) Note that this does not work, as wanted:: diff --git a/src/sage/rings/function_field/place_polymod.py b/src/sage/rings/function_field/place_polymod.py index f345c31129e..ee9e8de5874 100644 --- a/src/sage/rings/function_field/place_polymod.py +++ b/src/sage/rings/function_field/place_polymod.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.function_field +# sage.doctest: needs sage.rings.function_field """ Places of function fields: extension """ diff --git a/src/sage/rings/function_field/place_rational.py b/src/sage/rings/function_field/place_rational.py index 9b98397ba90..31ffd6a40b0 100644 --- a/src/sage/rings/function_field/place_rational.py +++ b/src/sage/rings/function_field/place_rational.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings (because all doctests use finite fields) +# sage.doctest: needs sage.rings.finite_rings (because all doctests use finite fields) """ Places of function fields: rational """ @@ -102,6 +102,7 @@ def _residue_field(self, name=None): EXAMPLES:: + sage: # needs sage.modules sage: F. = FunctionField(GF(2)) sage: O = F.maximal_order() sage: i = O.ideal(x^2 + x + 1) diff --git a/src/sage/rings/function_field/valuation_ring.py b/src/sage/rings/function_field/valuation_ring.py index 81fc97d3324..e1fe9751b0b 100644 --- a/src/sage/rings/function_field/valuation_ring.py +++ b/src/sage/rings/function_field/valuation_ring.py @@ -1,5 +1,5 @@ -# sage.doctest: optional - sage.rings.finite_rings -# sage.doctest: optional - sage.rings.function_field +# sage.doctest: needs sage.rings.finite_rings +# sage.doctest: needs sage.rings.function_field r""" Valuation rings of function fields diff --git a/src/sage/rings/polynomial/binary_form_reduce.py b/src/sage/rings/polynomial/binary_form_reduce.py index ff36ec13ab0..6afb11155cf 100644 --- a/src/sage/rings/polynomial/binary_form_reduce.py +++ b/src/sage/rings/polynomial/binary_form_reduce.py @@ -25,10 +25,8 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.calculus.functions import jacobian -from sage.functions.hyperbolic import cosh, sinh -from sage.functions.log import exp from sage.matrix.constructor import matrix +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.modules.free_module_element import vector from sage.rings.cc import CC @@ -40,6 +38,10 @@ from sage.rings.rational_field import QQ from sage.rings.real_mpfr import RealField +lazy_import("sage.calculus.functions", "jacobian") +lazy_import("sage.functions.hyperbolic", ["cosh", "sinh"]) +lazy_import("sage.functions.log", "exp") + def covariant_z0(F, z0_cov=False, prec=53, emb=None, error_limit=0.000001): r""" diff --git a/src/sage/rings/polynomial/ideal.py b/src/sage/rings/polynomial/ideal.py index 011cb860290..9eba00860b5 100644 --- a/src/sage/rings/polynomial/ideal.py +++ b/src/sage/rings/polynomial/ideal.py @@ -92,8 +92,9 @@ def change_ring(self, R): EXAMPLES:: sage: R. = QQ[] - sage: I = R.ideal([q^2+q-1]) - sage: I.change_ring(RR['q']) - Principal ideal (q^2 + q - 1.00000000000000) of Univariate Polynomial Ring in q over Real Field with 53 bits of precision + sage: I = R.ideal([q^2 + q - 1]) + sage: I.change_ring(RR['q']) # needs sage.rings.real_mpfr + Principal ideal (q^2 + q - 1.00000000000000) of + Univariate Polynomial Ring in q over Real Field with 53 bits of precision """ return R.ideal(self.gens()) diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 1270c42ce2a..1bddae9ebfc 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -6538,8 +6538,8 @@ cdef class Polynomial(CommutativePolynomial): TESTS:: - sage: a = RIF['x'](1/3) - sage: (a - a).exponents() + sage: a = RIF['x'](1/3) # needs sage.rings.real_interval_field + sage: (a - a).exponents() # needs sage.rings.real_interval_field [0] """ cdef Py_ssize_t i @@ -7944,11 +7944,12 @@ cdef class Polynomial(CommutativePolynomial): The following examples show that :issue:`11782` has been fixed:: - sage: var('x') # needs sage.symbolic + sage: # needs sage.libs.pari sage.symbolic + sage: var('x') x - sage: ZZ.quo(81)['x'](3*x^2 + 3*x + 3).discriminant() # needs sage.libs.pari sage.symbolic + sage: ZZ.quo(81)['x'](3*x^2 + 3*x + 3).discriminant() 54 - sage: ZZ.quo(9)['x'](2*x^3 + x^2 + x).discriminant() # needs sage.libs.pari sage.symbolic + sage: ZZ.quo(9)['x'](2*x^3 + x^2 + x).discriminant() 2 This was fixed by :issue:`15422`:: @@ -8487,7 +8488,7 @@ cdef class Polynomial(CommutativePolynomial): :: - sage: # needs sage.rings.complex_double sage.rings.real_mpfr + sage: # needs numpy sage.rings.complex_double sage.rings.real_mpfr sage: rflds = (RR, RDF, RealField(100)) sage: cflds = (CC, CDF, ComplexField(100)) sage: def cross(a, b): @@ -9773,6 +9774,8 @@ cdef class Polynomial(CommutativePolynomial): sage: d = z^4 + (2*t + 4)*z^3 + (-t + 5)*z^2 + (t^2 + 2)*z + t^2 + 2*t + 1 sage: prec = 9 sage: x = n.subs(z=w)/d.subs(z=w) + O(w^prec) + + sage: # needs sage.libs.flint (otherwise timeout) sage: nc, dc = Pz(x.list()).rational_reconstruction(z^prec) sage: (nc, dc) == (n, d) True diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index bdcfb2de0ae..d0d2d1241ab 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -3623,8 +3623,12 @@ def irreducible_element(self, n, algorithm=None): return self(conway_polynomial(p, n)) elif algorithm == "first_lexicographic": if p == 2: - from .polynomial_gf2x import GF2X_BuildIrred_list - return self(GF2X_BuildIrred_list(n)) + try: + from .polynomial_gf2x import GF2X_BuildIrred_list + except ImportError: + pass + else: + return self(GF2X_BuildIrred_list(n)) else: # Fallback to PolynomialRing_dense_finite_field.irreducible_element pass @@ -3638,8 +3642,12 @@ def irreducible_element(self, n, algorithm=None): raise NotImplementedError("'minimal_weight' option only implemented for p = 2") elif algorithm == "random": if p == 2: - from .polynomial_gf2x import GF2X_BuildRandomIrred_list - return self(GF2X_BuildRandomIrred_list(n)) + try: + from .polynomial_gf2x import GF2X_BuildRandomIrred_list + except ImportError: + pass + else: + return self(GF2X_BuildRandomIrred_list(n)) else: pass diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index f6d391679a6..d356edf742f 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -3776,9 +3776,13 @@ def _repr_(self): if isinstance(self._descr, ANExtensionElement) and self._descr._generator is QQbar_I_generator: return repr(self._descr._value) if self.parent().options.display_format == 'radical': - radical = self.radical_expression() - if radical is not self: - return repr(radical) + try: + radical = self.radical_expression() + except ImportError: + pass + else: + if radical is not self: + return repr(radical) if self.parent() is QQbar: return repr(CIF(self._value)) else: @@ -3819,9 +3823,13 @@ def _latex_(self): if isinstance(self._descr, ANExtensionElement) and self._descr._generator is QQbar_I_generator: return latex(self._descr._value) if self.parent().options.display_format == 'radical': - radical = self.radical_expression() - if radical is not self: - return latex(radical) + try: + radical = self.radical_expression() + except ImportError: + pass + else: + if radical is not self: + return latex(radical) return repr(self).replace('*I', r' \sqrt{-1}') def _sage_input_(self, sib, coerce): diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx index 73232348a01..4b34af0e8bf 100644 --- a/src/sage/rings/real_arb.pyx +++ b/src/sage/rings/real_arb.pyx @@ -675,12 +675,16 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): [-4.733045976388941e+363922934236666733021124 +/- ...e+363922934236666733021108], [+/- inf], [+/- inf], [+/- inf], nan] """ - import sage.symbolic.constants inf = self(sage.rings.infinity.Infinity) - return [self(0), self(1), self(1)/3, - -self(2)**(Integer(2)**80), - inf, -inf, self.zero().add_error(inf), - self.element_class(self, sage.symbolic.constants.NotANumber())] + elements = [self(0), self(1), self(1)/3, -self(2)**(Integer(2)**80), + inf, -inf, self.zero().add_error(inf)] + try: + from sage.symbolic.constants import NotANumber + except ImportError: + pass + else: + elements.append(self.element_class(self, NotANumber())) + return elements def _sum_of_products(self, terms): r""" @@ -1421,8 +1425,7 @@ cdef class RealBall(RingElement): raise ValueError("unsupported string format") else: # the initializers that trigger imports - import sage.symbolic.constants - import sage.symbolic.expression + import sage.rings.infinity if isinstance(mid, sage.rings.infinity.AnInfinity): if isinstance(mid, sage.rings.infinity.PlusInfinity): arb_pos_inf(self.value) @@ -1430,33 +1433,39 @@ cdef class RealBall(RingElement): arb_neg_inf(self.value) else: arb_zero_pm_inf(self.value) - elif isinstance(mid, sage.symbolic.constants.Constant): - if _do_sig(prec(self)): sig_on() + else: try: - if isinstance(mid, sage.symbolic.constants.NotANumber): - arb_indeterminate(self.value) - elif isinstance(mid, sage.symbolic.constants.Pi): - arb_const_pi(self.value, prec(self)) - elif isinstance(mid, sage.symbolic.constants.Log2): - arb_const_log2(self.value, prec(self)) - elif isinstance(mid, sage.symbolic.constants.Catalan): - arb_const_catalan(self.value, prec(self)) - elif isinstance(mid, sage.symbolic.constants.Khinchin): - arb_const_khinchin(self.value, prec(self)) - elif isinstance(mid, sage.symbolic.constants.Glaisher): - arb_const_glaisher(self.value, prec(self)) - elif isinstance(mid, sage.symbolic.constants.EulerGamma): - arb_const_euler(self.value, prec(self)) - else: - raise TypeError("unsupported constant") - finally: + import sage.symbolic.constants + import sage.symbolic.expression + except ImportError: + raise TypeError("unsupported midpoint type") + if isinstance(mid, sage.symbolic.constants.Constant): + if _do_sig(prec(self)): sig_on() + try: + if isinstance(mid, sage.symbolic.constants.NotANumber): + arb_indeterminate(self.value) + elif isinstance(mid, sage.symbolic.constants.Pi): + arb_const_pi(self.value, prec(self)) + elif isinstance(mid, sage.symbolic.constants.Log2): + arb_const_log2(self.value, prec(self)) + elif isinstance(mid, sage.symbolic.constants.Catalan): + arb_const_catalan(self.value, prec(self)) + elif isinstance(mid, sage.symbolic.constants.Khinchin): + arb_const_khinchin(self.value, prec(self)) + elif isinstance(mid, sage.symbolic.constants.Glaisher): + arb_const_glaisher(self.value, prec(self)) + elif isinstance(mid, sage.symbolic.constants.EulerGamma): + arb_const_euler(self.value, prec(self)) + else: + raise TypeError("unsupported constant") + finally: + if _do_sig(prec(self)): sig_off() + elif isinstance(mid, sage.symbolic.expression.E): + if _do_sig(prec(self)): sig_on() + arb_const_e(self.value, prec(self)) if _do_sig(prec(self)): sig_off() - elif isinstance(mid, sage.symbolic.expression.E): - if _do_sig(prec(self)): sig_on() - arb_const_e(self.value, prec(self)) - if _do_sig(prec(self)): sig_off() - else: - raise TypeError("unsupported midpoint type") + else: + raise TypeError("unsupported midpoint type") if rad is not None: mag_init(tmpm)