Skip to content

Commit

Permalink
Merge pull request #6269 from assaferan/master
Browse files Browse the repository at this point in the history
modifying display of q-expansion to always have 100 coefficients
  • Loading branch information
AndrewVSutherland authored Nov 22, 2024
2 parents c48efd7 + 27558fd commit 61fe97e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,14 @@ <h2> Dimensions </h2>

{% if space.dim > 0 %}
{% if space.has_trace_form %}
<script>
function show_qexp(qstyle) {
$('.smalloutput').hide();
$('.mediumoutput').hide();
$('.'+qstyle).show();
var elementBottom = $('#qexp-anchor').offset().top + $('#qexp-anchor').outerHeight();
var viewportTop = $(window).scrollTop();
return elementBottom < viewportTop;
}
</script>
<h2 id="qexp-anchor"> {{ KNOWL('cmf.space_trace_form', title='Trace form') }} </h2>
<div id="qexp">
<form>
<table class="qexp-table">
<tr>
<td class="qexp-output smalloutput">{{ space.trace_expansion(prec_max=10) | safe }}</td>
<td class="qexp-output mediumoutput nodisplay">{{ space.trace_expansion(prec_max=100) | safe }}</td>
<td class="qexp-output mediumoutput">{{ space.trace_expansion(prec_max=100) | safe }}</td>
</tr>
</table>
<p>
<div class="toggle">Display
<span class='smalloutput'><a onclick="show_qexp('mediumoutput'); return false;" href='#'>100 coefficients</a></span>
<span class='mediumoutput nodisplay'><a onclick="return show_qexp('smalloutput');" href='#qexp-anchor'>10 coefficients</a></span>
</div>
</p>
</form>
</div>
{% endif %}
Expand Down
35 changes: 3 additions & 32 deletions lmfdb/classical_modular_forms/templates/cmf_newform_common.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,6 @@ <h2> Embedding invariants </h2>
</table>
{% endif %}

<script>
function show_qexp(qstyle) {
$('.smalloutput').hide();
$('.mediumoutput').hide();
$('.'+qstyle).show();
var elementBottom = $('#qexp-anchor').offset().top + $('#qexp-anchor').outerHeight();
var viewportTop = $(window).scrollTop();
return elementBottom < viewportTop;
}
</script>
{% if newform.has_exact_qexp or (newform.embedding_label and newform.has_complex_qexp) %}

<h2 id="qexp-anchor"> {{ KNOWL('cmf.q-expansion',title='$q$-expansion')}}</h2>
Expand All @@ -219,25 +209,16 @@ <h2 id="qexp-anchor"> {{ KNOWL('cmf.q-expansion',title='$q$-expansion')}}</h2>
<tr>
<td class="fdef">\(f(q)\)</td>
<td class="op">\(=\)</td>
<td class="qexp-output smalloutput">{{ newform.q_expansion(prec_max=10) | safe }}</td>
<td class="qexp-output mediumoutput nodisplay">{{ newform.q_expansion(prec_max=100) | safe }}</td>
<td class="qexp-output mediumoutput">{{ newform.q_expansion(prec_max=100) | safe }}</td>
</tr>
{% if newform.dim > 1 %}
<tr>
<td class="topspace fdef">\(\operatorname{Tr}(f)(q)\)</td>
<td class="op topspace">\(=\)</td>
<td class="qexp-output topspace smalloutput">{{ newform.trace_expansion(prec_max=10) | safe }}</td>
<td class="qexp-output topspace mediumoutput nodisplay">{{ newform.trace_expansion(prec_max=100) | safe }}</td>
<td class="qexp-output topspace mediumoutput">{{ newform.trace_expansion(prec_max=100) | safe }}</td>
</tr>
{% endif %}
</table>

<p>
<div class="toggle" style="padding-left:9px;">Display
<span class='smalloutput'><a onclick="show_qexp('mediumoutput'); return false;" href='#'>100 coefficients</a></span>
<span class='mediumoutput nodisplay'><a onclick="return show_qexp('smalloutput');" href='#qexp-anchor'>10 coefficients</a></span>
</div>
</p>
</form>

{% if newform.show_hecke_ring_basis %}
Expand All @@ -251,19 +232,9 @@ <h2> {{ KNOWL('cmf.q-expansion',title='$q$-expansion')}}</h2>

<form id="qexp">
<table><tr><td>
<div class="smalloutput">
<span>\(\operatorname{Tr}(f)(q) = \) {{ newform.trace_expansion(prec_max=10) | safe }}</span>
</div>
<div class="mediumoutput nodisplay">
<div class="mediumoutput">
<span>\(\operatorname{Tr}(f)(q) = \) {{ newform.trace_expansion(prec_max=100) | safe }}</span>
</div></td></tr></table>

<p style="padding-left: 1ch;">
<div class="toggle">Display
<span class='smalloutput'><a onclick="show_qexp('mediumoutput'); return false" href='#'>100 coefficients</a></span>
<span class='mediumoutput nodisplay'><a onclick="show_qexp('smalloutput'); return false" href='#'>10 coefficients</a></span>
</div>
</p>
</form>
{% endif %}

Expand Down
19 changes: 1 addition & 18 deletions lmfdb/classical_modular_forms/templates/cmf_space.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,14 @@ <h2> Dimensions </h2>

{% if space.dim > 0 %}
{% if space.has_trace_form %}
<script>
function show_qexp(qstyle) {
$('.smalloutput').hide();
$('.mediumoutput').hide();
$('.'+qstyle).show();
var elementBottom = $('#qexp-anchor').offset().top + $('#qexp-anchor').outerHeight();
var viewportTop = $(window).scrollTop();
return elementBottom < viewportTop;
}
</script>
<h2 id="qexp-anchor"> {{ KNOWL('cmf.space_trace_form', title='Trace form') }} </h2>
<div id="qexp">
<form>
<table class="qexp-table">
<tr>
<td class="qexp-output smalloutput">{{ space.trace_expansion(prec_max=10) | safe }}</td>
<td class="qexp-output mediumoutput nodisplay">{{ space.trace_expansion(prec_max=100) | safe }}</td>
<td class="qexp-output mediumoutput">{{ space.trace_expansion(prec_max=100) | safe }}</td>
</tr>
</table>
<p>
<div class="toggle">Display
<span class='smalloutput'><a onclick="show_qexp('mediumoutput'); return false;" href='#'>100 coefficients</a></span>
<span class='mediumoutput nodisplay'><a onclick="return show_qexp('smalloutput');" href='#qexp-anchor'>10 coefficients</a></span>
</div>
</p>
</form>
</div>
{% endif %}
Expand Down
5 changes: 3 additions & 2 deletions lmfdb/classical_modular_forms/web_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from lmfdb.number_fields.web_number_field import nf_display_knowl, cyclolookup, rcyclolookup
from lmfdb.characters.TinyConrey import ConreyCharacter
from lmfdb.utils import (
display_knowl, web_latex, coeff_to_power_series,
display_knowl, raw_typeset_qexp,
web_latex_factored_integer, prop_int_pretty)
from flask import url_for
import re
Expand Down Expand Up @@ -156,7 +156,8 @@ def convert_spacelabel_from_conrey(spacelabel_conrey):

def trace_expansion_generic(space, prec_max=10):
prec = min(len(space.traces)+1, prec_max)
return web_latex(coeff_to_power_series([0] + space.traces[:prec-1],prec=prec),enclose=True)
return raw_typeset_qexp([0] + space.traces[:prec-1])
# return web_latex(coeff_to_power_series([0] + space.traces[:prec-1],prec=prec),enclose=True)


class DimGrid():
Expand Down
6 changes: 3 additions & 3 deletions lmfdb/utils/web_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def raw_typeset(raw, typeset='', extra='', compressed=False):
# clean white space
raw = re.sub(r'\s+', ' ', str(raw).strip())
raw = f'<textarea rows="1" cols="{len(raw)}" class="raw-container">{raw}</textarea>'

# the doublesclick behavior is set on load in javascript
out = f"""
<span class="raw-tset-container tset {"compressed" if compressed else ""}">
Expand Down Expand Up @@ -587,7 +587,7 @@ def raw_typeset_poly_factor(factors, # list of pairs (f,e)


def raw_typeset_qexp(coeffs_list,
compress_threshold=100,
compress_threshold=200,
coeff_compress_threshold=30,
var=r"\beta",
final_rawvar='b',
Expand Down Expand Up @@ -655,7 +655,7 @@ def rawtset_coeff(i, coeffs):
raw += r
if add_to_tset:
tset += t
if add_to_tset and "cdots" in tset:
if add_to_tset and (len(tset) > compress_threshold):
add_to_tset = False
lastt = None
else:
Expand Down

0 comments on commit 61fe97e

Please sign in to comment.