Skip to content

Commit 24f2d2d

Browse files
authored
Merge pull request #6443 from fchapoton/siegel_full_pep8
2 parents 7bfd225 + 5970c43 commit 24f2d2d

5 files changed

Lines changed: 83 additions & 54 deletions

File tree

lmfdb/siegel_modular_forms/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
def body_class():
1313
return {'body_class': 'smf'}
1414

15+
1516
from . import siegel_modular_form
16-
assert siegel_modular_form #silence pyflakes
17+
assert siegel_modular_form # silence pyflakes
1718

1819
app.register_blueprint(smf_page, url_prefix='/ModularForm/GSp/Q')

lmfdb/siegel_modular_forms/family.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
import inspect
1111
from .sample import Samples
1212

13+
1314
def get_smf_families():
1415
return [SiegelFamily(doc['name'], doc) for doc in db.smf_families.search({})]
1516

17+
1618
def get_smf_family(name):
1719
try:
1820
return SiegelFamily(name)
@@ -27,7 +29,7 @@ class SiegelFamily (SageObject):
2729

2830
def __init__(self, name, doc=None):
2931
if doc is None:
30-
doc = db.smf_families.lucky({ 'name': name })
32+
doc = db.smf_families.lucky({'name': name})
3133
if not doc:
3234
raise ValueError('Siegel modular form family "%s" not found in database' % (name))
3335
self.name = name
@@ -40,13 +42,13 @@ def __init__(self, name, doc=None):
4042
self.degree = doc.get('degree')
4143
self.dim_args_default = doc.get('dim_args_default')
4244
module = importlib.import_module('lmfdb.siegel_modular_forms.dimensions')
43-
self.__dimension = module.__dict__.get('dimension_'+name)
45+
self.__dimension = module.__dict__.get('dimension_' + name)
4446
if self.__dimension:
4547
args = inspect.getfullargspec(self.__dimension).args
4648
self.__dimension_glossary = self.__dimension.__doc__
47-
self.__dimension_desc = { 'name': name,
48-
'args': args
49-
}
49+
self.__dimension_desc = {'name': name,
50+
'args': args
51+
}
5052
else:
5153
self.__dimension_desc = None
5254
self.__dimension_glossary = None

lmfdb/siegel_modular_forms/family_data.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,49 @@
1111
{
1212
"name": "Gamma0_3",
1313
"degree": 2,
14-
"dim_args_default": { "k": "0..20" },
14+
"dim_args_default": {"k": "0..20"},
1515
"latex_name": "M_k\\left(\\Gamma_0(3)\\right)",
1616
"order": 80
1717
},
1818
{
1919
"name": "Gamma0_3_psi_3",
2020
"degree": 2,
21-
"dim_args_default": { "k": "0..20" },
21+
"dim_args_default": {"k": "0..20"},
2222
"latex_name": "M_k\\left(\\Gamma_0(3),\\psi_3\\right)",
2323
"order": 90
2424
},
2525
{
2626
"name": "Gamma0_4_half",
2727
"degree": 2,
28-
"dim_args_default": { "k": "1..20" },
28+
"dim_args_default": {"k": "1..20"},
2929
"latex_name": "M_{k-1/2}\\left(\\Gamma_0(4)\\right)",
3030
"order": 108
3131
},
3232
{
3333
"name": "Gamma0_4",
3434
"degree": 2,
35-
"dim_args_default": { "k": "0..20" },
35+
"dim_args_default": {"k": "0..20"},
3636
"latex_name": "M_k\\left(\\Gamma_0(4)\\right)",
3737
"order": 100
3838
},
3939
{
4040
"name": "Gamma0_4_psi_4",
4141
"degree": 2,
42-
"dim_args_default": { "k": "0..40" },
42+
"dim_args_default": {"k": "0..40"},
4343
"latex_name": "M_k\\left(\\Gamma_0(4),\\psi_4\\right)",
4444
"order": 105
4545
},
4646
{
4747
"name": "Gamma1_2",
4848
"degree": 2,
49-
"dim_args_default": { "k": "4..10", "j": "2" },
49+
"dim_args_default": {"k": "4..10", "j": "2"},
5050
"latex_name": "M_{k,j}\\left(\\Gamma_1(2)\\right)",
5151
"order": 60
5252
},
5353
{
5454
"name": "Gamma_2",
5555
"degree": 2,
56-
"dim_args_default": { "k": "4..10", "j": "2" },
56+
"dim_args_default": {"k": "4..10", "j": "2"},
5757
"latex_name": "M_{k,j}\\left(\\Gamma(2)\\right)",
5858
"order": 70
5959
},
@@ -66,35 +66,35 @@
6666
{
6767
"name": "Sp4Z_2",
6868
"degree": 2,
69-
"dim_args_default": { "k": "4..24" },
69+
"dim_args_default": {"k": "4..24"},
7070
"latex_name": "M_{k,2}\\left(\\textrm{Sp}(4,\\mathbb{Z})\\right)",
7171
"order": 30
7272
},
7373
{
7474
"name": "Sp4Z_j",
7575
"degree": 2,
76-
"dim_args_default": { "k": "4..24", "j": "4" },
76+
"dim_args_default": {"k": "4..24", "j": "4"},
7777
"latex_name": "M_{k,j}\\left(\\textrm{Sp}(4,\\mathbb{Z})\\right)",
7878
"order": 40
7979
},
8080
{
8181
"name": "Sp4Z",
8282
"degree": 2,
83-
"dim_args_default": { "k": "0..20" },
83+
"dim_args_default": {"k": "0..20"},
8484
"latex_name": "M_k\\left({\\textrm{Sp}}(4,\\mathbb{Z})\\right)",
8585
"order": 10
8686
},
8787
{
8888
"name": "Sp6Z",
8989
"degree": 3,
90-
"dim_args_default": { "k": "0..20" },
90+
"dim_args_default": {"k": "0..20"},
9191
"latex_name": "M_{k}\\left(\\textrm{Sp}(6,\\mathbb{Z})\\right)",
9292
"order": 130
9393
},
9494
{
9595
"name": "Sp8Z",
9696
"degree": 4,
97-
"dim_args_default": { "k": "0..16" },
97+
"dim_args_default": {"k": "0..16"},
9898
"latex_name": "M_k\\left(\\textrm{Sp}(8,\\mathbb{Z})\\right)",
9999
"order": 140
100100
},

lmfdb/siegel_modular_forms/siegel_modular_form.py

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from . import sample
1717
from lmfdb.utils import redirect_no_cache
1818

19+
1920
###############################################################################
2021
# Utility functions
2122
###############################################################################
@@ -24,10 +25,11 @@ def find_samples(family, weight):
2425
slist = db.smf_samples.search({'collection': {'$contains': [family]}, 'weight': int(weight)}, 'name')
2526
ret = []
2627
for name in slist:
27-
url = url_for(".by_label", label=family+"."+name)
28-
ret.append({'url':url, 'name':name})
28+
url = url_for(".by_label", label=family + "." + name)
29+
ret.append({'url': url, 'name': name})
2930
return ret
3031

32+
3133
def download_sample(name):
3234
a, b = name.split('.')
3335
s = sample.export(a, b)
@@ -52,11 +54,13 @@ def index():
5254
return render_search_results_page(request.args, bread)
5355
return render_main_page(bread)
5456

57+
5558
@smf_page.route("/random")
5659
@redirect_no_cache
5760
def random_sample():
5861
return url_for('.by_label', label='.'.join(sample.random_sample_name()))
5962

63+
6064
@smf_page.route('/<label>')
6165
@smf_page.route('/<label>/')
6266
def by_label(label):
@@ -68,26 +72,29 @@ def by_label(label):
6872
if len(slabel) == 1:
6973
return render_family_page(family, request.args, bread)
7074
if len(slabel) == 2:
71-
sam = sample.Samples({ 'collection': {'$contains': [slabel[0]]}, 'name': slabel[1]})
75+
sam = sample.Samples({'collection': {'$contains': [slabel[0]]},
76+
'name': slabel[1]})
7277
if len(sam) > 0:
73-
bread.append(('$'+family.latex_name+'$', url_for('.by_label',label=slabel[0])))
78+
bread.append(('$' + family.latex_name + '$',
79+
url_for('.by_label', label=slabel[0])))
7480
return render_sample_page(family, sam[0], request.args, bread)
7581
flash_error("No Siegel modular form data for %s was found in the database.", label)
7682
return redirect(url_for(".index"))
7783

84+
7885
@smf_page.route('/Sp4Z_j/<int:k>/<int:j>')
7986
@smf_page.route('/Sp4Z_j/<int:k>/<int:j>/')
80-
def Sp4Z_j_space(k,j):
87+
def Sp4Z_j_space(k, j):
8188
bread = [("Modular forms", url_for('modular_forms')),
8289
('Siegel', url_for('.index')),
8390
(r'$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z})$', url_for('.Sp4Z_j')),
84-
(r'$M_{%s,%s}(\mathrm{Sp}(4, \mathbb{Z}))$' % (k,j), '')]
91+
(r'$M_{%s,%s}(\mathrm{Sp}(4, \mathbb{Z}))$' % (k, j), '')]
8592
if j % 2:
8693
# redirect to general page for Sp4Z_j which will display an error message
87-
return redirect(url_for(".Sp4Z_j",k=str(k),j=str(j)))
88-
info = { 'args':{'k':str(k),'j':str(j)} }
94+
return redirect(url_for(".Sp4Z_j", k=str(k), j=str(j)))
95+
info = {'args': {'k': str(k), 'j': str(j)}}
8996
try:
90-
if j in [0,2]:
97+
if j in [0, 2]:
9198
headers, table = dimensions._dimension_Sp4Z([k])
9299
info['samples'] = find_samples('Sp4Z' if j == 0 else 'Sp4Z_2', k)
93100
else:
@@ -96,7 +103,7 @@ def Sp4Z_j_space(k,j):
96103
info['subspace'] = table[k]
97104
except NotImplementedError:
98105
# redirect to general page for Sp4Z_j which will display an error message
99-
return redirect(url_for(".Sp4Z_j",k=str(k),j=str(j)))
106+
return redirect(url_for(".Sp4Z_j", k=str(k), j=str(j)))
100107
return render_template('ModularForm_GSp4_Q_full_level_space.html',
101108
title=r'$M_{%s, %s}(\mathrm{Sp}(4, \mathbb{Z}))$' % (k, j),
102109
bread=bread,
@@ -108,11 +115,13 @@ def Sp4Z_j_space(k,j):
108115
def Sp4Z_space(k):
109116
return redirect(url_for(".Sp4Z_j_space", k=k, j=0), 301)
110117

118+
111119
# handle URLs in scalar valued SMF L-function format
112120
@smf_page.route('/Sp4Z/<int:k>/<orbit>')
113-
def Sp4Z_form(k,orbit):
114-
label = 'Sp4Z.%d_%s' % (k,orbit)
115-
return redirect(url_for('.by_label',label=label))
121+
def Sp4Z_form(k, orbit):
122+
label = 'Sp4Z.%d_%s' % (k, orbit)
123+
return redirect(url_for('.by_label', label=label))
124+
116125

117126
@smf_page.route('/Sp4Z_2/<int:k>')
118127
@smf_page.route('/Sp4Z_2/<int:k>/')
@@ -128,7 +137,8 @@ def Sp4Z_j():
128137
(r'$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z}))$', '')]
129138
info = {'args': request.args}
130139
try:
131-
dim_args = dimensions.parse_dim_args(request.args, {'k':'10-20','j':'0-30'})
140+
dim_args = dimensions.parse_dim_args(request.args,
141+
{'k': '10-20', 'j': '0-30'})
132142
except ValueError:
133143
# error message is flashed in parse_dim_args
134144
info['error'] = True
@@ -145,16 +155,20 @@ def Sp4Z_j():
145155
info=info
146156
)
147157

158+
148159
##########################################################
149160
# Page rendering functions
150161
##########################################################
151162

152163
def render_main_page(bread):
153164
fams = get_smf_families()
154-
fam_list = [c for c in fams if c.computes_dimensions() and c.name not in ["Sp4Z","Sp4Z_2"]] # Sp4Z and Sp4Z_2 are sub-families of Sp4Z_j
155-
info = { 'family_list': fam_list, 'args': {}, 'number_of_samples': db.smf_samples.count()}
165+
fam_list = [c for c in fams
166+
if c.computes_dimensions() and
167+
c.name not in ["Sp4Z", "Sp4Z_2"]] # Sp4Z and Sp4Z_2 are sub-families of Sp4Z_j
168+
info = {'family_list': fam_list, 'args': {}, 'number_of_samples': db.smf_samples.count()}
156169
return render_template('ModularForm_GSp4_Q_index.html', title='Siegel modular forms', bread=bread, info=info)
157170

171+
158172
def build_dimension_table(info, fam, args):
159173
try:
160174
dim_args = dimensions.parse_dim_args(args, fam.dim_args_default)
@@ -192,21 +206,25 @@ def build_dimension_table(info, fam, args):
192206
info['error'] = True
193207
return
194208

209+
195210
def render_family_page(family, args, bread):
196211
sams = family.samples()
197-
forms = [ (k, [(f.name(), f.degree_of_field()) for f in sams if k == f.weight()]) for k in Set(f.weight() for f in sams)]
198-
info = { 'family': family, 'forms': forms, 'args': to_dict(args) }
212+
forms = [(k, [(f.name(), f.degree_of_field()) for f in sams
213+
if k == f.weight()])
214+
for k in Set(f.weight() for f in sams)]
215+
info = {'family': family, 'forms': forms, 'args': to_dict(args)}
199216
if family.computes_dimensions():
200217
build_dimension_table(info, family, args)
201-
bread.append(('$'+family.latex_name+'$', ''))
202-
return render_template("ModularForm_GSp4_Q_family.html", title='Siegel modular forms for $'+family.latex_name+'$', bread=bread, info=info)
218+
bread.append(('$' + family.latex_name + '$', ''))
219+
return render_template("ModularForm_GSp4_Q_family.html", title='Siegel modular forms for $' + family.latex_name + '$', bread=bread, info=info)
220+
203221

204222
def render_search_results_page(args, bread):
205223
if args.get("table"):
206224
return render_dimension_table_page(args, bread)
207225
if args.get("lookup"):
208-
return redirect(url_for('.by_label',label=args['label']))
209-
info = { 'args': to_dict(args) }
226+
return redirect(url_for('.by_label', label=args['label']))
227+
info = {'args': to_dict(args)}
210228
query = {}
211229
try:
212230
parse_ints(info['args'], query, 'deg', 'degree', qfield="degree")
@@ -217,12 +235,14 @@ def render_search_results_page(args, bread):
217235
if not info.get('error'):
218236
info['results'] = sample.Samples(query)
219237
bread.append(('Search results', ''))
220-
return render_template( "ModularForm_GSp4_Q_search_results.html", title='Siegel modular forms search results', bread=bread, info=info)
238+
return render_template("ModularForm_GSp4_Q_search_results.html", title='Siegel modular forms search results', bread=bread, info=info)
239+
221240

222241
def render_dimension_table_page(args, bread):
223242
fams = get_smf_families()
224-
fam_list = [c for c in fams if c.computes_dimensions() and c.name not in ["Sp4Z","Sp4Z_2"]] # Sp4Z and Sp4Z_2 are sub-families of Sp4Z_j
225-
info = { 'family_list': fam_list, 'args': to_dict(args) }
243+
fam_list = [c for c in fams
244+
if c.computes_dimensions() and c.name not in ["Sp4Z", "Sp4Z_2"]] # Sp4Z and Sp4Z_2 are sub-families of Sp4Z_j
245+
info = {'family_list': fam_list, 'args': to_dict(args)}
226246
family = get_smf_family(args.get('family'))
227247
if not family:
228248
flash_error("Space %s not found in database", args.get('family'))
@@ -235,25 +255,29 @@ def render_dimension_table_page(args, bread):
235255
if 'j' not in info['args'] or not info['args']['j']:
236256
info['args']['j'] = '0'
237257
if 'j' not in family.latex_name and 'j' in info['args'] and info['args']['j'] != '0':
238-
flash_error("$j$ = %s should not be specified for the selected space %s", info['args']['j'], '$'+family.latex_name+'$')
258+
flash_error("$j$ = %s should not be specified for the selected space %s", info['args']['j'], '$' + family.latex_name + '$')
239259
else:
240260
build_dimension_table(info, family, info['args'])
241261
bread.append(('Dimensions', 'dimensions'))
242262
return render_template("ModularForm_GSp4_Q_dimensions.html", title='Siegel modular forms dimension tables', bread=bread, info=info)
243263

244264

245265
def render_sample_page(family, sam, args, bread):
246-
info = { 'args': to_dict(args), 'sam': sam, 'latex': latex, 'type':sam.type(), 'name':sam.name(), 'full_name': sam.full_name(), 'weight':sam.weight(), 'fdeg':sam.degree_of_field(), 'is_eigenform':sam.is_eigenform(), 'field_poly': sam.field_poly()}
266+
info = {'args': to_dict(args), 'sam': sam, 'latex': latex,
267+
'type': sam.type(), 'name': sam.name(),
268+
'full_name': sam.full_name(), 'weight': sam.weight(),
269+
'fdeg': sam.degree_of_field(), 'is_eigenform': sam.is_eigenform(),
270+
'field_poly': sam.field_poly()}
247271
if sam.is_integral() is not None:
248272
info['is_integral'] = sam.is_integral()
249273
if 'Sp4Z' in sam.collection():
250274
info['space_url'] = url_for('.Sp4Z_j_space', k=info['weight'], j=0)
251275
if 'Sp4Z_2' in sam.collection():
252276
info['space_url'] = url_for('.Sp4Z_j_space', k=info['weight'], j=2)
253-
info['space'] = '$'+family.latex_name.replace('k', '{' + str(sam.weight()) + '}')+'$'
277+
info['space'] = '$' + family.latex_name.replace('k', '{' + str(sam.weight()) + '}') + '$'
254278
if 'space_url' in info:
255279
bread.append((info['space'], info['space_url']))
256-
info['space_href'] = '<a href="%s">%s</d>' % (info['space_url'],info['space']) if 'space_url' in info else info['space']
280+
info['space_href'] = '<a href="%s">%s</d>' % (info['space_url'], info['space']) if 'space_url' in info else info['space']
257281
if info['field_poly'].disc() < 10**10:
258282
label = poly_to_field_label(info['field_poly'])
259283
if label:
@@ -288,7 +312,7 @@ def render_sample_page(family, sam, args, bread):
288312
if info['field_poly'].disc() < 10**80:
289313
null_ideal = sam.field().ring_of_integers().ideal(0)
290314
info['modulus'] = null_ideal
291-
modulus = args.get('modulus','').strip()
315+
modulus = args.get('modulus', '').strip()
292316
m = 0
293317
if modulus:
294318
try:
@@ -299,7 +323,7 @@ def render_sample_page(family, sam, args, bread):
299323
flash_error("Unable to construct modulus ideal from specified generators %s.", modulus)
300324
if m == 1:
301325
info['error'] = True
302-
flash_error("The ideal %s is the unit ideal, please specify a different modulus.", '('+modulus+')')
326+
flash_error("The ideal %s is the unit ideal, please specify a different modulus.", '(' + modulus + ')')
303327
m = 0
304328
info['modulus'] = m
305329
# Hack to reduce polynomials and to handle non integral stuff

0 commit comments

Comments
 (0)