Skip to content

Commit

Permalink
gh-39572: Change some instances of "gens" method to return tuples
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". -->

Contributes to #34120

As noted in the referenced issue. most instances of the "gens" method
return tuples, so the few instances of the method which return lists
instead should be modified to return tuples. This pull request handles
the following bullet points from the issue:
- `SymmetricReductionStrategy` in
`src/sage/rings/polynomial/symmetric_reduction.pyx`
- `EllipticCurve_number_field` in
`src/sage/schemes/elliptic_curves/ell_number_field.py`
- `SpecialCubicQuotientRing` in
`src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py`

In each case the gens method from the mentioned class has been modified
to return a tuple instead of a list and doctests have been updated
appropriately.

### 📝 Checklist

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

- [X] The title is concise and informative.
- [X] The description explains in detail what this PR is about.
- [X] I have linked a relevant issue or discussion.
- [X] I have created tests covering the changes.
- [X] 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: #39572
Reported by: Caleb Van't Land
Reviewer(s): Vincent Macri
  • Loading branch information
Release Manager committed Feb 27, 2025
2 parents 8806c7c + b9275d7 commit 1bc98df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/sage/rings/polynomial/symmetric_reduction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ cdef class SymmetricReductionStrategy:
return richcmp((left._parent, left._lm, left._tail),
(right._parent, right._lm, right._tail), op)

def gens(self) -> list:
def gens(self) -> tuple:
"""
Return the list of Infinite Polynomials modulo which ``self`` reduces.
Return the tuple of Infinite Polynomials modulo which ``self`` reduces.

EXAMPLES::

Expand All @@ -269,9 +269,9 @@ cdef class SymmetricReductionStrategy:
y_2*y_1^2,
y_2^2*y_1
sage: S.gens()
[y_2*y_1^2, y_2^2*y_1]
(y_2*y_1^2, y_2^2*y_1)
"""
return self._lm
return tuple(self._lm)

def setgens(self, L):
"""
Expand Down
18 changes: 9 additions & 9 deletions src/sage/schemes/elliptic_curves/ell_number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def base_extend(self, R):
[(52 : 111 : 1)]
sage: EK = E.base_extend(K)
sage: EK.gens()
[(52 : 111 : 1)]
((52 : 111 : 1),)
"""
E = super().base_extend(R)
if isinstance(E, EllipticCurve_number_field):
Expand Down Expand Up @@ -2328,21 +2328,21 @@ def gens(self, **kwds):
sage: K.<a> = NumberField(x^2 + 23, 'a')
sage: E = EllipticCurve(K,[0,0,0,101,0])
sage: E.gens()
[(23831509/8669448*a - 2867471/8669448 : 76507317707/18049790736*a - 424166479633/18049790736 : 1),
((23831509/8669448*a - 2867471/8669448 : 76507317707/18049790736*a - 424166479633/18049790736 : 1),
(-2031032029/969232392*a + 58813561/969232392 : -15575984630401/21336681877488*a + 451041199309/21336681877488 : 1),
(-186948623/4656964 : 549438861195/10049728312*a : 1)]
(-186948623/4656964 : 549438861195/10049728312*a : 1))
It can happen that no points are found if the height bounds
used in the search are too small (see :issue:`10745`)::
sage: K.<t> = NumberField(x^4 + x^2 - 7)
sage: E = EllipticCurve(K, [1, 0, 5*t^2 + 16, 0, 0])
sage: E.gens(lim1=1, lim3=1)
[]
()
sage: E.rank()
1
sage: gg=E.gens(lim3=13); gg # long time (about 4s)
[(... : 1)]
((... : 1),)
Check that the point found has infinite order, and that it is on the curve::
Expand All @@ -2356,7 +2356,7 @@ def gens(self, **kwds):
sage: K.<t> = NumberField(x^2 - 17)
sage: E = EllipticCurve(K, [-4, 0])
sage: E.gens()
[(-1/2*t + 1/2 : -1/2*t + 1/2 : 1), (-t + 3 : -2*t + 10 : 1)]
((-1/2*t + 1/2 : -1/2*t + 1/2 : 1), (-t + 3 : -2*t + 10 : 1))
sage: E.rank()
2
Expand All @@ -2368,7 +2368,7 @@ def gens(self, **kwds):
sage: EK.rank()
0
sage: EK.gens()
[]
()
IMPLEMENTATION:
Expand All @@ -2378,10 +2378,10 @@ def gens(self, **kwds):
PARI/GP scripts from http://www.math.unicaen.fr/~simon/.
"""
try:
return self.gens_quadratic(**kwds)
return tuple(self.gens_quadratic(**kwds))
except ValueError:
self.simon_two_descent(**kwds)
return self._known_points
return tuple(self._known_points)

def period_lattice(self, embedding):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def poly_ring(self):

def gens(self):
"""
Return a list [x, T] where x and T are the generators of the ring
Return a tuple (x, T) where x and T are the generators of the ring
(as element *of this ring*).
.. NOTE::
Expand Down

0 comments on commit 1bc98df

Please sign in to comment.