Skip to content

Should the gens of a group, ring, or ideal always be a tuple? #34120

@DaveWitteMorris

Description

@DaveWitteMorris

Looking at all occurrences of def gens in the sagemath source code reveals that the output of the gens method is a tuple in the vast majority of cases (including for the class ParentWithGens in src/sage/structure/parent_gens.pyx). In fact, the final line of the source code of the method is usually return tuple( <something> ). However, the search uncovered several exceptions that return a list:

  • FiniteGCAlgebra in src/sage/algebras/finite_gca.py
  • AbstractLinearCodeNoMetric in src/sage/coding/linear_code_no_metric.py
  • PermutationGroup_generic in src/sage/groups/perm_gps/permgroup.py -- the docstring says the method will return a tuple, and that seems to usually be the case, but SymmetricGroup(1).gens() is a list (and the same if 1 is replaced with some other number). This is clearly a bug, because the output type does not match the documentation.
  • SemimonomialTransformationGroup in src/sage/semimonomial_transformations/semimonomial_transformation_group.py -- the docstring says that the method will return a tuple, so this is another clear bug.
  • MagmaElement in src/sage/interfaces/magma.py
  • mwrank_EllipticCurve in src/sage/eclib/interface.py
  • FiniteSubgroup in src/sage/modular/abvar/finite_subgroup.py
  • ModularFormsSpace in src/sage/modular/modform/space.py
  • QuasiModularForms, QuasiCuspForms, ModularForms, CuspForms, and ZeroForm in src/sage/modular/modform_hecketriangle/space.py
  • SubSpaceForms in src/sage/modular/modform_hecketriangle/subspace.py
  • PollackStevensModularDomain in src/sage/modular/pollack_stevens/fund_domain.py
  • QuasiModularForms in src/sage/modular/quasimodform/ring.py
  • QuiverHomSpace in src/sage/quivers/homspace.py
  • QuiverRep_generic in src/sage/quivers/representation.py
  • UnsignedInfinityRing_class and InfinityRing_class in src/sage/rings/infinite.py
  • InfinityRing_class in src/sage/rings/padics/padic_generic.py
  • MPolynomialIdeal in src/sage/rings/polynomial/mult_polynomial_ideal.py -- the value is of type PolynomialSequence, which seems to be an immutable list. Single-variable polynomials return a tuple, and it would be good for the two to be consistent, even if we do not change the others in this list. This was pointed out in #34105 comment:4.
  • SymmetricReductionStrategy in src/sage/rings/polynomial/symmetric_reduction.pyx
  • RealIntervalField_class in src/sage/rings/real_mpfi.pyx
  • RealField_class in src/sage/rings/real_mpfr.pyx
  • EllipticCurve_number_field in src/sage/schemes/elliptic_curves/ell_number_field.py
  • EllipticCurve_rational_field in src/sage/schemes/elliptic_curves/ell_rational_field.py
  • SpecialCubicQuotientRing in src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py

Perhaps most (or all) of the above should be changed to a tuple.

An iterator or Family is returned in the following cases, but that makes sense because the set of generators may be infinite:

  • SteenrodAlgebra_generic in src/sage/algebras/steenrod/steenrod_algebra.py
  • HeckeAlgebra_base and HeckeAlgebra_anemic in src/sage/modular/hecke/algebra.py
  • OverconvergentModularFormsSpace in src/sage/modular/overconvergent/genus0.py
  • AlgebraicClosureFiniteField_generic in src/sage/rings/algebraic_closure_finite_field.py

This ticket arose from #34105 comment:4, which pointed out that multivariate polynomials behave differently than single-variable polynomials.

Related ticket: #33824 (make gens and orbits of PermutationGroup immutable)

CC: @yyyyx4

Component: algebra

Keywords: gens, tuple, list

Branch/Commit: public/ticket-34120 @ 52a359b

Issue created by migration from https://trac.sagemath.org/ticket/34120

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions