2727from sage .matrix .constructor import Matrix
2828from sage .misc .cachefunc import cached_method
2929from sage .misc .misc_c import prod
30- from sage .misc .superseded import deprecated_function_alias
3130from sage .misc .verbose import verbose
3231from sage .modular .arithgroup .congroup_gamma0 import Gamma0_constructor as Gamma0
3332from sage .modular .arithgroup .congroup_generic import CongruenceSubgroupBase
4645from .space import ModularFormsSpace
4746
4847
49- def _span_of_forms_in_weight (forms , weight , prec , stop_dim = None , use_random = False ):
48+ def _span_of_forms_in_weight (forms , weight , prec ,
49+ stop_dim = None , use_random = False ):
5050 r"""
5151 Utility function. Given a nonempty list of pairs ``(k,f)``, where `k` is an
5252 integer and `f` is a power series, and a weight l, return all weight l
@@ -62,10 +62,10 @@ def _span_of_forms_in_weight(forms, weight, prec, stop_dim=None, use_random=Fals
6262 - ``stop_dim`` -- integer; stop as soon as we have enough forms to span
6363 a submodule of this rank (a saturated one if the base ring is `\ZZ`).
6464 Ignored if ``use_random`` is ``False``.
65- - ``use_random`` -- which algorithm to use. If ``True``, tries random products
66- of the generators of the appropriate weight until a large enough
67- submodule is found (determined by ``stop_dim``). If ``False``, just tries
68- everything.
65+ - ``use_random`` -- which algorithm to use. If ``True``, tries random
66+ products of the generators of the appropriate weight until a
67+ large enough submodule is found (determined by ``stop_dim``). If
68+ ``False``, just tries everything.
6969
7070 Note that if the given forms do generate the whole space, then
7171 ``use_random=True`` will often be quicker (particularly if the weight is
@@ -78,7 +78,8 @@ def _span_of_forms_in_weight(forms, weight, prec, stop_dim=None, use_random=Fals
7878 EXAMPLES::
7979
8080 sage: import sage.modular.modform.ring as f
81- sage: forms = [(4, 240*eisenstein_series_qexp(4,5)), (6,504*eisenstein_series_qexp(6,5))]
81+ sage: forms = [(4, 240*eisenstein_series_qexp(4, 5)),
82+ ....: (6, 504*eisenstein_series_qexp(6, 5))]
8283 sage: f._span_of_forms_in_weight(forms, 12, prec=5)
8384 Vector space of degree 5 and dimension 2 over Rational Field
8485 Basis matrix:
@@ -136,12 +137,13 @@ def _span_of_forms_in_weight(forms, weight, prec, stop_dim=None, use_random=Fals
136137 return W
137138 verbose ("Nothing worked" , t )
138139 return W
139- else :
140- G = [V (prod (forms [i ][1 ]** c [i ] for i in range (n )).padded_list (prec )) for c in wts ]
141- t = verbose ('found %s candidates' % N , t )
142- W = V .span (G )
143- verbose ('span has dimension %s' % W .rank (), t )
144- return W
140+
141+ G = [V (prod (forms [i ][1 ]** c [i ] for i in range (n )).padded_list (prec ))
142+ for c in wts ]
143+ t = verbose (f'found { N } candidates' , t )
144+ W = V .span (G )
145+ verbose (f'span has dimension { W .rank ()} ' , t )
146+ return W
145147
146148
147149@richcmp_method
@@ -194,7 +196,7 @@ class ModularFormsRing(Parent):
194196
195197 Element = GradedModularFormElement
196198
197- def __init__ (self , group , base_ring = QQ ):
199+ def __init__ (self , group , base_ring = QQ ) -> None :
198200 r"""
199201 INPUT:
200202
@@ -267,7 +269,7 @@ def change_ring(self, base_ring):
267269 """
268270 return ModularFormsRing (self .group (), base_ring = base_ring )
269271
270- def some_elements (self ):
272+ def some_elements (self ) -> list :
271273 r"""
272274 Return some elements of this ring.
273275
@@ -313,7 +315,7 @@ def gen(self, i):
313315 raise NotImplementedError ("the base ring of the given ring of modular form should be QQ" )
314316 return self (self .gen_forms ()[i ])
315317
316- def ngens (self ):
318+ def ngens (self ) -> int :
317319 r"""
318320 Return the number of generators of this ring.
319321
@@ -473,7 +475,7 @@ def from_polynomial(self, polynomial, gens=None):
473475
474476 * add conversion for symbolic expressions?
475477 """
476- if not self .base_ring () == QQ : # this comes from the method gens_form
478+ if not self .base_ring () == QQ : # this comes from the method gens_form
477479 raise NotImplementedError ("conversion from polynomial is not implemented if the base ring is not Q" )
478480 if not isinstance (polynomial , MPolynomial ):
479481 raise TypeError ('`polynomial` must be a multivariate polynomial' )
@@ -615,7 +617,7 @@ def _coerce_map_from_(self, M):
615617 return True
616618 return self .base_ring ().has_coerce_map_from (M )
617619
618- def __richcmp__ (self , other , op ):
620+ def __richcmp__ (self , other , op ) -> bool :
619621 r"""
620622 Compare ``self`` to ``other``.
621623
@@ -636,7 +638,7 @@ def __richcmp__(self, other, op):
636638 return richcmp ((self .group (), self .base_ring ()),
637639 (other .group (), other .base_ring ()), op )
638640
639- def _repr_ (self ):
641+ def _repr_ (self ) -> str :
640642 r"""
641643 Return the string representation of ``self``.
642644
@@ -664,9 +666,10 @@ def modular_forms_of_weight(self, weight):
664666 """
665667 return ModularForms (self .group (), weight )
666668
667- def generators (self , maxweight = 8 , prec = 10 , start_gens = [], start_weight = 2 ):
669+ def generators (self , maxweight = 8 , prec = 10 , start_gens = [],
670+ start_weight = 2 ) -> list :
668671 r"""
669- Return a list of generator of this ring as a list of pairs
672+ Return a list of generators of this ring as a list of pairs
670673 `(k, f)` where `k` is an integer and `f` is a univariate power
671674 series in `q` corresponding to the `q`-expansion of a modular
672675 form of weight `k`.
@@ -811,15 +814,17 @@ def generators(self, maxweight=8, prec=10, start_gens=[], start_weight=2):
811814 if len (x ) == 2 :
812815 if x [1 ].prec () < prec :
813816 raise ValueError ("Requested precision cannot be higher"
814- " than precision of approximate starting generators!" )
817+ " than precision of approximate starting "
818+ "generators!" )
815819 sgs .append ((x [0 ], x [1 ], None ))
816820 else :
817821 sgs .append (x )
818822
819823 G = self ._find_generators (maxweight , tuple (sgs ), start_weight )
820824
821825 ret = []
822- # Returned generators may be a funny mixture of precisions if start_gens has been used.
826+ # Returned generators may be a funny mixture of precisions if
827+ # start_gens has been used.
823828 for k , f , F in G :
824829 if f .prec () < prec :
825830 f = F .qexp (prec ).change_ring (self .base_ring ())
@@ -829,7 +834,7 @@ def generators(self, maxweight=8, prec=10, start_gens=[], start_weight=2):
829834
830835 return ret
831836
832- def gen_forms (self , maxweight = 8 , start_gens = [], start_weight = 2 ):
837+ def gen_forms (self , maxweight = 8 , start_gens = [], start_weight = 2 ) -> list :
833838 r"""
834839 Return a list of modular forms generating this ring (as an algebra
835840 over the appropriate base ring).
@@ -872,9 +877,9 @@ def gen_forms(self, maxweight=8, start_gens=[], start_weight=2):
872877
873878 gens = gen_forms
874879
875- def _find_generators (self , maxweight , start_gens , start_weight ):
880+ def _find_generators (self , maxweight , start_gens , start_weight ) -> list :
876881 r"""
877- Returns a list of triples `(k, f, F)` where `F` is a modular
882+ Return a list of triples `(k, f, F)` where `F` is a modular
878883 form of weight `k` and `f` is its `q`-expansion coerced into the
879884 base ring of self.
880885
@@ -982,7 +987,7 @@ def _find_generators(self, maxweight, start_gens, start_weight):
982987 except AttributeError :
983988 # work around a silly free module bug
984989 qc = V .coordinates (q .lift ())
985- qcZZ = [ZZ (_ ) for _ in qc ] # lift to ZZ so we can define F
990+ qcZZ = [ZZ (_ ) for _ in qc ] # lift to ZZ so we can define F
986991 f = sum ([B [i ] * qcZZ [i ] for i in range (len (B ))])
987992 F = M (f )
988993 G .append ((k , f .change_ring (self .base_ring ()), F ))
@@ -1125,7 +1130,7 @@ def cuspidal_ideal_generators(self, maxweight=8, prec=None):
11251130 except AttributeError :
11261131 # work around a silly free module bug
11271132 qc = V .coordinates (q .lift ())
1128- qcZZ = [ZZ (_ ) for _ in qc ] # lift to ZZ so we can define F
1133+ qcZZ = [ZZ (_ ) for _ in qc ] # lift to ZZ so we can define F
11291134 f = sum ([B [i ] * qcZZ [i ] for i in range (len (B ))])
11301135 F = S (f )
11311136 G .append ((k , f .change_ring (self .base_ring ()), F ))
@@ -1241,14 +1246,10 @@ def _to_matrix(self, gens=None, prec=None):
12411246 gens = self .gen_forms ()
12421247
12431248 if prec is None :
1244- # we don't default to prec=6 because this is an internal function
1245- # and is usually used to write other forms as a linear combination
1246- # of generators, in which case using the Sturm bound is more reasonable
1249+ # we do not default to prec=6 because this is an internal
1250+ # function and is usually used to write other forms as a
1251+ # linear combination of generators, in which case using
1252+ # the Sturm bound is more reasonable
12471253 prec = max (gen .group ().sturm_bound (gen .weight ()) for gen in gens )
12481254
12491255 return Matrix (gen .coefficients (range (prec + 1 )) for gen in gens )
1250-
1251-
1252- # Deprecated functions
1253- find_generators = deprecated_function_alias (31559 , ModularFormsRing .generators )
1254- basis_for_modform_space = deprecated_function_alias (31559 , ModularFormsRing .q_expansion_basis )
0 commit comments