Skip to content

Commit 2ee4b27

Browse files
authored
Merge branch 'main' into copilot/fix-6652
2 parents 16e52ad + b904488 commit 2ee4b27

File tree

33 files changed

+363
-231
lines changed

33 files changed

+363
-231
lines changed

lmfdb/api/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from psycopg2.extensions import QueryCanceledError
77
from lmfdb import db
88
from psycodict.encoding import Json
9-
from lmfdb.utils import flash_error
9+
from lmfdb.utils import flash_error, comma
1010
from lmfdb.utils.datetime_utils import utc_now_naive
1111
from flask import (render_template, request, url_for, current_app,
1212
abort, redirect, Response)
@@ -137,11 +137,11 @@ def split_db(tablename):
137137
'tablespace': tablespaces.get(tablename, ""),
138138
}
139139
dataSize = size - indexSize
140-
info['ntables'] = len(table_sizes)
141-
info['nobjects'] = nobjects
142-
info['size'] = mb(size)
143-
info['dataSize'] = mb(dataSize)
144-
info['indexSize'] = mb(indexSize)
140+
info['ntables'] = comma(len(table_sizes))
141+
info['nobjects'] = comma(nobjects)
142+
info['size'] = comma(mb(size))
143+
info['dataSize'] = comma(mb(dataSize))
144+
info['indexSize'] = comma(mb(indexSize))
145145
if info['sortby'] == 'name':
146146
sortedkeys = sorted(stats)
147147
elif info['sortby'] == 'objects' and info['groupby'] == 'db':

lmfdb/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ def WhiteListedRoutes():
719719
'Character/calc-jacobi/Dirichlet',
720720
'Character/calc-kloosterman/Dirichlet',
721721
'Character/calc-value/Dirichlet',
722+
'datasets',
722723
'EllipticCurve',
723724
'Field',
724725
'GaloisGroup',
@@ -774,6 +775,7 @@ def WhiteListedRoutes():
774775
'news',
775776
'not_yet_implemented',
776777
'random',
778+
'rcs',
777779
'robots.txt',
778780
'search',
779781
'sitemap',

lmfdb/artin_representations/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,11 @@ def artin_postprocess(res, info, query):
245245
cache = knowl_cache(gp_labels)
246246
return [ArtinRepresentation(data=x, knowl_cache=cache) for x in res]
247247

248+
248249
class ArtinDownload(Downloader):
249250
table = db.artin_reps
250251
title = "Artin representations"
252+
251253
def modify_query(self, info, query):
252254
query['Hide'] = 0
253255

lmfdb/characters/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ def url_character(**kwargs):
5353
return url_for('characters.render_characterNavigation')
5454
elif kwargs['type'] == 'Dirichlet':
5555
del kwargs['type']
56-
if kwargs.get('calc',None):
56+
if kwargs.get('calc'):
5757
return url_for('characters.dc_calc',**kwargs)
5858
else:
5959
return url_for('characters.render_Dirichletwebpage',**kwargs)
6060
elif kwargs['type'] == 'Hecke':
6161
del kwargs['type']
62-
if kwargs.get('calc',None):
62+
if kwargs.get('calc'):
6363
return url_for('characters.hc_calc',**kwargs)
6464
else:
6565
return url_for('characters.render_Heckewebpage',**kwargs)

lmfdb/characters/web_character.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def valuefield_from_order(order):
9696
class WebCharObject():
9797
""" class for all characters and character groups """
9898
def __init__(self, **args):
99-
self.type = args.get('type',None)
100-
self.nflabel = args.get('number_field',None)
101-
self.modlabel = args.get('modulus',None)
102-
self.numlabel = args.get('number',None)
99+
self.type = args.get('type')
100+
self.nflabel = args.get('number_field')
101+
self.modlabel = args.get('modulus')
102+
self.numlabel = args.get('number')
103103
self.args = args
104104

105105
self._compute()
@@ -558,14 +558,14 @@ class WebDBDirichlet(WebDirichlet):
558558
"""
559559
def __init__(self, **kwargs):
560560
self.type = "Dirichlet"
561-
self.modulus = kwargs.get('modulus', None)
561+
self.modulus = kwargs.get('modulus')
562562
if self.modulus:
563563
self.modulus = int(self.modulus)
564564
self.modlabel = self.modulus
565565
if self.modulus == 1:
566566
self.number = 1
567567
else:
568-
self.number = kwargs.get('number', None)
568+
self.number = kwargs.get('number')
569569
if self.number:
570570
self.number = int(self.number)
571571
self.numlabel = self.number
@@ -1108,11 +1108,11 @@ class WebDBDirichletOrbit(WebChar, WebDBDirichlet):
11081108
def __init__(self, **kwargs):
11091109
self.type = "Dirichlet"
11101110
self.isorbit = True
1111-
self.modulus = kwargs.get('modulus', None)
1111+
self.modulus = kwargs.get('modulus')
11121112
if self.modulus:
11131113
self.modulus = int(self.modulus)
11141114
self.modlabel = self.modulus
1115-
self.number = kwargs.get('number', None)
1115+
self.number = kwargs.get('number')
11161116
if self.number:
11171117
self.number = int(self.number)
11181118
self.numlabel = self.number
@@ -1122,7 +1122,7 @@ def __init__(self, **kwargs):
11221122
if self.number:
11231123
self.chi = ConreyCharacter(self.modulus, self.number)
11241124
self.codelangs = ('pari', 'sage')
1125-
self.orbit_label = kwargs.get('orbit_label', None) # this is what the user inserted, so might be banana
1125+
self.orbit_label = kwargs.get('orbit_label') # this is what the user inserted, so might be banana
11261126
self.label = "{}.{}".format(self.modulus, self.orbit_label)
11271127
self.maxrows = 30
11281128
self.rowtruncate = False

lmfdb/classical_modular_forms/code-form.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,35 @@ dimensions-spaces:
4343
mfdim([N,k,chi],1) \\ Cusps
4444
mfdim([N,k,chi],0) \\ New
4545
46-
initialize-newspace:
46+
initialize-newspace-common: &initialize-newspace-common
4747
comment: Compute space of new eigenforms
4848
pari: |
4949
[N,k,chi] = [{N},{k},Mod({conrey_index},{N})]
5050
mf = mfinit([N,k,chi],0)
5151
lf = mfeigenbasis(mf)
52-
sage: |
53-
from sage.modular.dirichlet import DirichletCharacter
54-
H = DirichletGroup({N}, base_ring=CyclotomicField({sage_zeta_order}))
55-
chi = DirichletCharacter(H, H._module({sage_genvalues}))
56-
N = Newforms(chi, {k}, names="a")
5752
magma: |
5853
//Please install CHIMP (https://github.com/edgarcosta/CHIMP) if you want to run this code
5954
chi := DirichletCharacter("{N}.{conrey_index}");
6055
S:= CuspForms(chi, {k});
6156
N := Newforms(S);
6257
58+
initialize-newspace-weight-1:
59+
<<: *initialize-newspace-common
60+
sage: |
61+
from sage.modular.dirichlet import DirichletCharacter
62+
H = DirichletGroup({N}, base_ring=CyclotomicField({sage_zeta_order}))
63+
chi = DirichletCharacter(H, H._module({sage_genvalues}))
64+
B = ModularForms(chi, 1).cuspidal_submodule().basis()
65+
N = [B[i] for i in range(len(B))]
66+
67+
initialize-newspace-weight-not-1:
68+
<<: *initialize-newspace-common
69+
sage: |
70+
from sage.modular.dirichlet import DirichletCharacter
71+
H = DirichletGroup({N}, base_ring=CyclotomicField({sage_zeta_order}))
72+
chi = DirichletCharacter(H, H._module({sage_genvalues}))
73+
N = Newforms(chi, {k}, names="a")
74+
6375
coeff-field:
6476
comment: Coefficient field, relative polynomial
6577
pari: |

lmfdb/classical_modular_forms/main.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,33 @@ def parse_prec(info):
306306
return []
307307

308308

309+
def validate_format_parameter(format_param):
310+
"""
311+
Validate the format parameter for newform display.
312+
313+
Args:
314+
format_param: The format parameter to validate
315+
316+
Returns:
317+
str: validated format parameter (defaults to 'embed' if None or invalid)
318+
319+
Side effects:
320+
Flashes error message if format parameter is invalid
321+
"""
322+
valid_formats = ['embed', 'analytic_embed', 'satake', 'satake_angle']
323+
324+
# Default to 'embed' if format is None
325+
if format_param is None:
326+
return 'embed'
327+
328+
# Check if format is valid
329+
if format_param not in valid_formats:
330+
flash_error("Invalid format parameter '%s'. Valid formats are: %s" % (format_param, ', '.join(valid_formats)))
331+
format_param = 'embed'
332+
333+
return format_param
334+
335+
309336
def eta_quotient_texstring(etadata):
310337
r"""
311338
Returns a latex string representing an eta quotient.
@@ -357,7 +384,9 @@ def render_newform_webpage(label):
357384

358385
info = to_dict(request.args)
359386
info['display_float'] = display_float
360-
info['format'] = info.get('format', 'embed')
387+
388+
# Validate format parameter
389+
info['format'] = validate_format_parameter(info.get('format'))
361390

362391
if label in ETAQUOTIENTS:
363392
info['eta_quotient'] = eta_quotient_texstring(ETAQUOTIENTS[label])

lmfdb/classical_modular_forms/templates/cmf_newform_common.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
<h2> {{KNOWL('cmf.newspace',title='Newspace')}} parameters </h2>
99

10-
{{ place_code('initialize-newspace')}}
10+
{% if newform.weight == 1 %}
11+
{{ place_code('initialize-newspace-weight-1')}}
12+
{% else %}
13+
{{ place_code('initialize-newspace-weight-not-1')}}
14+
{% endif %}
1115

1216
<table>
1317
<tr>

lmfdb/classical_modular_forms/test_cmf.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,3 +655,29 @@ def test_character_values(self):
655655
</table>
656656
"""
657657
assert (character_values_table in data)
658+
659+
def test_invalid_format_parameter(self):
660+
"""Test that invalid format parameters are handled gracefully"""
661+
# Test invalid format 'txt' which was causing the original issue
662+
page = self.tc.get('/ModularForm/GL2/Q/holomorphic/441/4/a/h/?format=txt')
663+
data = page.get_data(as_text=True)
664+
assert "Invalid format parameter" in data
665+
assert "txt" in data
666+
assert "Valid formats are:" in data
667+
668+
# Test another invalid format
669+
page = self.tc.get('/ModularForm/GL2/Q/holomorphic/11/2/a/a/?format=invalid')
670+
data = page.get_data(as_text=True)
671+
assert "Invalid format parameter" in data
672+
assert "invalid" in data
673+
674+
# Test that valid formats still work
675+
page = self.tc.get('/ModularForm/GL2/Q/holomorphic/11/2/a/a/?format=embed')
676+
data = page.get_data(as_text=True)
677+
assert "Valid formats are:" not in data
678+
assert "Invalid format parameter" not in data
679+
680+
page = self.tc.get('/ModularForm/GL2/Q/holomorphic/11/2/a/a/?format=satake')
681+
data = page.get_data(as_text=True)
682+
assert "Valid formats are:" not in data
683+
assert "Invalid format parameter" not in data

lmfdb/ecnf/templates/ecnf-isoclass.html

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,6 @@ <h2> Base field {{ cl.field.knowl()|safe }} </h2>
4141
{{ place_code('field', is_top_snippet=True) }}
4242
</div>
4343

44-
<h2>Elliptic curves in class {{cl.short_class_label}} over {{ cl.field_knowl|safe }}</h2>
45-
<p>
46-
Isogeny class {{cl.short_class_label}} contains
47-
{% if cl.class_size==1 %}
48-
only one elliptic curve.
49-
{% else %}
50-
{{cl.class_size}} curves linked by isogenies of
51-
{% if cl.one_deg %}degree {% else %}degrees dividing {% endif %}
52-
{{cl.class_deg}}.
53-
{% endif %}
54-
</p>
55-
<table>
56-
<tr>
57-
<th>{{ KNOWL('ec.curve_label',title = "Curve label") }}</th>
58-
<th>{{ KNOWL('ec.weierstrass_coeffs', title='Weierstrass Coefficients') }}</th>
59-
</tr>
60-
{% for c in cl.curves %}
61-
<tr>
62-
<td> <a href={{c[1]}}>{{c[0]}}</a>
63-
<td> <a href={{c[1]}}>{{c[2]}}</a>
64-
</tr>
65-
{% endfor %}
66-
</table>
67-
6844
<h2>{{ KNOWL('ec.rank',title='Rank') }}</h2>
6945

7046
{% if cl.rk == "?" %}
@@ -97,6 +73,30 @@ <h2>{{ KNOWL('ec.isogeny_graph',title='Isogeny graph') }}</h2>
9773
<p>Not available.</p>
9874
{% endif %}
9975

76+
<h2>Elliptic curves in class {{cl.short_class_label}} over {{ cl.field_knowl|safe }}</h2>
77+
<p>
78+
Isogeny class {{cl.short_class_label}} contains
79+
{% if cl.class_size==1 %}
80+
only one elliptic curve.
81+
{% else %}
82+
{{cl.class_size}} curves linked by isogenies of
83+
{% if cl.one_deg %}degree {% else %}degrees dividing {% endif %}
84+
{{cl.class_deg}}.
85+
{% endif %}
86+
</p>
87+
<table>
88+
<tr>
89+
<th>{{ KNOWL('ec.curve_label',title = "Curve label") }}</th>
90+
<th>{{ KNOWL('ec.weierstrass_coeffs', title='Weierstrass Coefficients') }}</th>
91+
</tr>
92+
{% for c in cl.curves %}
93+
<tr>
94+
<td> <a href={{c[1]}}>{{c[0]}}</a>
95+
<td> <a href={{c[1]}}>{{c[2]}}</a>
96+
</tr>
97+
{% endfor %}
98+
</table>
99+
100100
{% if DEBUG %}
101101
<hr>
102102
<div>

0 commit comments

Comments
 (0)