27
27
from sage .matrix .constructor import Matrix
28
28
from sage .misc .cachefunc import cached_method
29
29
from sage .misc .misc_c import prod
30
- from sage .misc .superseded import deprecated_function_alias
31
30
from sage .misc .verbose import verbose
32
31
from sage .modular .arithgroup .congroup_gamma0 import Gamma0_constructor as Gamma0
33
32
from sage .modular .arithgroup .congroup_generic import CongruenceSubgroupBase
46
45
from .space import ModularFormsSpace
47
46
48
47
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 ):
50
50
r"""
51
51
Utility function. Given a nonempty list of pairs ``(k,f)``, where `k` is an
52
52
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
62
62
- ``stop_dim`` -- integer; stop as soon as we have enough forms to span
63
63
a submodule of this rank (a saturated one if the base ring is `\ZZ`).
64
64
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.
69
69
70
70
Note that if the given forms do generate the whole space, then
71
71
``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
78
78
EXAMPLES::
79
79
80
80
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))]
82
83
sage: f._span_of_forms_in_weight(forms, 12, prec=5)
83
84
Vector space of degree 5 and dimension 2 over Rational Field
84
85
Basis matrix:
@@ -136,12 +137,13 @@ def _span_of_forms_in_weight(forms, weight, prec, stop_dim=None, use_random=Fals
136
137
return W
137
138
verbose ("Nothing worked" , t )
138
139
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
145
147
146
148
147
149
@richcmp_method
@@ -194,7 +196,7 @@ class ModularFormsRing(Parent):
194
196
195
197
Element = GradedModularFormElement
196
198
197
- def __init__ (self , group , base_ring = QQ ):
199
+ def __init__ (self , group , base_ring = QQ ) -> None :
198
200
r"""
199
201
INPUT:
200
202
@@ -267,7 +269,7 @@ def change_ring(self, base_ring):
267
269
"""
268
270
return ModularFormsRing (self .group (), base_ring = base_ring )
269
271
270
- def some_elements (self ):
272
+ def some_elements (self ) -> list :
271
273
r"""
272
274
Return some elements of this ring.
273
275
@@ -313,7 +315,7 @@ def gen(self, i):
313
315
raise NotImplementedError ("the base ring of the given ring of modular form should be QQ" )
314
316
return self (self .gen_forms ()[i ])
315
317
316
- def ngens (self ):
318
+ def ngens (self ) -> int :
317
319
r"""
318
320
Return the number of generators of this ring.
319
321
@@ -473,7 +475,7 @@ def from_polynomial(self, polynomial, gens=None):
473
475
474
476
* add conversion for symbolic expressions?
475
477
"""
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
477
479
raise NotImplementedError ("conversion from polynomial is not implemented if the base ring is not Q" )
478
480
if not isinstance (polynomial , MPolynomial ):
479
481
raise TypeError ('`polynomial` must be a multivariate polynomial' )
@@ -615,7 +617,7 @@ def _coerce_map_from_(self, M):
615
617
return True
616
618
return self .base_ring ().has_coerce_map_from (M )
617
619
618
- def __richcmp__ (self , other , op ):
620
+ def __richcmp__ (self , other , op ) -> bool :
619
621
r"""
620
622
Compare ``self`` to ``other``.
621
623
@@ -636,7 +638,7 @@ def __richcmp__(self, other, op):
636
638
return richcmp ((self .group (), self .base_ring ()),
637
639
(other .group (), other .base_ring ()), op )
638
640
639
- def _repr_ (self ):
641
+ def _repr_ (self ) -> str :
640
642
r"""
641
643
Return the string representation of ``self``.
642
644
@@ -664,9 +666,10 @@ def modular_forms_of_weight(self, weight):
664
666
"""
665
667
return ModularForms (self .group (), weight )
666
668
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 :
668
671
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
670
673
`(k, f)` where `k` is an integer and `f` is a univariate power
671
674
series in `q` corresponding to the `q`-expansion of a modular
672
675
form of weight `k`.
@@ -811,15 +814,17 @@ def generators(self, maxweight=8, prec=10, start_gens=[], start_weight=2):
811
814
if len (x ) == 2 :
812
815
if x [1 ].prec () < prec :
813
816
raise ValueError ("Requested precision cannot be higher"
814
- " than precision of approximate starting generators!" )
817
+ " than precision of approximate starting "
818
+ "generators!" )
815
819
sgs .append ((x [0 ], x [1 ], None ))
816
820
else :
817
821
sgs .append (x )
818
822
819
823
G = self ._find_generators (maxweight , tuple (sgs ), start_weight )
820
824
821
825
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.
823
828
for k , f , F in G :
824
829
if f .prec () < prec :
825
830
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):
829
834
830
835
return ret
831
836
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 :
833
838
r"""
834
839
Return a list of modular forms generating this ring (as an algebra
835
840
over the appropriate base ring).
@@ -872,9 +877,9 @@ def gen_forms(self, maxweight=8, start_gens=[], start_weight=2):
872
877
873
878
gens = gen_forms
874
879
875
- def _find_generators (self , maxweight , start_gens , start_weight ):
880
+ def _find_generators (self , maxweight , start_gens , start_weight ) -> list :
876
881
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
878
883
form of weight `k` and `f` is its `q`-expansion coerced into the
879
884
base ring of self.
880
885
@@ -982,7 +987,7 @@ def _find_generators(self, maxweight, start_gens, start_weight):
982
987
except AttributeError :
983
988
# work around a silly free module bug
984
989
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
986
991
f = sum ([B [i ] * qcZZ [i ] for i in range (len (B ))])
987
992
F = M (f )
988
993
G .append ((k , f .change_ring (self .base_ring ()), F ))
@@ -1125,7 +1130,7 @@ def cuspidal_ideal_generators(self, maxweight=8, prec=None):
1125
1130
except AttributeError :
1126
1131
# work around a silly free module bug
1127
1132
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
1129
1134
f = sum ([B [i ] * qcZZ [i ] for i in range (len (B ))])
1130
1135
F = S (f )
1131
1136
G .append ((k , f .change_ring (self .base_ring ()), F ))
@@ -1241,14 +1246,10 @@ def _to_matrix(self, gens=None, prec=None):
1241
1246
gens = self .gen_forms ()
1242
1247
1243
1248
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
1247
1253
prec = max (gen .group ().sturm_bound (gen .weight ()) for gen in gens )
1248
1254
1249
1255
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