diff --git a/lmfdb/groups/abstract/main.py b/lmfdb/groups/abstract/main.py index dabaa916fc..2d35a513ad 100644 --- a/lmfdb/groups/abstract/main.py +++ b/lmfdb/groups/abstract/main.py @@ -1347,7 +1347,6 @@ def diagram_js_string(gp, only=None): # Writes individual pages def render_abstract_group(label, data=None): - info = {} if data is None: label = clean_input(label) @@ -1451,13 +1450,22 @@ def render_abstract_group(label, data=None): bread = get_bread([(label, "")]) learnmore_gp_picture = ('Picture description', url_for(".picture_page")) + gp.code_snippets() + if gp.live(): + code = None + else: + code = gp.code +# print("HERE IS gp.code", gp.code) + return render_template( "abstract-show-group.html", title=title, bread=bread, info=info, gp=gp, + # code=gp.code, + code=code, properties=gp.properties(), friends=friends, learnmore=learnmore_list_add(*learnmore_gp_picture), @@ -2845,3 +2853,16 @@ def order_stats_list_to_string(o_list): if o_list.index(pair) != len(o_list) - 1: s += "," return s + + +sorted_code_names = ['presentation', 'permutation', 'matrix', 'transitive'] + +code_names = {'presentation': 'Define the group using generators and relations', + 'permutation': 'Define the group as a permutation group', + 'matrix': 'Define the group as a matrix group', + 'transitivei': 'Define the group from the transitive group database'} + +Fullname = {'magma': 'Magma', 'gap': 'Gap'} +Comment = {'magma': '//', 'gap': '#'} + + diff --git a/lmfdb/groups/abstract/templates/abstract-show-group.html b/lmfdb/groups/abstract/templates/abstract-show-group.html index 4bf5215a95..60b0a2cdad 100644 --- a/lmfdb/groups/abstract/templates/abstract-show-group.html +++ b/lmfdb/groups/abstract/templates/abstract-show-group.html @@ -1,8 +1,8 @@ {% extends "homepage.html" %} - {% block content %} + + {% if gp.live() %}
This group is not stored in the database. However, basic information about the group, computed on the fly, is listed below. diff --git a/lmfdb/groups/abstract/web_groups.py b/lmfdb/groups/abstract/web_groups.py index 647a57a294..304657eb51 100644 --- a/lmfdb/groups/abstract/web_groups.py +++ b/lmfdb/groups/abstract/web_groups.py @@ -1,6 +1,7 @@ import re # import timeout_decorator - +import os +import yaml from lmfdb import db from flask import url_for from urllib.parse import quote_plus @@ -94,6 +95,12 @@ def group_pretty_image(label): return str(img) # we should not get here + + + + + + @cached_function(key=lambda label,name,pretty,ambient,aut,profiledata,cache: (label,name,pretty,ambient,aut,profiledata)) def abstract_group_display_knowl(label, name=None, pretty=True, ambient=None, aut=False, profiledata=None, cache={}): # If you have the group in hand, set the name using gp.tex_name since that will avoid a database call @@ -1818,7 +1825,8 @@ def _matrix_coefficient_data(self, rep_type, as_str=False): rep_type = "GLFp" return R, N, k, d, rep_type - def decode_as_matrix(self, code, rep_type, as_str=False, LieType=False): + def decode_as_matrix(self, code, rep_type, as_str=False, LieType=False, ListForm = False): + # ListForm is for code snippet if rep_type == "GLZ" and not isinstance(code, int): # decimal here represents an integer encoding b a, b = str(code).split(".") code = int(a) @@ -1839,6 +1847,8 @@ def pad(X, m): elif rep_type == "GLZ": shift = (N - 1) // 2 L = [c - shift for c in L] + if ListForm: + return L x = matrix(R, d, d, L) if as_str: # for projective families, we add "[ ]" @@ -1953,8 +1963,9 @@ def print_elt(vec): relators = ", ".join(rel_powers + relators) return r"\langle %s \mid %s \rangle" % (show_gens, relators) - def presentation_raw(self): + def presentation_raw(self, as_str = True): # We use knowledge of the form of the presentation to construct it manually. + # Need as_str = False for code snippet gens = list(self.PCG.GeneratorsOfGroup()) pcgs = self.PCG.FamilyPcgs() used = [u - 1 for u in sorted(self.gens_used)] # gens_used is 1-indexed @@ -2005,16 +2016,22 @@ def print_elt(vec): for j in range(i + 1, ngens): b = used[j] if all(x == 0 for x in pcgs.ExponentsOfCommutator(b + 1, a + 1)): # back to 1-indexed - if not self.abelian: + if not as_str: # print commutator out for code snippets + comm.append("%s^-1*%s^-1*%s*%s" % (var_name(i), var_name(j), var_name(i), var_name(j))) + elif not self.abelian: comm.append("[%s,%s]" % (var_name(i), var_name(j))) else: v = pcgs.ExponentsOfConjugate(b + 1, a + 1) # back to 1-indexed relators.append("%s*%s^-1*%s^-1*%s" % (print_elt(v), var_name(i), var_name(j), var_name(i))) - show_gens = ", ".join(var_name(i) for i in range(len(used))) if pure_powers or comm: rel_powers = [",".join(pure_powers + comm)] + rel_powers relators = ", ".join(rel_powers + relators) - return r"< %s | %s >" % (show_gens, relators) + if as_str: + show_gens = ", ".join(var_name(i) for i in range(len(used))) + return r"< %s | %s >" % (show_gens, relators) + else: + show_gens = ",".join(var_name(i) for i in range(len(used))) # no space for code snipptes + return show_gens, relators, len(used) @lazy_attribute def representations(self): @@ -2061,25 +2078,31 @@ def representation_line(self, rep_type, skip_head=False): pres = self.presentation() pres_raw=self.presentation_raw() pres = raw_typeset(pres_raw,compress_pres(pres)) + if self.live(): + code_cmd = None + else: + code_cmd = self.create_snippet('presentation') if self.abelian and not self.cyclic: pres = "Abelian group " + pres - return f'