Skip to content

Commit

Permalink
gh-38210: sage.rings: Modularization fixes (imports), # needs
Browse files Browse the repository at this point in the history
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes #12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes #12345". -->

- Cherry-picked from #35095

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
    
URL: #38210
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee, Matthias Köppe
  • Loading branch information
Release Manager committed Jun 16, 2024
2 parents c8089eb + ede0e92 commit 2ff3027
Show file tree
Hide file tree
Showing 29 changed files with 191 additions and 156 deletions.
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/differential.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.modules
# sage.doctest: needs sage.modules
"""
Differentials of function fields
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/function_field/divisor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/drinfeld_modules/action.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.rings.finite_rings
# sage.doctest: needs sage.rings.finite_rings
r"""
Drinfeld modules
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.rings.finite_rings
# sage.doctest: needs sage.rings.finite_rings
r"""
Finite Drinfeld modules
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/drinfeld_modules/homset.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/drinfeld_modules/morphism.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.rings.finite_rings
# sage.doctest: needs sage.rings.finite_rings
r"""
Drinfeld module morphisms
Expand Down
73 changes: 39 additions & 34 deletions src/sage/rings/function_field/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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.<x> = FunctionField(QQ); R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
sage: y.matrix()
Expand All @@ -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.<x> = FunctionField(QQ)
sage: R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
Expand All @@ -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.<x> = FunctionField(QQ)
sage: R.<y> = K[]
sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
Expand Down Expand Up @@ -254,7 +254,7 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
sage: L.<y> = 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()
Expand All @@ -267,17 +267,17 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
sage: L.<y> = 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::
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[] # needs sage.rings.function_field
sage: M.<z> = 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()
Expand Down Expand Up @@ -326,13 +326,15 @@ cdef class FunctionFieldElement(FieldElement):
EXAMPLES::
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[] # needs sage.rings.function_field
sage: M.<z> = 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.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
sage: M.<z> = 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)
Expand All @@ -347,13 +349,15 @@ cdef class FunctionFieldElement(FieldElement):
EXAMPLES::
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[] # needs sage.rings.function_field
sage: M.<z> = 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.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
sage: M.<z> = 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)
Expand All @@ -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.<x> = FunctionField(QQ); R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
sage: y.is_integral()
Expand Down Expand Up @@ -396,24 +400,25 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[] # needs sage.rings.finite_rings
sage: L.<y> = 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:
Verify that :issue:`27712` is resolved::
sage: K.<x> = FunctionField(GF(31))
sage: R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x) # needs sage.rings.function_field
sage: R.<z> = L[] # needs sage.rings.function_field
sage: M.<z> = 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.<y> = K[]
sage: L.<y> = K.extension(y^2 - x)
sage: R.<z> = L[]
sage: M.<z> = 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()
Expand All @@ -436,7 +441,7 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[] # needs sage.rings.finite_rings
sage: L.<y> = 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()
Expand All @@ -458,14 +463,14 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<t> = 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.<x> = FunctionField(GF(4)); _.<Y> = K[] # needs sage.rings.finite_rings
sage: L.<y> = 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()
Expand All @@ -489,7 +494,7 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(2)); _.<Y> = K[]
sage: L.<y> = 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)
Expand Down Expand Up @@ -517,7 +522,7 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[] # needs sage.rings.finite_rings
sage: L.<y> = 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():
Expand All @@ -544,7 +549,7 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[] # needs sage.rings.finite_rings
sage: L.<y> = 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():
Expand All @@ -570,7 +575,7 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[] # needs sage.rings.finite_rings
sage: L.<y> = 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()
Expand All @@ -590,7 +595,7 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[] # needs sage.rings.finite_rings
sage: L.<y> = 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()
Expand All @@ -607,8 +612,8 @@ cdef class FunctionFieldElement(FieldElement):
sage: K.<x> = FunctionField(GF(2)); _.<Y> = K[]
sage: L.<y> = 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
::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/element_polymod.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.rings.function_field
# sage.doctest: needs sage.rings.function_field
r"""
Elements of function fields: extension
"""
Expand Down
14 changes: 7 additions & 7 deletions src/sage/rings/function_field/element_rational.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement):
sage: K.<t> = 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.<t> = FunctionField(GF(131101)) # needs sage.libs.pari
sage: # needs sage.rings.finite_rings
sage: K.<t> = FunctionField(GF(131101))
sage: t.element()
t
sage: type(t.element())
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -437,7 +438,6 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement):
EXAMPLES::
sage: # needs sage.rings.finite_rings
sage: K.<x> = FunctionField(GF(3))
sage: f = (x+1)/(x+2)
sage: f.nth_root(1)
Expand All @@ -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:
Expand Down
Loading

0 comments on commit 2ff3027

Please sign in to comment.