194
194
from sage .rings .rational_field import QQ
195
195
from sage .structure .element import Vector , ModuleElement
196
196
from sage .structure .richcmp import richcmp
197
+ from .weightspace import WeightSpace_constructor as WeightSpace , WeightCharacter
197
198
198
199
lazy_import ('sage.modular.modform.j_invariant' , 'j_invariant_qexp' )
199
200
lazy_import ('sage.rings.padics.factory' , 'Qp' , as_ = 'pAdicField' )
200
201
201
- from .weightspace import WeightSpace_constructor as WeightSpace , WeightCharacter
202
-
203
202
204
203
__ocmfdict = {}
205
204
@@ -268,6 +267,7 @@ def OverconvergentModularForms(prime, weight, radius, base_ring=QQ, prec=20, cha
268
267
__ocmfdict [key ] = weakref .ref (M )
269
268
return M
270
269
270
+
271
271
#########################
272
272
# Main class definition #
273
273
#########################
@@ -298,19 +298,21 @@ class OverconvergentModularFormsSpace(Module):
298
298
def __init__ (self , prime , weight , radius , base_ring , prec , char ):
299
299
r"""
300
300
Create a space of overconvergent `p`-adic modular forms of level
301
- `\Gamma_0(p)`, over the given base ring. The base ring need not be a
301
+ `\Gamma_0(p)`, over the given base ring.
302
+
303
+ The base ring need not be a
302
304
`p`-adic ring (the spaces we compute with typically have bases over
303
305
`\QQ`).
304
306
305
307
EXAMPLES::
306
308
307
- sage: OverconvergentModularForms(3, 0, 1/2)
309
+ sage: M = OverconvergentModularForms(3, 0, 1/2); M
308
310
Space of 3-adic 1/2-overconvergent modular forms of weight-character 0 over Rational Field
311
+ sage: TestSuite(M).run()
309
312
"""
310
-
311
313
self ._p = prime
312
314
313
- if not ( base_ring == QQ or isinstance (base_ring , sage .rings .abc .pAdicField ) ):
315
+ if not (base_ring == QQ or isinstance (base_ring , sage .rings .abc .pAdicField )):
314
316
raise TypeError ("Base ring must be QQ or a p-adic field" )
315
317
316
318
if base_ring != QQ and base_ring .prime () != self ._p :
@@ -328,13 +330,13 @@ def __init__(self, prime, weight, radius, base_ring, prec, char):
328
330
329
331
self ._prec = prec
330
332
331
- self ._qsr = PowerSeriesRing (base_ring , 'q' , prec ) # q-series ring
332
- self ._gsr = PowerSeriesRing (base_ring , 'g' , prec ) # g-adic expansions, g = c*f
333
+ self ._qsr = PowerSeriesRing (base_ring , 'q' , prec ) # q-series ring
334
+ self ._gsr = PowerSeriesRing (base_ring , 'g' , prec ) # g-adic expansions, g = c*f
333
335
334
336
self ._cached_recurrence_matrix = None
335
337
self ._set_radius (radius )
336
338
self ._basis_cache = [self ._wtchar .pAdicEisensteinSeries (self ._qsr , self .prec ())]
337
- self ._uniformiser = self ._qsr (EtaProduct (prime , {prime : 24 / ZZ (prime - 1 ), ZZ (1 ):- 24 / ZZ (prime - 1 )}).qexp (self .prec ()))
339
+ self ._uniformiser = self ._qsr (EtaProduct (prime , {prime : 24 / ZZ (prime - 1 ), ZZ (1 ): - 24 / ZZ (prime - 1 )}).qexp (self .prec ()))
338
340
339
341
for i in range (1 , self .prec ()):
340
342
self ._basis_cache .append (self ._basis_cache [- 1 ] * self ._uniformiser * self ._const )
@@ -374,7 +376,7 @@ def _set_radius(self, radius):
374
376
p = ZZ (self .prime ())
375
377
376
378
if (radius < 0 or radius > p / (p + 1 )):
377
- raise ValueError ("radius (=%s) must be between 0 and p/(p+1)" % radius )
379
+ raise ValueError ("radius (=%s) must be between 0 and p/(p+1)" % radius )
378
380
d = 12 / (p - 1 )* radius
379
381
if d .is_integral ():
380
382
self ._const = p ** ZZ (d )
@@ -383,7 +385,7 @@ def _set_radius(self, radius):
383
385
try :
384
386
pi = self .base_ring ().uniformiser ()
385
387
e = d / pi .normalized_valuation ()
386
- except AttributeError : # base ring isn't a p-adic ring
388
+ except AttributeError : # base ring isn't a p-adic ring
387
389
pi = p
388
390
e = d
389
391
if not e .is_integral ():
@@ -452,7 +454,7 @@ def _an_element_(self):
452
454
sage: OverconvergentModularForms(3, 2, 1/3, prec=4).an_element() # indirect doctest
453
455
3-adic overconvergent modular form of weight-character 2 with q-expansion 9*q + 216*q^2 + 2430*q^3 + O(q^4)
454
456
"""
455
- return OverconvergentModularFormElement (self , self ._gsr .an_element ())
457
+ return self . element_class (self , self ._gsr .an_element ())
456
458
457
459
def character (self ):
458
460
r"""
@@ -757,15 +759,15 @@ def _element_constructor_(self, input):
757
759
return self ._coerce_from_ocmf (input )
758
760
759
761
elif isinstance (input , ModularFormElement ):
760
- if ( (input .level () == 1 or input .level ().prime_factors () == [self .prime ()])
761
- and input .weight () == self .weight ().k ()
762
- and input .character ().primitive_character () == self .weight ().chi ().primitive_character ()):
763
- p = ZZ (self .prime ())
764
- nu = (input .level () == 1 and p / (p + 1 )) or (1 / (p + 1 ) * p ** (2 - input .level ().valuation (p )))
765
- if self .radius () > nu :
766
- raise ValueError ("Form is not overconvergent enough (form is only %s-overconvergent)" % nu )
767
- else :
768
- return self (self ._qsr (input .q_expansion (self .prec ())))
762
+ if ((input .level () == 1 or input .level ().prime_factors () == [self .prime ()])
763
+ and input .weight () == self .weight ().k ()
764
+ and input .character ().primitive_character () == self .weight ().chi ().primitive_character ()):
765
+ p = ZZ (self .prime ())
766
+ nu = (input .level () == 1 and p / (p + 1 )) or (1 / (p + 1 ) * p ** (2 - input .level ().valuation (p )))
767
+ if self .radius () > nu :
768
+ raise ValueError ("Form is not overconvergent enough (form is only %s-overconvergent)" % nu )
769
+ else :
770
+ return self (self ._qsr (input .q_expansion (self .prec ())))
769
771
else :
770
772
raise TypeError ("Cannot create an element of '%s' from element of incompatible space '%s'" % (self , input .parent ()))
771
773
@@ -836,10 +838,9 @@ def _coerce_map_from_(self, other):
836
838
3-adic overconvergent modular form of weight-character 0 with q-expansion 1 + O(q^20)
837
839
"""
838
840
if (isinstance (other , OverconvergentModularFormsSpace ) and
839
- self .base_ring ().has_coerce_map_from (other .base_ring ())):
841
+ self .base_ring ().has_coerce_map_from (other .base_ring ())):
840
842
return True
841
- else :
842
- return self .base_ring ().has_coerce_map_from (other )
843
+ return self .base_ring ().has_coerce_map_from (other )
843
844
844
845
def coordinate_vector (self , x ):
845
846
r"""
@@ -882,23 +883,6 @@ def ngens(self):
882
883
"""
883
884
return Infinity
884
885
885
- def gens_dict (self ):
886
- r"""
887
- Return a dictionary mapping the names of generators of this space to
888
- their values. (Required by parent class definition.) As this does not
889
- make any sense here, this raises a TypeError.
890
-
891
- EXAMPLES::
892
-
893
- sage: M = OverconvergentModularForms(2, 4, 1/6)
894
- sage: M.gens_dict()
895
- Traceback (most recent call last):
896
- ...
897
- TypeError: gens_dict does not make sense as number of generators is infinite
898
- """
899
-
900
- raise TypeError ("gens_dict does not make sense as number of generators is infinite" )
901
-
902
886
#####################################
903
887
# Routines with some actual content #
904
888
#####################################
@@ -999,15 +983,15 @@ def hecke_matrix(self, m, n, use_recurrence=False, exact_arith=False):
999
983
l = self ._convert_to_basis (self .hecke_operator (self ._basis_cache [j ], m ))
1000
984
for i in range (n ):
1001
985
try :
1002
- mat [i ,j ] = l [i ]
986
+ mat [i , j ] = l [i ]
1003
987
except IndexError :
1004
988
if not self .weight ().is_zero ():
1005
989
raise ValueError ("n is too large for current precision" )
1006
990
else :
1007
991
if i <= self .prime () * j :
1008
- raise ValueError ("n is too large computing initial conds: can't work out u[%s, %s]" % (i ,j ))
992
+ raise ValueError ("n is too large computing initial conds: can't work out u[%s, %s]" % (i , j ))
1009
993
else :
1010
- mat [i ,j ] = 0 # computations are exact for weight 0, and we know these terms are zero
994
+ mat [i , j ] = 0 # computations are exact for weight 0, and we know these terms are zero
1011
995
if use_recurrence :
1012
996
if m != self .prime ():
1013
997
raise ValueError ("Recurrence method not valid when m != p" )
@@ -1019,17 +1003,17 @@ def hecke_matrix(self, m, n, use_recurrence=False, exact_arith=False):
1019
1003
raise ValueError ("n is too large for current precision" )
1020
1004
else :
1021
1005
if j <= self .prime () * i :
1022
- raise ValueError ("n is too large computing initial conds: can't work out u[%s,%s]" % (i ,j ))
1023
- mat [i ,j ] = 0
1006
+ raise ValueError ("n is too large computing initial conds: can't work out u[%s,%s]" % (i , j ))
1007
+ mat [i , j ] = 0
1024
1008
1025
1009
else :
1026
1010
l = self ._convert_to_basis (self .hecke_operator (self ._basis_cache [j ], m ))
1027
1011
for i in range (self .prime ()):
1028
- mat [i ,j ] = l [i ]
1012
+ mat [i , j ] = l [i ]
1029
1013
for i in range (self .prime (), n ):
1030
1014
for u in range (self .prime ()):
1031
1015
for v in range (self .prime ()):
1032
- mat [i ,j ] = mat [i ,j ] + mat [i - u - 1 , j - v - 1 ]* self .recurrence_matrix ()[u ,v ]
1016
+ mat [i , j ] = mat [i , j ] + mat [i - u - 1 , j - v - 1 ]* self .recurrence_matrix ()[u , v ]
1033
1017
1034
1018
else :
1035
1019
if n * self .prime () > self .prec ():
@@ -1098,8 +1082,8 @@ def eigenfunctions(self, n, F=None, exact_arith=True):
1098
1082
F = self .base_ring ()
1099
1083
1100
1084
if F .is_exact ():
1101
- #raise TypeError, "cannot calculate eigenfunctions over exact base fields"
1102
- F = pAdicField (self .prime (), 100 )
1085
+ # raise TypeError, "cannot calculate eigenfunctions over exact base fields"
1086
+ F = pAdicField (self .prime (), 100 ) # noqa:F821
1103
1087
1104
1088
m = self .hecke_matrix (self .prime (), n , use_recurrence = True , exact_arith = exact_arith )
1105
1089
cp = m .charpoly ()
@@ -1144,7 +1128,7 @@ def eigenfunctions(self, n, F=None, exact_arith=True):
1144
1128
1145
1129
gexp = self ._gsr (0 )
1146
1130
for i in range (v .nrows ()):
1147
- gexp += self ._gsr .gen ()** i * F (v [i ,0 ])
1131
+ gexp += self ._gsr .gen ()** i * F (v [i , 0 ])
1148
1132
gexp = gexp + O (self ._gsr .gen ()** int (v .nrows ()))
1149
1133
1150
1134
if gexp [0 ] != 0 :
@@ -1166,8 +1150,8 @@ def eigenfunctions(self, n, F=None, exact_arith=True):
1166
1150
# up with garbage. I don't know why. XXX FIX THIS XXX
1167
1151
eigenfunctions .append ((r .valuation (), efunc ))
1168
1152
1169
- eigenfunctions .sort () # sort by slope
1170
- return [f for _ ,f in eigenfunctions ]
1153
+ eigenfunctions .sort () # sort by slope
1154
+ return [f for _ , f in eigenfunctions ]
1171
1155
1172
1156
def recurrence_matrix (self , use_smithline = True ):
1173
1157
r"""
@@ -1232,13 +1216,13 @@ def _discover_recurrence_matrix(self, use_smithline=True):
1232
1216
1233
1217
if use_smithline :
1234
1218
# Compute Smithline's polynomial H_p
1235
- jq = self ._qsr (j_invariant_qexp (1 + self .prime ()).shift (1 ).power_series ())
1219
+ jq = self ._qsr (j_invariant_qexp (1 + self .prime ()).shift (1 ).power_series ()) # noqa:F821
1236
1220
1237
1221
# avoid dividing by q so as not to instantiate a Laurent series
1238
1222
h = self ._uniformiser .shift (- 1 ) * jq
1239
1223
fi = self ._qsr (1 )
1240
1224
coeffs = []
1241
- for i in range (self .prime ()+ 2 ):
1225
+ for i in range (self .prime () + 2 ):
1242
1226
if not h .valuation () >= i :
1243
1227
raise ValueError ("Something strange is happening here" )
1244
1228
@@ -1247,15 +1231,15 @@ def _discover_recurrence_matrix(self, use_smithline=True):
1247
1231
fi = fi * self ._uniformiser
1248
1232
SmiH = f_ring (coeffs )
1249
1233
assert SmiH .degree () == self .prime () + 1
1250
- xyring = PolynomialRing (self .base_ring (), ["x" ,"y" ], 2 )
1251
- x ,y = xyring .gens ()
1234
+ xyring = PolynomialRing (self .base_ring (), ["x" , "y" ], 2 )
1235
+ x , y = xyring .gens ()
1252
1236
cc = self .prime () ** (- 12 / (self .prime () - 1 ))
1253
1237
bigI = x * SmiH (y * cc ) - y * cc * SmiH (x )
1254
1238
smallI = xyring (bigI / (x - cc * y ))
1255
1239
r = matrix (ZZ , self .prime (), self .prime ())
1256
1240
for i in range (self .prime ()):
1257
1241
for j in range (self .prime ()):
1258
- r [i ,j ] = - smallI [i + 1 , j + 1 ]
1242
+ r [i , j ] = - smallI [i + 1 , j + 1 ]
1259
1243
return r
1260
1244
else :
1261
1245
# compute from U(f^j) for small j via Newton's identities
@@ -1296,6 +1280,7 @@ def cps_u(self, n, use_recurrence=False):
1296
1280
1297
1281
return g
1298
1282
1283
+
1299
1284
class OverconvergentModularFormElement (ModuleElement ):
1300
1285
r"""
1301
1286
A class representing an element of a space of overconvergent modular forms.
@@ -1318,18 +1303,17 @@ def __init__(self, parent, gexp=None, qexp=None):
1318
1303
sage: OverconvergentModularForms(3, 2, 1/6,prec=5).an_element() # indirect doctest
1319
1304
3-adic overconvergent modular form of weight-character 2 with q-expansion 3*q + 72*q^2 + 810*q^3 + 6096*q^4 + O(q^5)
1320
1305
"""
1321
-
1322
1306
ModuleElement .__init__ (self , parent )
1323
1307
1324
1308
self ._p = self .parent ().prime ()
1325
- #self.weight = self.parent().weight
1309
+ # self.weight = self.parent().weight
1326
1310
if (gexp is None and qexp is None ) or (gexp is not None and qexp is not None ):
1327
1311
raise ValueError ("Must supply exactly one of a q-expansion and a g-expansion" )
1328
1312
if gexp is not None :
1329
1313
self ._gexp = gexp .add_bigoh (self .parent ().prec ())
1330
1314
self ._qexp = sum ([self .parent ()._basis_cache [i ] * gexp [i ] for i in range (min (gexp .prec (), self .parent ().prec ()))])
1331
1315
self ._qexp = self ._qexp .add_bigoh (self ._gexp .prec ())
1332
- else : # qexp is not None
1316
+ else : # qexp is not None
1333
1317
self ._qexp = qexp .add_bigoh (self .parent ().prec ())
1334
1318
self ._gexp = self .parent ()._convert_to_basis (self ._qexp )
1335
1319
@@ -1433,7 +1417,9 @@ def slope(self):
1433
1417
1434
1418
def eigenvalue (self ):
1435
1419
r"""
1436
- Return the `U_p`-eigenvalue of this eigenform. Raises an error unless
1420
+ Return the `U_p`-eigenvalue of this eigenform.
1421
+
1422
+ This raises an error unless
1437
1423
this element was explicitly flagged as an eigenform, using the
1438
1424
_notify_eigen function.
1439
1425
@@ -1547,13 +1533,12 @@ def is_integral(self):
1547
1533
sage: M(q - q^2/2 + 6*q^7 + O(q^9)).is_integral()
1548
1534
False
1549
1535
"""
1550
-
1551
1536
for co in self .q_expansion ().list ():
1552
- if (co * (1 + O (self .prime ()))).valuation () < 0 : # have to force it into ZZ_p
1537
+ if (co * (1 + O (self .prime ()))).valuation () < 0 : # have to force it into ZZ_p
1553
1538
return False
1554
1539
return True
1555
1540
1556
- def _repr_ (self ):
1541
+ def _repr_ (self ) -> str :
1557
1542
r"""
1558
1543
String representation of ``self``.
1559
1544
@@ -1598,10 +1583,10 @@ def r_ord(self, r):
1598
1583
1599
1584
F = self .parent ().base_ring ()
1600
1585
if not isinstance (F , sage .rings .abc .pAdicField ):
1601
- F = pAdicField (p )
1586
+ F = pAdicField (p ) # noqa:F821
1602
1587
1603
1588
for i in range (self .prec ()):
1604
- ord = max ( ord , 12 / ZZ (p - 1 )* i * (r - s ) - F (self .gexp ()[i ]).normalized_valuation ())
1589
+ ord = max (ord , 12 / ZZ (p - 1 )* i * (r - s ) - F (self .gexp ()[i ]).normalized_valuation ())
1605
1590
1606
1591
return ord
1607
1592
@@ -1638,7 +1623,7 @@ def governing_term(self, r):
1638
1623
p = self .prime ()
1639
1624
F = self .parent ().base_ring ()
1640
1625
if not isinstance (F , sage .rings .abc .pAdicField ):
1641
- F = pAdicField (p )
1626
+ F = pAdicField (p ) # noqa:F821
1642
1627
s = self .parent ().radius ()
1643
1628
p = self .prime ()
1644
1629
@@ -1729,3 +1714,6 @@ def __pari__(self):
1729
1714
(3^3 + O(3^23))*q + (3^4 + 3^5 + O(3^24))*q^2 + (3^5 + 3^7 + O(3^25))*q^3 + (3^3 + 3^4 + 2*3^5 + 2*3^8 + O(3^23))*q^4 + (2*3^4 + 3^5 + 3^6 + 2*3^7 + 3^10 + O(3^24))*q^5 + (3^6 + 3^7 + 3^8 + 3^9 + 3^10 + 3^11 + O(3^26))*q^6 + (2*3^3 + 3^4 + 2*3^6 + 2*3^7 + 2*3^8 + 3^9 + 3^10 + 2*3^11 + 3^12 + O(3^23))*q^7 + (2*3^4 + 3^5 + 3^8 + 2*3^9 + 2*3^10 + 2*3^13 + O(3^24))*q^8 + (3^7 + 2*3^9 + 2*3^12 + 2*3^14 + O(3^27))*q^9 + (2*3^5 + 3^8 + 3^9 + 2*3^10 + 2*3^13 + 2*3^15 + O(3^25))*q^10 + (3^4 + 2*3^5 + 2*3^6 + 3^8 + 2*3^9 + 3^12 + 3^14 + 2*3^16 + O(3^24))*q^11 + (3^5 + 3^6 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^12 + 3^14 + 2*3^15 + 2*3^16 + 3^17 + O(3^25))*q^12 + (2*3^3 + 2*3^4 + 2*3^5 + 3^8 + 2*3^9 + 2*3^11 + 3^13 + 2*3^14 + 2*3^17 + 3^18 + O(3^23))*q^13 + (2*3^4 + 2*3^6 + 2*3^7 + 3^8 + 2*3^9 + 3^10 + 3^12 + 3^14 + 2*3^15 + 2*3^16 + 3^18 + 3^19 + O(3^24))*q^14 + (2*3^6 + 3^7 + 3^9 + 3^10 + 3^11 + 2*3^14 + 3^15 + 2*3^16 + 3^17 + 3^18 + 3^20 + O(3^26))*q^15 + (3^3 + 2*3^4 + 2*3^7 + 2*3^8 + 3^9 + 3^10 + 2*3^11 + 3^12 + 2*3^14 + 2*3^15 + 3^17 + 3^18 + 2*3^19 + 2*3^20 + O(3^23))*q^16 + (2*3^5 + 2*3^7 + 2*3^8 + 3^10 + 3^11 + 2*3^12 + 2*3^13 + 3^14 + 3^15 + 3^17 + 2*3^18 + 3^19 + 2*3^21 + O(3^25))*q^17 + (3^8 + 3^9 + 2*3^10 + 2*3^11 + 3^12 + 3^14 + 3^15 + 3^16 + 3^17 + 2*3^21 + 3^22 + O(3^28))*q^18 + (2*3^3 + 3^5 + 2*3^6 + 2*3^8 + 2*3^9 + 3^11 + 2*3^12 + 3^13 + 3^14 + 2*3^15 + 3^16 + 3^17 + 2*3^18 + 3^19 + 2*3^21 + O(3^23))*q^19 + O(q^20)
1730
1715
"""
1731
1716
return self .q_expansion ().__pari__ ()
1717
+
1718
+
1719
+ OverconvergentModularFormsSpace .Element = OverconvergentModularFormElement
0 commit comments