1616from . import sample
1717from 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+
3133def 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
5760def 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>/' )
6266def 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):
108115def 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
152163def 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+
158172def 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+
195210def 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
204222def 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
222241def 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
245265def 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