From f89ffa20854c10f89d011354b9a624a60a7aa4bd Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 17 Aug 2023 18:57:38 -0400 Subject: [PATCH 01/14] Using raw/latex in Belyi pages --- lmfdb/belyi/templates/belyi_galmap.html | 8 ++++---- lmfdb/belyi/web_belyi.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lmfdb/belyi/templates/belyi_galmap.html b/lmfdb/belyi/templates/belyi_galmap.html index add3e204e9..1ce7156f00 100644 --- a/lmfdb/belyi/templates/belyi_galmap.html +++ b/lmfdb/belyi/templates/belyi_galmap.html @@ -36,7 +36,7 @@

Curve

@@ -57,17 +47,6 @@

Curve

@@ -105,20 +84,20 @@

{{ KNOWL('belyi.galmap', 'Map') }}

{% else %}

Curve

- \(\displaystyle {{data.curve}}\) - {% if data.g == 0 %} + {{data.curve}} + {%- if data.g == 0 -%} , with affine coordinate $x$ {% endif %} - {% if data["curve_label"] %} + {%- if data["curve_label"] -%} , isomorphic to curve with label {{data["curve_label"]}} {% endif %}

{{ KNOWL('belyi.galmap', 'Map') }}

{% if data.g == 0 %} -

\(\displaystyle \phi(x) = {{data.map}}\)

+

\(\displaystyle \phi(x) =\) {{data.map|safe}}

{% else %} -

\(\displaystyle \phi(x,y) = {{data.map}}\)

+

\(\displaystyle \phi(x,y) =\) {{data.map|safe}}

{% endif %} {% endif %} diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py index aadada19e7..1e979d660a 100644 --- a/lmfdb/belyi/web_belyi.py +++ b/lmfdb/belyi/web_belyi.py @@ -112,37 +112,37 @@ def make_map_latex(map_str, nu=None): phi_str = lc_str + "\\frac{%s}{%s}" % (num_str, den_str) return phi_str -def make_plane_model_latex(crv_str, nu=None): - if "nu" not in crv_str: - R0 = QQ - else: - R0 = PolynomialRing(QQ, "nu") - R = PolynomialRing(R0, 2, "t,x") - f = R(crv_str) - #return teXify_pol(f) - return latex(f)+"=0" - -def make_plane_model_latex_factored(crv_str, numfld_cs, nu=None): - R0 = PolynomialRing(QQ,"T") - K = NumberField(R0(numfld_cs), "nu") # sage factors out constants, ruining integrality - S0 = PolynomialRing(K,"x") - S = PolynomialRing(S0,"t") - t = S.gens()[0] - f = S(crv_str) - cs = f.coefficients() - cs.reverse() - mons = f.monomials() - L = len(cs) - f_str = "" - for i in range(0,L-1): - f_str += "%s%s" % (latex(factor(cs[i])), latex(t**(L-i-1))) - if i != L-2: - f_str += "+" - if mons[-1] == 1: - f_str += latex(factor(cs[-1])) - else: - f_str += latex(factor(cs[-1])) + latex(mons[-1]) - return f_str +#def make_plane_model_latex(crv_str, nu=None): +# if "nu" not in crv_str: +# R0 = QQ +# else: +# R0 = PolynomialRing(QQ, "nu") +# R = PolynomialRing(R0, 2, "t,x") +# f = R(crv_str) +# #return teXify_pol(f) +# return latex(f)+"=0" +# +#def make_plane_model_latex_factored(crv_str, numfld_cs, nu=None): +# R0 = PolynomialRing(QQ,"T") +# K = NumberField(R0(numfld_cs), "nu") # sage factors out constants, ruining integrality +# S0 = PolynomialRing(K,"x") +# S = PolynomialRing(S0,"t") +# t = S.gens()[0] +# f = S(crv_str) +# cs = f.coefficients() +# cs.reverse() +# mons = f.monomials() +# L = len(cs) +# f_str = "" +# for i in range(0,L-1): +# f_str += "%s%s" % (latex(factor(cs[i])), latex(t**(L-i-1))) +# if i != L-2: +# f_str += "+" +# if mons[-1] == 1: +# f_str += latex(factor(cs[-1])) +# else: +# f_str += latex(factor(cs[-1])) + latex(mons[-1]) +# return f_str def belyi_latex(s): str = s.replace('*',' ') @@ -263,18 +263,42 @@ def __init__(self, galmap, triple=None): my_dict['embedding'] = embed_strs[i] data['embeddings_and_triples'].append(my_dict) + # Friends + self.friends = [("Passport", url_for_belyi_passport_label(galmap["plabel"]))] + if galmap['label'] != galmap['primitivization']: + self.friends.append(("Primitivization", url_for_belyi_galmap_label(galmap["primitivization"]))) + self.friends.extend(names_and_urls(galmap['friends'])) + + curve_ref = '' + # add curve link, if in LMFDB + if 'curve_label' in galmap.keys(): + data['curve_label'] = galmap['curve_label'] + for name, url in self.friends: + if "curve" in name.lower() and data['curve_label'] in name: + data["curve_url"] = url + + # curve reference + curve_ref = ', isomorphic to ' + if galmap['g'] == 1: + curve_ref += 'elliptic' + if galmap['g'] == 2: + curve_ref += 'genus 2' + curve_ref += rf' curve with label {data["curve_label"]}' + + + + # curve equations crv_str = galmap["curve"] if crv_str == "PP1": data["curve"] = r"$\mathbb{P}^1$" else: - data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+make_curve_latex(crv_str, nu=self.embedding)+'$') + data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+make_curve_latex(crv_str, nu=self.embedding)+'$', extra=curve_ref) data["map"] = raw_typeset(galmap["map"], r'$\displaystyle '+make_map_latex(galmap["map"], nu=self.embedding)+'$') data["lambdas"] = [str(c)[1:-1] for c in galmap["lambdas"]] # plane model if galmap.get("plane_model"): - data["plane_model"] = raw_typeset(galmap["plane_model"]+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$') - data["plane_model2"] = r'$\displaystyle '+galmap["plane_model_latex"]+'=0$' + data["plane_model"] = raw_typeset(galmap["plane_model"]+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$', extra=curve_ref) if galmap.get('plane_map_constant_factored'): data['plane_map_constant_factored'] = galmap['plane_map_constant_factored'] @@ -296,19 +320,6 @@ def __init__(self, galmap, triple=None): ] self.properties = properties - # Friends - self.friends = [("Passport", url_for_belyi_passport_label(galmap["plabel"]))] - if galmap['label'] != galmap['primitivization']: - self.friends.append(("Primitivization", url_for_belyi_galmap_label(galmap["primitivization"]))) - self.friends.extend(names_and_urls(galmap['friends'])) - - # add curve link, if in LMFDB - if 'curve_label' in galmap.keys(): - data['curve_label'] = galmap['curve_label'] - for name, url in self.friends: - if "curve" in name.lower() and data['curve_label'] in name: - data["curve_url"] = url - # Downloads data_label = data["label"] if galmap["g"] <= 2: From 620f79b210642bde2bfe1dfc966901c3248e72ff Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 3 Oct 2023 15:27:47 -0400 Subject: [PATCH 07/14] pyflakes --- lmfdb/belyi/web_belyi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py index 1e979d660a..d5e0cc5dc6 100644 --- a/lmfdb/belyi/web_belyi.py +++ b/lmfdb/belyi/web_belyi.py @@ -3,7 +3,7 @@ from lmfdb.utils import web_latex from lmfdb.number_fields.web_number_field import WebNumberField from lmfdb.galois_groups.transitive_group import transitive_group_display_knowl -from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing, NumberField, factor +from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing from lmfdb.utils import names_and_urls, prop_int_pretty, raw_typeset from flask import url_for import re From 0d9e24b0086fd09f0d2f5d5e6f252a5430604148 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 3 Oct 2023 19:19:48 -0400 Subject: [PATCH 08/14] Remove debug line --- lmfdb/belyi/templates/belyi_galmap.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmfdb/belyi/templates/belyi_galmap.html b/lmfdb/belyi/templates/belyi_galmap.html index 3d81cc210d..4fde6cb3c6 100644 --- a/lmfdb/belyi/templates/belyi_galmap.html +++ b/lmfdb/belyi/templates/belyi_galmap.html @@ -84,7 +84,7 @@

{{ KNOWL('belyi.galmap', 'Map') }}

{% else %}

Curve

- {{data.curve}} + {{data.curve|safe}} {%- if data.g == 0 -%} , with affine coordinate $x$ {% endif %} From f13e357a89b00f79d98cb4a08b3f4318cf177e2e Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 4 Oct 2023 18:37:11 -0400 Subject: [PATCH 09/14] Finish replacing curve info --- lmfdb/belyi/templates/belyi_galmap.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/lmfdb/belyi/templates/belyi_galmap.html b/lmfdb/belyi/templates/belyi_galmap.html index 4fde6cb3c6..d2b2822a54 100644 --- a/lmfdb/belyi/templates/belyi_galmap.html +++ b/lmfdb/belyi/templates/belyi_galmap.html @@ -88,9 +88,6 @@

Curve

{%- if data.g == 0 -%} , with affine coordinate $x$ {% endif %} - {%- if data["curve_label"] -%} - , isomorphic to curve with label {{data["curve_label"]}} - {% endif %}

{{ KNOWL('belyi.galmap', 'Map') }}

From 5a230ff89dd61a80fef419cc071158777a404eab Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 5 Oct 2023 10:53:34 -0400 Subject: [PATCH 10/14] Expanded the compressed integers usage --- lmfdb/belyi/web_belyi.py | 10 +++++----- lmfdb/utils/__init__.py | 2 ++ lmfdb/utils/web_display.py | 12 ++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py index d5e0cc5dc6..58c1e1b33c 100644 --- a/lmfdb/belyi/web_belyi.py +++ b/lmfdb/belyi/web_belyi.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from lmfdb.utils import web_latex from lmfdb.number_fields.web_number_field import WebNumberField from lmfdb.galois_groups.transitive_group import transitive_group_display_knowl from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing -from lmfdb.utils import names_and_urls, prop_int_pretty, raw_typeset +from lmfdb.utils import (names_and_urls, prop_int_pretty, raw_typeset, + web_latex, compress_complicated) from flask import url_for import re @@ -292,13 +292,13 @@ def __init__(self, galmap, triple=None): if crv_str == "PP1": data["curve"] = r"$\mathbb{P}^1$" else: - data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+make_curve_latex(crv_str, nu=self.embedding)+'$', extra=curve_ref) + data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+compress_complicated(make_curve_latex(crv_str, nu=self.embedding))+'$', extra=curve_ref) - data["map"] = raw_typeset(galmap["map"], r'$\displaystyle '+make_map_latex(galmap["map"], nu=self.embedding)+'$') + data["map"] = raw_typeset(galmap["map"], r'$\displaystyle '+compress_complicated(make_map_latex(galmap["map"], nu=self.embedding))+'$') data["lambdas"] = [str(c)[1:-1] for c in galmap["lambdas"]] # plane model if galmap.get("plane_model"): - data["plane_model"] = raw_typeset(galmap["plane_model"]+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$', extra=curve_ref) + data["plane_model"] = raw_typeset(compress_complicated(galmap["plane_model"])+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$', extra=curve_ref) if galmap.get('plane_map_constant_factored'): data['plane_map_constant_factored'] = galmap['plane_map_constant_factored'] diff --git a/lmfdb/utils/__init__.py b/lmfdb/utils/__init__.py index 856a62c7fb..72153fef24 100644 --- a/lmfdb/utils/__init__.py +++ b/lmfdb/utils/__init__.py @@ -49,6 +49,7 @@ 'raw_typeset', 'raw_typeset_poly', 'raw_typeset_poly_factor', 'raw_typeset_qexp', 'raw_typeset_int', 'compress_poly_Q', 'input_string_to_poly', 'dispZmat', 'dispcyclomat', + 'compress_complicated', 'pos_int_and_factor', 'compress_polynomial'] from flask import (request, make_response, flash, url_for, @@ -115,6 +116,7 @@ raw_typeset_poly, compress_poly_Q, compress_polynomial, + compress_complicated, pos_int_and_factor, raw_typeset_poly_factor, raw_typeset_qexp, diff --git a/lmfdb/utils/web_display.py b/lmfdb/utils/web_display.py index 92f60185da..cd9365eb1c 100644 --- a/lmfdb/utils/web_display.py +++ b/lmfdb/utils/web_display.py @@ -121,6 +121,18 @@ def compress_int(n, cutoff=15, sides=2): else: return res, False +def compress_complicated(expression, cutoff=15, sides=2): + r""" + Takes a string and any numbers (consecutive digits) longer than + cutoff gets replaced + """ + def c_int(n): + n = str(n.group()) + if len(n) >= cutoff: + return n[:sides] + r'\!\cdots\!' + n[-sides:] + else: + return n + return re.sub(r'\d+', c_int, expression) def bigint_knowl(n, cutoff=20, max_width=70, sides=2): short, shortened = compress_int(n, cutoff=cutoff, sides=sides) From 5e6f8e460751db7dc918f128d953416cf51d6598 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 5 Oct 2023 11:13:25 -0400 Subject: [PATCH 11/14] change katex option --- lmfdb/templates/base.html | 1 + 1 file changed, 1 insertion(+) diff --git a/lmfdb/templates/base.html b/lmfdb/templates/base.html index 6973c6a95f..50ef461adf 100644 --- a/lmfdb/templates/base.html +++ b/lmfdb/templates/base.html @@ -62,6 +62,7 @@ {left: "$", right: "$", display: false}, {left: "\\(", right: "\\)", display: false} ], + maxExpand: Infinity, macros: { "\\C": '{\\mathbb{C}}', "\\R": '{\\mathbb{R}}', From c1b90bcb4797c7cee0fb2cc15ce2001c008ff4f8 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 5 Oct 2023 11:33:40 -0400 Subject: [PATCH 12/14] Fix tests --- lmfdb/belyi/test_belyi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lmfdb/belyi/test_belyi.py b/lmfdb/belyi/test_belyi.py index 76a951059c..9341fe423c 100644 --- a/lmfdb/belyi/test_belyi.py +++ b/lmfdb/belyi/test_belyi.py @@ -20,7 +20,8 @@ def test_passport(self): self.check_args("/Belyi/9T33-5.2.2_5.3.1_2.2.2.2.1-a", "3.1.14175.1") def test_smooth_equation(self): - self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"9075734485907514624 \frac{x^{9}}{4537867242953757312 x^{9} - 10520021716426424475 x^{8} + 12447550725170242500 x^{6} - 9941569340991356250 x^{4} + 4201111257707812500 x^{2} - 724916949326171875}") + self.check_args("/Belyi/7T5-7_7_3.3.1-a", r"\frac{50000 x^{5} + 60000 x^{4} + \left(7000 \nu + 5000\right) x^{3} + 50000 x^{2} y + \left(7000 \nu - 11400\right) x^{2} + 40000 x y + \left(455 \nu - 1725\right) x + \left(500 \nu + 2500\right) y - 532 \nu + 284}{50000 x^{5} + 60000 x^{4} + \left(7000 \nu + 5000\right) x^{3} + \left(7000 \nu - 11400\right) x^{2} + \left(455 \nu - 1725\right) x - 532 \nu + 284}") + self.check_args("/Belyi/7T5-7_7_3.3.1-a", r"y^{2} = x^{6} + \frac{4}{5} x^{5} + \left(\frac{13}{50} \nu - \frac{19}{50}\right) x^{4} + \left(\frac{21}{125} \nu - \frac{7}{25}\right) x^{3} + \left(-\frac{709}{10000} \nu + \frac{279}{10000}\right) x^{2} + \left(-\frac{153}{6250} \nu + \frac{67}{6250}\right) x + \frac{83}{15625} \nu + \frac{47}{15625}") def test_plane_equation(self): self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"x^{9} t + \left(-126 x^{4} + 420 x^{3} - 540 x^{2} + 315 x - 70") From 7c03dea584507e575c82de8f670deba17823b638 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 5 Oct 2023 23:45:47 -0400 Subject: [PATCH 13/14] Change name of function --- lmfdb/belyi/web_belyi.py | 8 ++++---- lmfdb/utils/__init__.py | 4 ++-- lmfdb/utils/web_display.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py index 58c1e1b33c..7226b35d62 100644 --- a/lmfdb/belyi/web_belyi.py +++ b/lmfdb/belyi/web_belyi.py @@ -4,7 +4,7 @@ from lmfdb.galois_groups.transitive_group import transitive_group_display_knowl from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing from lmfdb.utils import (names_and_urls, prop_int_pretty, raw_typeset, - web_latex, compress_complicated) + web_latex, compress_expression) from flask import url_for import re @@ -292,13 +292,13 @@ def __init__(self, galmap, triple=None): if crv_str == "PP1": data["curve"] = r"$\mathbb{P}^1$" else: - data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+compress_complicated(make_curve_latex(crv_str, nu=self.embedding))+'$', extra=curve_ref) + data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+compress_expression(make_curve_latex(crv_str, nu=self.embedding))+'$', extra=curve_ref) - data["map"] = raw_typeset(galmap["map"], r'$\displaystyle '+compress_complicated(make_map_latex(galmap["map"], nu=self.embedding))+'$') + data["map"] = raw_typeset(galmap["map"], r'$\displaystyle '+compress_expression(make_map_latex(galmap["map"], nu=self.embedding))+'$') data["lambdas"] = [str(c)[1:-1] for c in galmap["lambdas"]] # plane model if galmap.get("plane_model"): - data["plane_model"] = raw_typeset(compress_complicated(galmap["plane_model"])+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$', extra=curve_ref) + data["plane_model"] = raw_typeset(compress_expression(galmap["plane_model"])+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$', extra=curve_ref) if galmap.get('plane_map_constant_factored'): data['plane_map_constant_factored'] = galmap['plane_map_constant_factored'] diff --git a/lmfdb/utils/__init__.py b/lmfdb/utils/__init__.py index 72153fef24..9cd5eba053 100644 --- a/lmfdb/utils/__init__.py +++ b/lmfdb/utils/__init__.py @@ -49,7 +49,7 @@ 'raw_typeset', 'raw_typeset_poly', 'raw_typeset_poly_factor', 'raw_typeset_qexp', 'raw_typeset_int', 'compress_poly_Q', 'input_string_to_poly', 'dispZmat', 'dispcyclomat', - 'compress_complicated', + 'compress_expression', 'pos_int_and_factor', 'compress_polynomial'] from flask import (request, make_response, flash, url_for, @@ -116,7 +116,7 @@ raw_typeset_poly, compress_poly_Q, compress_polynomial, - compress_complicated, + compress_expression, pos_int_and_factor, raw_typeset_poly_factor, raw_typeset_qexp, diff --git a/lmfdb/utils/web_display.py b/lmfdb/utils/web_display.py index cd9365eb1c..111d31c0db 100644 --- a/lmfdb/utils/web_display.py +++ b/lmfdb/utils/web_display.py @@ -121,7 +121,7 @@ def compress_int(n, cutoff=15, sides=2): else: return res, False -def compress_complicated(expression, cutoff=15, sides=2): +def compress_expression(expression, cutoff=15, sides=2): r""" Takes a string and any numbers (consecutive digits) longer than cutoff gets replaced From 0266e02573fa785f3eccfe01eb20086f238da652 Mon Sep 17 00:00:00 2001 From: John Jones Date: Sun, 8 Oct 2023 18:40:58 -0400 Subject: [PATCH 14/14] Consolidate code (compress_int will now accept a string) --- lmfdb/utils/web_display.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lmfdb/utils/web_display.py b/lmfdb/utils/web_display.py index 111d31c0db..1582c13bac 100644 --- a/lmfdb/utils/web_display.py +++ b/lmfdb/utils/web_display.py @@ -115,8 +115,9 @@ def web_latex(x, enclose=True): def compress_int(n, cutoff=15, sides=2): res = str(n) - if abs(n) >= 10**cutoff: - short = res[:sides + (1 if n < 0 else 0)] + r'\!\cdots\!' + res[-sides:] + minus_width = 1 if '-' in res else 0 + if len(res) > cutoff+minus_width: + short = res[:sides + minus_width] + r'\!\cdots\!' + res[-sides:] return short, True else: return res, False @@ -126,13 +127,7 @@ def compress_expression(expression, cutoff=15, sides=2): Takes a string and any numbers (consecutive digits) longer than cutoff gets replaced """ - def c_int(n): - n = str(n.group()) - if len(n) >= cutoff: - return n[:sides] + r'\!\cdots\!' + n[-sides:] - else: - return n - return re.sub(r'\d+', c_int, expression) + return re.sub(r'\d+', lambda a: compress_int(str(a.group()),cutoff, sides)[0], expression) def bigint_knowl(n, cutoff=20, max_width=70, sides=2): short, shortened = compress_int(n, cutoff=cutoff, sides=sides)
- $\displaystyle {{ data.curve }}$ + {{ data.curve|safe }} {% if data.g == 0 %} , with affine coordinate $x$ {% endif %} @@ -56,7 +56,7 @@

Curve

- \(\displaystyle {{ data.plane_model }} = 0\) + {{ data.plane_model|safe }} {% if data["curve_label"] %} , isomorphic to {% if data.g == 1 %} @@ -88,9 +88,9 @@

Curve

{{ KNOWL('belyi.galmap', 'Map') }}

{% if data.g == 0 %} -

\(\displaystyle \phi(x) = {{data.map}}\)

+

\(\displaystyle \phi(x) =\) {{data.map|safe}}

{% else %} -

\(\displaystyle \phi(x,y) = {{data.map}}\)

+

\(\displaystyle \phi(x,y) =\) {{data.map|safe}}

{% endif %}
diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py index a163d42a2c..98594b283f 100644 --- a/lmfdb/belyi/web_belyi.py +++ b/lmfdb/belyi/web_belyi.py @@ -4,7 +4,7 @@ from lmfdb.number_fields.web_number_field import WebNumberField from lmfdb.galois_groups.transitive_group import transitive_group_display_knowl from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing, NumberField, factor -from lmfdb.utils import names_and_urls, prop_int_pretty +from lmfdb.utils import names_and_urls, prop_int_pretty, raw_typeset from flask import url_for from lmfdb import db @@ -257,13 +257,13 @@ def __init__(self, galmap, triple=None): if crv_str == "PP1": data["curve"] = r"\mathbb{P}^1" else: - data["curve"] = make_curve_latex(crv_str, nu=self.embedding) + data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+make_curve_latex(crv_str, nu=self.embedding)+'$') - data["map"] = make_map_latex(galmap["map"], nu=self.embedding) + data["map"] = raw_typeset(galmap["map"], r'$\displaystyle '+make_map_latex(galmap["map"], nu=self.embedding)+'$') data["lambdas"] = [str(c)[1:-1] for c in galmap["lambdas"]] # plane model if galmap.get("plane_model"): - data["plane_model"] = galmap["plane_model_latex"] + data["plane_model"] = raw_typeset(galmap["plane_model"]+'=0', r'$\displaystyle '+galmap["plane_model_latex"]+'=0$') if galmap.get('plane_map_constant_factored'): data['plane_map_constant_factored'] = galmap['plane_map_constant_factored'] From f98a6915f25e6d8dc32b9a1d530fa921dfc34188 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 17 Aug 2023 19:28:13 -0400 Subject: [PATCH 02/14] tweak tests to match new (slightly modified) output --- lmfdb/belyi/test_belyi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lmfdb/belyi/test_belyi.py b/lmfdb/belyi/test_belyi.py index 6d9139c5c2..76a951059c 100644 --- a/lmfdb/belyi/test_belyi.py +++ b/lmfdb/belyi/test_belyi.py @@ -20,10 +20,10 @@ def test_passport(self): self.check_args("/Belyi/9T33-5.2.2_5.3.1_2.2.2.2.1-a", "3.1.14175.1") def test_smooth_equation(self): - self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"\phi(x) = 9075734485907514624 \frac{x^{9}}{4537867242953757312 x^{9} - 10520021716426424475 x^{8} + 12447550725170242500 x^{6} - 9941569340991356250 x^{4} + 4201111257707812500 x^{2} - 724916949326171875}\)") + self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"9075734485907514624 \frac{x^{9}}{4537867242953757312 x^{9} - 10520021716426424475 x^{8} + 12447550725170242500 x^{6} - 9941569340991356250 x^{4} + 4201111257707812500 x^{2} - 724916949326171875}") def test_plane_equation(self): - self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"x^{9} t + \left(-126 x^{4} + 420 x^{3} - 540 x^{2} + 315 x - 70\right) = 0") + self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"x^{9} t + \left(-126 x^{4} + 420 x^{3} - 540 x^{2} + 315 x - 70") # web pages From b6761b9d92231ae6056be7adcfd588a3208d8996 Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 27 Sep 2023 12:07:24 -0400 Subject: [PATCH 03/14] Latex --- lmfdb/belyi/web_belyi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py index 98594b283f..a1af1cf717 100644 --- a/lmfdb/belyi/web_belyi.py +++ b/lmfdb/belyi/web_belyi.py @@ -255,7 +255,7 @@ def __init__(self, galmap, triple=None): crv_str = galmap["curve"] if crv_str == "PP1": - data["curve"] = r"\mathbb{P}^1" + data["curve"] = r"$\mathbb{P}^1$" else: data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+make_curve_latex(crv_str, nu=self.embedding)+'$') From d6635119c2e81778bfe1a55549c5095e505d42cd Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 27 Sep 2023 13:11:42 -0400 Subject: [PATCH 04/14] Test version --- lmfdb/belyi/templates/belyi_galmap.html | 3 +++ lmfdb/belyi/web_belyi.py | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lmfdb/belyi/templates/belyi_galmap.html b/lmfdb/belyi/templates/belyi_galmap.html index 1ce7156f00..3c1f8a3f4c 100644 --- a/lmfdb/belyi/templates/belyi_galmap.html +++ b/lmfdb/belyi/templates/belyi_galmap.html @@ -57,6 +57,9 @@

Curve

{{ data.plane_model|safe }} +
+
+ {{ data.plane_model2|safe }} {% if data["curve_label"] %} , isomorphic to {% if data.g == 1 %} diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py index a1af1cf717..aadada19e7 100644 --- a/lmfdb/belyi/web_belyi.py +++ b/lmfdb/belyi/web_belyi.py @@ -6,6 +6,7 @@ from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing, NumberField, factor from lmfdb.utils import names_and_urls, prop_int_pretty, raw_typeset from flask import url_for +import re from lmfdb import db @@ -143,6 +144,15 @@ def make_plane_model_latex_factored(crv_str, numfld_cs, nu=None): f_str += latex(factor(cs[-1])) + latex(mons[-1]) return f_str +def belyi_latex(s): + str = s.replace('*',' ') + str = str.replace('(',r'\left(') + str = str.replace(')',r'\right)') + str = str.replace('nu',r'\nu') + # multidigit exponents + str = re.sub(r'\^\s*(\d+)', r'^{\1}',str) + return str + ############################################################################### # Belyi map class definitions ############################################################################### @@ -263,7 +273,9 @@ def __init__(self, galmap, triple=None): data["lambdas"] = [str(c)[1:-1] for c in galmap["lambdas"]] # plane model if galmap.get("plane_model"): - data["plane_model"] = raw_typeset(galmap["plane_model"]+'=0', r'$\displaystyle '+galmap["plane_model_latex"]+'=0$') + data["plane_model"] = raw_typeset(galmap["plane_model"]+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$') + data["plane_model2"] = r'$\displaystyle '+galmap["plane_model_latex"]+'=0$' + if galmap.get('plane_map_constant_factored'): data['plane_map_constant_factored'] = galmap['plane_map_constant_factored'] From c43bb7e723e7366bab01c024dc8095fbb169af27 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 29 Sep 2023 15:25:26 -0400 Subject: [PATCH 05/14] Remove old version --- lmfdb/belyi/templates/belyi_galmap.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/lmfdb/belyi/templates/belyi_galmap.html b/lmfdb/belyi/templates/belyi_galmap.html index 3c1f8a3f4c..1ce7156f00 100644 --- a/lmfdb/belyi/templates/belyi_galmap.html +++ b/lmfdb/belyi/templates/belyi_galmap.html @@ -57,9 +57,6 @@

Curve

{{ data.plane_model|safe }} -
-
- {{ data.plane_model2|safe }} {% if data["curve_label"] %} , isomorphic to {% if data.g == 1 %} From 19107923f6d79ee6e1a1ca4e53bf1c3b2cb89945 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 3 Oct 2023 15:11:43 -0400 Subject: [PATCH 06/14] Handle "is isomorphic to" --- lmfdb/belyi/templates/belyi_galmap.html | 33 ++------ lmfdb/belyi/web_belyi.py | 105 +++++++++++++----------- 2 files changed, 64 insertions(+), 74 deletions(-) diff --git a/lmfdb/belyi/templates/belyi_galmap.html b/lmfdb/belyi/templates/belyi_galmap.html index 1ce7156f00..3d81cc210d 100644 --- a/lmfdb/belyi/templates/belyi_galmap.html +++ b/lmfdb/belyi/templates/belyi_galmap.html @@ -37,19 +37,9 @@

Curve

{{ data.curve|safe }} - {% if data.g == 0 %} + {%- if data.g == 0 -%} , with affine coordinate $x$ {% endif %} - {% if data["curve_label"] %} - , isomorphic to - {% if data.g == 1 %} - elliptic - {% endif %} - {% if data.g == 2 %} - genus 2 - {% endif %} - curve with label {{data["curve_label"]}} - {% endif %}
{{ data.plane_model|safe }} - {% if data["curve_label"] %} - , isomorphic to - {% if data.g == 1 %} - elliptic - {% endif %} - {% if data.g == 2 %} - genus 2 - {% endif %} - curve with label {{data["curve_label"]}} - {% endif %} -