Skip to content

Commit dcc34e2

Browse files
author
Release Manager
committed
Trac #34698: Fix conversion bug in modular forms rings
We currently have the following behavior: {{{ sage: M = ModularFormsRing(Gamma0(2)) sage: E4 = ModularForms(1, 4).0 sage: F = M(E4) sage: F[4].parent() Modular Forms space of dimension 1 for Modular Group SL(2,Z) of weight 4 over Rational Field }}} The parent of `F[4]` is wrong as the group should be `Gamma0(2)`. URL: https://trac.sagemath.org/34698 Reported by: gh-DavidAyotte Ticket author(s): David Ayotte Reviewer(s): Vincent Delecroix
2 parents fb4c96a + ba35b10 commit dcc34e2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/sage/modular/modform/element.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,6 +3234,14 @@ def __init__(self, parent, forms_datum):
32343234
Traceback (most recent call last):
32353235
...
32363236
ValueError: the group and/or the base ring of at least one modular form (q - 6*q^2 + 9*q^3 + 4*q^4 + 6*q^5 + O(q^6)) is not consistant with the base space
3237+
sage: M = ModularFormsRing(Gamma0(2))
3238+
sage: E4 = ModularForms(1, 4).0
3239+
sage: M(E4)[4].parent()
3240+
Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(2) of weight 4 over Rational Field
3241+
sage: M = ModularFormsRing(Gamma1(3), base_ring=GF(7))
3242+
sage: E6 = ModularForms(1, 6, base_ring=GF(7)).0
3243+
sage: M(E6)[6].parent()
3244+
Modular Forms space of dimension 3 for Congruence Subgroup Gamma1(3) of weight 6 over Finite Field of size 7
32373245
"""
32383246
forms_dictionary = {}
32393247
if isinstance(forms_datum, dict):
@@ -3245,7 +3253,8 @@ def __init__(self, parent, forms_datum):
32453253
elif is_ModularFormElement(f):
32463254
if f.weight() == k:
32473255
if parent.group().is_subgroup(f.group()) and parent.base_ring().has_coerce_map_from(f.base_ring()):
3248-
forms_dictionary[k] = f
3256+
M = parent.modular_forms_of_weight(f.weight()).change_ring(parent.base_ring())
3257+
forms_dictionary[k] = M(f)
32493258
else:
32503259
raise ValueError('the group and/or the base ring of at least one modular form (%s) is not consistant with the base space' % (f))
32513260
else:
@@ -3261,7 +3270,8 @@ def __init__(self, parent, forms_datum):
32613270
if (chi is not None) and (not chi.is_trivial()):
32623271
raise NotImplementedError("graded modular forms for non-trivial characters is not yet implemented")
32633272
if parent.group().is_subgroup(f.group()) and parent.base_ring().has_coerce_map_from(f.base_ring()):
3264-
forms_dictionary[f.weight()] = forms_dictionary.get(f.weight(), 0) + f
3273+
M = parent.modular_forms_of_weight(f.weight()).change_ring(parent.base_ring())
3274+
forms_dictionary[f.weight()] = M(forms_dictionary.get(f.weight(), 0) + f)
32653275
else:
32663276
raise ValueError('the group and/or the base ring of at least one modular form (%s) is not consistant with the base space' % (f))
32673277
else:

src/sage/modular/modform/ring.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def _generators_variables_dictionnary(self, poly_parent, gens):
397397
nb_gens = self.ngens()
398398
if nb_var != nb_gens:
399399
raise ValueError('the number of variables (%s) must be equal to the number of generators of the modular forms ring (%s)'%(nb_var, self.ngens()))
400-
return {poly_parent.gen(i) : self(gens[i]) for i in range(0, nb_var)}
400+
return {poly_parent.gen(i): self(gens[i]) for i in range(0, nb_var)}
401401

402402
def from_polynomial(self, polynomial, gens=None):
403403
r"""
@@ -518,7 +518,7 @@ def _element_constructor_(self, forms_datum):
518518
forms_dictionary = forms_datum._forms_dictionary
519519
elif is_ModularFormElement(forms_datum):
520520
if self.group().is_subgroup(forms_datum.group()) and self.base_ring().has_coerce_map_from(forms_datum.base_ring()):
521-
forms_dictionary = {forms_datum.weight():forms_datum}
521+
forms_dictionary = {forms_datum.weight(): forms_datum}
522522
else:
523523
raise ValueError('the group (%s) and/or the base ring (%s) of the given modular form is not consistant with the base space: %s'%(forms_datum.group(), forms_datum.base_ring(), self))
524524
elif forms_datum in self.base_ring():

0 commit comments

Comments
 (0)