def getMaassDb(): # NB although base.getDBConnection().PORT works it gives the # default port number of 27017 and not the actual one! if pymongo.version_tuple[0] < 3: host = base.getDBConnection().host port = base.getDBConnection().port else: host, port = base.getDBConnection().address return MaassDB(host=host, port=port)
def render_hiwf_webpage(**args): C = getDBConnection() data = None if 'label' in args: label = str(args['label']) data = C.halfintegralmf.forms.find_one({'label': label}) if data is None: return "No such field" info = {} info.update(data) info['friends'] = [] bread = [('Half Integral Weight Cusp Forms', url_for(".half_integral_weight_form_render_webpage")), ('%s' % data['label'], ' ')] t = "Half Integral Weight Cusp Forms %s" % info['label'] credit = 'Samuele Anni and Soma Purkait' f = C.halfintegralmf.forms.find_one({'level': data['level'], 'weight': data['weight']}) dim = f['dim'] dimtheta = f['dimtheta'] dimnew=dim-dimtheta info['dimension'] = dim info['dimtheta']= dimtheta info['dimnew'] = dimnew chi = f['character'] info['ch_lab']= chi.replace('.','/') chi1=chi.split(".") chi2="\chi_{"+chi1[0]+"}("+chi1[1]+",\cdot)" info['char']= chi2 info['newpart']=f['newpart'] new=[] for n in f['newpart']: v={} v['dim'] = n['dim_image'] s=[] for h in n['half_forms']: s.append(my_latex_from_qexp(print_q_expansion(h))) v['hiwf'] = s v['mf'] = n['mf_label'] v['nf'] = n['nf_label'] v['field_knowl'] = nf_display_knowl(n['nf_label'], getDBConnection(), n['nf_label']) new.append(v) info['new']= new if dimtheta !=0: theta=[] for m in f['thetas']: for n in m: n_lab= n.replace('.','/') n_l=n.split(".") n_lat="\chi_{"+n_l[0]+"}("+n_l[1]+",\cdot)" v=[n_lab, n_lat] theta.append(v) info['theta']= theta else: info['theta']= f['thetas'] return render_template("half_integral_weight_form.html", info=info, credit=credit, title=t, bread=bread)
def updateMetadata(): db = getDBConnection().upload id = request.values['id'] property = request.values['property'] value = request.values['value'] db.fs.files.update({"_id": ObjectId(id)}, {"$set": {"metadata." + property: value}}) if property == "status": db.fs.files.update({"metadata.parent_archive_id": ObjectId(id)}, {"$set": { "metadata.status": value + "child"}}, multi=1) return getDBConnection().upload.fs.files.find_one({"_id": ObjectId(id)})['metadata'][property]
def random_sample_name(): # do this ourselves rather than using random_object_from_collection, but use # the random object index if it exists (it should only contain records for samples, not evs of fcs) n = getDBConnection().siegel_modular_forms.samples.rand.count() if n: id = getDBConnection().siegel_modular_forms.samples.rand.find_one({'num':randint(1,n)})['_id'] data = smf_db_samples().find_one({'_id':id},{'_id':False,'collection':True,'name':True}) else: # do it the hard way, don't bother with aggregate (there are currently only a few hundred records in any case) recs = [r for r in smf_db_samples().find({'data_type':'sample'},{'_id':False,'collection':True,'name':True})] data = recs[randint(0,len(recs)-1)] return (data['collection'][0], data['name'])
def profile(userid): getDBConnection().knowledge.knowls.ensure_index('title') user = LmfdbUser(userid) bread = base_bread() + [(user.name, url_for('.profile', userid=user.get_id()))] userknowls = getDBConnection( ).knowledge.knowls.find({'authors': userid}, fields=['title']).sort([('title', ASC)]) userfiles = getDBConnection( ).upload.fs.files.find({'metadata.uploader_id': userid, 'metadata.status': 'approved'}) userfilesmod = getDBConnection( ).upload.fs.files.find({'metadata.uploader_id': userid, 'metadata.status': 'unmoderated'}) return render_template("user-detail.html", user=user, title="%s" % user.name, bread=bread, userknowls=userknowls, userfiles=userfiles, userfilesmod=userfilesmod)
def last_author(self): """ Full names for the last authors. (lookup for all full names in just *one* query, hence the or) """ users = getDBConnection().userdb.users return users.find_one({'_id': self._last_author}, ["full_name"])["full_name"]
def download(id, filename): file = GridFS(getDBConnection().upload).get(ObjectId(id)) response = flask.Response(file.__iter__()) response.headers['content-type'] = file.metadata['content_type'] response.content_length = file.length return response
def __init__(self, dbname='', **kwds): r""" For 'one-dimensional' data sets the second skip parameter does not have a meaning but should be present anyway... """ self._skip = kwds.get('skip', []) self._limit = kwds.get('limit', []) self._keys = kwds.get('keys', []) self._db = getDBConnection()[dbname] self._collection_name = kwds.get('collection', 'all') self._collection = [] self._skip_rec = 0 self._props = {} if self._limit and self._skip: self._nrows = self._limit[0] if len(self._limit) > 1: self._ncols = self._limit[1] else: self._ncols = 1 if len(self._skip) == 2: self._skip_rows = self._skip[0] self._skip_cols = self._skip[1] else: self._skip_rec = self._skip[0] self._table = dict() self._is_set = False self._set_collection() self._row_heads = [] self._col_heads = []
def random_lattice(): # Random Lattice from sage.misc.prandom import randint n = get_stats().counts()['nlattice'] n = randint(0,n-1) C = getDBConnection() res = C.Lattices.lat.find()[n] return redirect(url_for(".render_lattice_webpage", label=res['label']))
def random_hmf(): # Random Hilbert modular form from sage.misc.prandom import randint n = get_stats().counts()['nforms'] n = randint(0,n-1) C = getDBConnection() res = C.hmfs.forms.find()[n] return hilbert_modular_form_by_label(res)
def test_gamma1_pages(self): errors = [] spaces = getDBConnection().modularforms2.webmodformspace wmax = 10 Nmax = 50 data = spaces.find( { "weight": {"$ge": int(2)}, "weight": {"$lt": int(wmax + 1)}, "level": {"$lt": int(Nmax + 1)}, "version": float(version), } ) print "Checking %d spaces of weight w <= %d and level N <= %d" % (data.count(), wmax, Nmax) errors = self.check_spaces(data) if errors: print "Errors occurred for the following labels: ", errors wmax = 20 Nmax = 16 data = spaces.find( { "weight": {"$ge": int(2)}, "weight": {"$lt": int(wmax + 1)}, "level": {"$lt": int(Nmax + 1)}, "version": float(version), } ) print "Checking %d spaces of weight w <= %d and level N <= %d" % (data.count(), wmax, Nmax) errors = self.check_spaces(data) if errors: print "Errors occurred for the following labels: ", errors
def field_knowl(self): from lmfdb.WebNumberField import nf_display_knowl nfgg = self.number_field_galois_group() if nfgg.url_for(): return nf_display_knowl(nfgg.label(), getDBConnection(), nfgg.polredabshtml()) else: return nfgg.polredabshtml()
def galois_string(self): if not self.haskey('galois'): return 'Not computed' n = self._data['degree'] t = self._data['galois']['t'] C = base.getDBConnection() return group_display_short(n, t, C)
def test_completeness(self): import sys stdb = getDBConnection().sato_tate_groups.st_groups L = self.tc.get('/SatoTateGroup/?weight=1°ree=2') assert '3 matches' in L.data data = stdb.find({'weight':int(1),'degree':int(2)}) assert data.count() == 3 print "" for r in data: sys.stdout.write("{}...".format(r['label'])) sys.stdout.flush() L = self.tc.get('/SatoTateGroup/' + r['label']) assert r['label'] in L.data and 'Moment Statistics' in L.data data = stdb.find({'weight':int(1),'degree':int(2)}) L = self.tc.get('/SatoTateGroup/?weight=1°ree=4') assert 'of 52' in L.data data = stdb.find({'weight':int(1),'degree':int(4)}) assert data.count() == 52 for r in data: sys.stdout.write("{}...".format(r['label'])) sys.stdout.flush() L = self.tc.get('/SatoTateGroup/' + r['label']) assert r['label'] in L.data and 'Moment Statistics' in L.data L = self.tc.get('/SatoTateGroup/?components=999999999') assert 'unique match' in L.data and 'mu(999999999)' in L.data
def get_database_info(show_hidden=False): C = base.getDBConnection() info = {} for db in C.database_names(): if not censored_db(db): info[db] = sorted([(c, C[db][c].count()) for c in C[db].collection_names() if not censored_collection(c) and (show_hidden or not hidden_collection(c))]) return info
def random_hmf(): # Random Hilbert modular form from sage.misc.prandom import randint n = get_stats().counts()['nforms'] n = randint(0,n-1) C = getDBConnection() res = C.hmfs.forms.find()[n] return redirect(url_for(".render_hmf_webpage", field_label=res['field_label'], label=res['label']))
def download_search(info): lang = info["submit"] filename = "integral_rep_galois_modls" + download_file_suffix[lang] mydate = time.strftime("%d %B %Y") # reissue saved query here res = getDBConnection().rep_galois_modls.reps.find(ast.literal_eval(info["query"])) c = download_comment_prefix[lang] s = "\n" s += c + " Integral rep_galois_modls downloaded from the LMFDB on %s. Found %s rep_galois_modls.\n\n" % ( mydate, res.count(), ) # The list entries are matrices of different sizes. Sage and gp # do not mind this but Magma requires a different sort of list. list_start = "[*" if lang == "magma" else "[" list_end = "*]" if lang == "magma" else "]" s += download_assignment_start[lang] + list_start + "\\\n" mat_start = "Mat(" if lang == "gp" else "Matrix(" mat_end = "~)" if lang == "gp" else ")" entry = lambda r: "".join([mat_start, str(r), mat_end]) # loop through all search results and grab the gram matrix s += ",\\\n".join([entry(r["gram"]) for r in res]) s += list_end s += download_assignment_end[lang] s += "\n" strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True)
def test_all_pages(self): errors = [] curves = getDBConnection().genus2_curves.curves data = curves.find({},{'_id':False,'label':True,'class':True}) n = 0 for c in data: l = c['label'].split('.') url = "Genus2Curve/Q/%s/%s/%s/%s"%(l[0],l[1],l[2],l[3]) print "Checking home page for genus 2 curve " + c['label'] try: n = n+1 page = self.tc.get(url, follow_redirects=True) assert c['label'] in page.data except: print "Internal server error on page " + url errors.append(url) continue url = "Genus2Curve/Q/%s/%s/"%(l[0],l[1]) print "Checking home page for genus 2 isogeny class " + c['class'] try: n = n+1 page = self.tc.get(url, follow_redirects=True) assert c['label'] in page.data except: print "Internal server error on page "+url errors.append(url) continue if not errors: print "Tested %s pages with no errors" % n else: print "Tested %d pages with %d errors occuring on the following pages:" %(n,len(errors)) for url in errors: print url
def render_groups_page(): info = {} info['learnmore'] = [('Global number field labels', url_for(".render_labels_page")), ('Galois group labels', url_for(".render_groups_page")), (Completename, url_for(".render_discriminants_page")) ] t = 'Galois group labels' bread = [('Global Number Fields', url_for(".number_field_render_webpage")), ('Galois group labels', ' ')] C = base.getDBConnection() return render_template("galois_groups.html", al=aliastable(C), info=info, credit=NF_credit, title=t, bread=bread, learnmore=info.pop('learnmore'))
def init_nf_count(): global nfields, init_nf_flag, max_deg if not init_nf_flag: nfdb = base.getDBConnection().numberfields.fields nfields = nfdb.count() max_deg = nfdb.find().sort('degree', pymongo.DESCENDING).limit(1)[0]['degree'] init_nf_flag = True
def random_nfglobal(): label = random_object_from_collection( getDBConnection().numberfields.fields )['label'] #This version leaves the word 'random' in the URL: #return render_field_webpage({'label': label}) #This version uses the number field's own URL: #url = return redirect(url_for(".by_label", label= label))
def download_search(info): lang = info["submit"] filename = 'mod_l_modular_forms' + download_file_suffix[lang] mydate = time.strftime("%d %B %Y") # reissue saved query here res = getDBConnection().mod_l_eigenvalues.modlmfs.find(ast.literal_eval(info["query"])) c = download_comment_prefix[lang] s = '\n' s += c + ' Mod l modular forms downloaded from the LMFDB on %s. Found %s mod l modular forms.\n\n'%(mydate, res.count()) s += ' Each entry is given in the following format: field characteristic, field degree, level, minimal weight, conductor.\n\n' list_start = '[*' if lang=='magma' else '[' list_end = '*]' if lang=='magma' else ']' s += download_assignment_start[lang] + list_start + '\\\n' for r in res: for m in ['characteristic', 'deg', 'level', 'min_weight', 'conductor']: s += ",\\\n".join(str(r[m])) s += list_end s += download_assignment_end[lang] s += '\n' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
def galois_rep_from_path(p): C = getDBConnection() if p[0]=='EllipticCurve': # create the sage elliptic curve then create Galois rep object data = C.elliptic_curves.curves.find_one({'lmfdb_label':p[2]}) ainvs = [int(a) for a in data['ainvs']] E = EllipticCurve(ainvs) return GaloisRepresentation(E) elif (p[0]=='Character' and p[1]=='Dirichlet'): dirichletArgs = {'type':'Dirichlet', 'modulus':int(p[2]), 'number':int(p[3])} chi = WebDirichletCharacter(**dirichletArgs) return GaloisRepresentation(chi) elif (p[0]=='ModularForm'): N = int(p[4]) k = int(p[5]) chi = p[6] # this should be zero; TODO check this is the case label = p[7] # this is a, b, c, etc.; chooses the galois orbit embedding = p[8] # this is the embedding of that galois orbit form = WebNewForm(N, k, chi=chi, label=label) return GaloisRepresentation([form, embedding]) elif (p[0]=='ArtinRepresentation'): dim = p[1] conductor = p[2] index = p[3] rho = ArtinRepresentation(dim, conductor, index) return GaloisRepresentation(rho) else: return
def download_search(info): lang = info["submit"] filename = 'integral_lattices' + download_file_suffix[lang] mydate = time.strftime("%d %B %Y") # reissue saved query here res = getDBConnection().Lattices.lat.find(ast.literal_eval(info["query"])) c = download_comment_prefix[lang] s = '\n' s += c + ' Integral Lattices downloaded from the LMFDB on %s. Found %s lattices.\n\n'%(mydate, res.count()) # The list entries are matrices of different sizes. Sage and gp # do not mind this but Magma requires a different sort of list. list_start = '[*' if lang=='magma' else '[' list_end = '*]' if lang=='magma' else ']' s += download_assignment_start[lang] + list_start + '\\\n' mat_start = "Mat(" if lang == 'gp' else "Matrix(" mat_end = "~)" if lang == 'gp' else ")" entry = lambda r: "".join([mat_start,str(r),mat_end]) # loop through all search results and grab the gram matrix s += ",\\\n".join([entry(r['gram']) for r in res]) s += list_end s += download_assignment_end[lang] s += '\n' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
def field_stats(F): ff = F.replace(".",":") return {'nforms': field_data[ff]['nforms'], 'maxnorm': field_data[ff]['max_norm'], 'field_knowl': nf_display_knowl(F, getDBConnection(), F), 'forms': url_for('hmf.hilbert_modular_form_render_webpage', field_label=F) }
def test_all_sample_pages(self): """ Verify that every sample form home page loads OK (should take under 10s on atkin) """ errors = [] samples = getDBConnection().siegel_modular_forms.samples data = samples.find({'collection':{'$exists':True},'name':{'$exists':True}},{'_id':False,'collection':True,'name':True}) assert data.count() >= 129 n = 0 print "" import sys for s in data: full_label = s['collection'][0] + "." + s['name'] sys.stdout.write("Checking {}...".format(full_label)) sys.stdout.flush() try: n = n+1 self.check(full_label,[full_label,'Hecke eigenform']) except: print "\nError on page " + full_label errors.append(full_label) if not errors: print "\nTested %s SMF pages with no errors" % n else: print "\nTested %d pages with %d errors occuring on the following pages:" %(n,len(errors)) for label in errors: print label
def test_completeness(self): print "" L = self.tc.get('/SatoTateGroup/?weight=1°ree=2') assert '3 matches' in L.data L = self.tc.get('/SatoTateGroup/U(1)') assert '1.2.1.1.1a' in L.data L = self.tc.get('/SatoTateGroup/N(U(1))') assert '1.2.1.2.1a' in L.data L = self.tc.get('/SatoTateGroup/SU(2)') assert '1.2.3.1.1a' in L.data stdb = getDBConnection().sato_tate_groups.st_groups data = stdb.find({'weight':int(1),'degree':int(2)}) assert data.count() == 3 for r in data: print 'Checking Sato-Tate group ' + r['label'] L = self.tc.get('/SatoTateGroup/?label='+r['label']) assert r['label'] in L.data and 'Moment Statistics' in L.data L = self.tc.get('/SatoTateGroup/?weight=1°ree=4') assert 'of 52' in L.data data = stdb.find({'weight':int(1),'degree':int(4)}) assert data.count() == 52 for r in data: print 'Checking Sato-Tate group ' + r['label'] L = self.tc.get('/SatoTateGroup/?label='+r['label']) assert r['label'] in L.data and 'Moment Statistics' in L.data
def getInstanceLdata(label,label_type="url"): db = base.getDBConnection().Lfunctions try: if label_type == "url": Lpointer = db.instances.find_one({'url': label}) if not Lpointer: return None Lhash = Lpointer['Lhash'] Ldata = db.Lfunctions.find_one({'Lhash': Lhash}) # do not ignore this error, if the instances record exists the # Lhash should be there and we want to know if it is not if not Ldata: raise KeyError("Lhash '%s' in instances record for URL '%s' not found in Lfunctions collection" % (label, Lhash)) elif label_type == "Lhash": Ldata = db.Lfunctions.find_one({'Lhash': label}) else: raise ValueError("Invalid label_type = '%s', should be 'url' or 'Lhash'" % label) # Need to change this so it shows the nonvanishing derivative if Ldata['order_of_vanishing'] or 'leading_term' not in Ldata.keys(): central_value = [0.5 + 0.5*Ldata['motivic_weight'], 0] else: central_value = [0.5 + 0.5*Ldata['motivic_weight'],Ldata['leading_term']] if 'values' not in Ldata: Ldata['values'] = [ central_value ] else: Ldata['values'] += [ central_value ] except ValueError: Ldata = None return Ldata
def getGenus2IsogenyClass(label): connection = base.getDBConnection() g2 = connection.genus2_curves try: iso = g2.isogeny_classes.find_one({'label': label}) except: iso = None return iso
def getEllipticCurveLData(label): connection = base.getDBConnection() coll = connection.Lfunctions.Lfunctions try: Ldata = coll.find_one({'instances': label}) except: Ldata = None return Ldata
def higher_genus_w_automorphisms_search(**args): info = to_dict(args) bread = get_bread([("Search results", '')]) C = base.getDBConnection() query = {} if 'jump_to' in info: labs = info['jump_to'] if label_is_one_passport(labs): return render_passport({'passport_label': labs}) elif label_is_one_family(labs): return render_family({'label': labs}) else: flash_error( "The label %s is not a legitimate label for this data.", labs) return redirect(url_for(".index")) #allow for ; in signature if info.get('signature'): info['signature'] = info['signature'].replace(';', ',') try: parse_gap_id(info, query, 'group', 'Group') parse_ints(info, query, 'genus', name='Genus') parse_bracketed_posints(info, query, 'signature', split=False, name='Signature', keepbrackets=True) if query.get('signature'): query['signature'] = info['signature'] = str( sort_sign(ast.literal_eval(query['signature']))).replace( ' ', '') parse_ints(info, query, 'dim', name='Dimension of the family') if 'inc_hyper' in info: if info['inc_hyper'] == 'exclude': query['hyperelliptic'] = False elif info['inc_hyper'] == 'only': query['hyperelliptic'] = True if 'inc_cyc_trig' in info: if info['inc_cyc_trig'] == 'exclude': query['cyclic_trigonal'] = False elif info['inc_cyc_trig'] == 'only': query['cyclic_trigonal'] = True if 'inc_full' in info: if info['inc_full'] == 'exclude': query['full_auto'] = {'$exists': True} elif info['inc_full'] == 'only': query['full_auto'] = {'$exists': False} query['cc.1'] = 1 except ValueError: return search_input_error(info, bread) count = parse_count(info) start = parse_start(info) res = C.curve_automorphisms.passports.find(query).sort([ ('genus', pymongo.ASCENDING), ('dim', pymongo.ASCENDING), ('cc'[0], pymongo.ASCENDING) ]) nres = res.count() res = res.skip(start).limit(count) if (start >= nres): start -= (1 + (start - nres) / count) * count if (start < 0): start = 0 L = [] for field in res: field['signature'] = ast.literal_eval(field['signature']) L.append(field) info['fields'] = L info['number'] = nres info['group_display'] = sg_pretty info['sign_display'] = sign_display info['start'] = start if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % ( start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres return render_template( "hgcwa-search.html", info=info, title= "Families of Higher Genus Curves with Automorphisms Search Result", bread=bread)
import sys sys.path.append("../..") import pymongo from lmfdb import base from lmfdb.website import dbport from lmfdb.WebNumberField import WebNumberField from lmfdb.hilbert_modular_forms.hilbert_field import (findvar, niceideals, conjideals, str2ideal) print "calling base._init()" dbport = 37010 base._init(dbport, '') print "getting connection" conn = base.getDBConnection() print "setting hmfs, fields and forms" hmfs = conn.hmfs fields = hmfs.fields forms = hmfs.forms nfcurves = conn.elliptic_curves.nfcurves # Cache of WebNumberField and FieldData objects to avoid re-creation WNFs = {} Fdata = {} def get_WNF(label, gen_name): if not label in WNFs: WNFs[label] = WebNumberField(label, gen_name=gen_name) return WNFs[label]
def make_form(self): # To start with the data fields of self are just those from # the database. We need to reformat these and compute some # further (easy) data about it. # from lmfdb.ecnf.WebEllipticCurve import FIELD self.field = FIELD(self.field_label) pretty_field = field_pretty(self.field_label) self.field_knowl = nf_display_knowl(self.field_label, getDBConnection(), pretty_field) try: dims = db_dims().find_one({ 'field_label': self.field_label, 'level_label': self.level_label })['gl2_dims'] self.newspace_dimension = dims[str(self.weight)]['new_dim'] except TypeError: self.newspace_dimension = 'not available' self.newspace_label = "-".join([self.field_label, self.level_label]) self.newspace_url = url_for(".render_bmf_space_webpage", field_label=self.field_label, level_label=self.level_label) K = self.field.K() if self.dimension > 1: Qx = PolynomialRing(QQ, 'x') self.hecke_poly = Qx(str(self.hecke_poly)) F = NumberField(self.hecke_poly, 'z') self.hecke_poly = web_latex(self.hecke_poly) def conv(ap): if '?' in ap: return 'not known' else: return F(str(ap)) self.hecke_eigs = [conv(str(ap)) for ap in self.hecke_eigs] self.nap = len(self.hecke_eigs) self.nap0 = min(50, self.nap) self.hecke_table = [[ web_latex(p.norm()), ideal_label(p), web_latex(p.gens_reduced()[0]), web_latex(ap) ] for p, ap in zip(primes_iter(K), self.hecke_eigs[:self.nap0])] level = ideal_from_label(K, self.level_label) self.level_ideal2 = web_latex(level) badp = level.prime_factors() self.have_AL = self.AL_eigs[0] != '?' if self.have_AL: self.AL_table = [[ web_latex(p.norm()), ideal_label(p), web_latex(p.gens_reduced()[0]), web_latex(ap) ] for p, ap in zip(badp, self.AL_eigs)] self.sign = 'not determined' if self.sfe == 1: self.sign = "+1" elif self.sfe == -1: self.sign = "-1" if self.Lratio == '?': self.Lratio = "not determined" self.anrank = "not determined" else: self.Lratio = QQ(self.Lratio) self.anrank = "\(0\)" if self.Lratio != 0 else "odd" if self.sfe == -1 else "\(\ge2\), even" self.properties2 = [('Base field', pretty_field), ('Weight', str(self.weight)), ('Level norm', str(self.level_norm)), ('Level', self.level_ideal2), ('Label', self.label), ('Dimension', str(self.dimension))] if self.CM == '?': self.CM = 'not determined' elif self.CM == 0: self.CM = 'no' self.properties2.append(('CM', str(self.CM))) self.bc_extra = '' self.bcd = 0 self.bct = self.bc != '?' and self.bc != 0 if self.bc == '?': self.bc = 'not determined' elif self.bc == 0: self.bc = 'no' elif self.bc == 1: self.bcd = self.bc self.bc = 'yes' elif self.bc > 1: self.bcd = self.bc self.bc = 'yes' self.bc_extra = ', of a form over \(\mathbb{Q}\) with coefficients in \(\mathbb{Q}(\sqrt{' + str( self.bcd) + '})\)' elif self.bc == -1: self.bc = 'no' self.bc_extra = ', but is a twist of the base-change of a form over \(\mathbb{Q}\)' elif self.bc < -1: self.bcd = -self.bc self.bc = 'no' self.bc_extra = ', but is a twist of the base-change of a form over \(\mathbb{Q}\) with coefficients in \(\mathbb{Q}(\sqrt{' + str( self.bcd) + '})\)' self.properties2.append(('Base-change', str(self.bc))) curve = db_ecnf().find_one({'class_label': self.label}) if curve: self.ec_status = 'exists' self.ec_url = url_for("ecnf.show_ecnf_isoclass", nf=self.field_label, conductor_label=self.level_label, class_label=self.label_suffix) curve_bc = curve['base_change'] curve_bc_parts = [split_lmfdb_label(lab) for lab in curve_bc] bc_urls = [ url_for("emf.render_elliptic_modular_forms", level=cond, weight=2, character=1, label=iso) for cond, iso, num in curve_bc_parts ] bc_labels = [ newform_label(cond, 2, 1, iso) for cond, iso, num in curve_bc_parts ] bc_exists = [is_newform_in_db(lab) for lab in bc_labels] self.bc_forms = [{ 'exists': ex, 'label': lab, 'url': url } for ex, lab, url in zip(bc_exists, bc_labels, bc_urls)] else: self.bc_forms = [] if self.bct: self.ec_status = 'none' else: self.ec_status = 'missing' self.properties2.append(('Sign', self.sign)) self.properties2.append(('Analytic rank', self.anrank)) self.friends = [] if self.dimension == 1: if self.ec_status == 'exists': self.friends += [ ('Elliptic curve isogeny class {}'.format(self.label), self.ec_url) ] elif self.ec_status == 'missing': self.friends += [ ('Elliptic curve {} missing'.format(self.label), "") ] else: self.friends += [('No elliptic curve', "")] self.friends += [('Newspace {}'.format(self.newspace_label), self.newspace_url)] self.friends += [('L-function not available', '')]
def db_forms(): return getDBConnection().bmfs.forms
def galois_module_data(n, t, index): C = base.getDBConnection() return galois_module_knowl_guts(n, t, index, C)
def galois_group_data(n, t): C = base.getDBConnection() return group_knowl_guts(n, t, C)
def render_group_webpage(args): data = None info = {} if 'label' in args: label = clean_input(args['label']) label = label.replace('t', 'T') C = base.getDBConnection() data = C.transitivegroups.groups.find_one({'label': label}) if data is None: bread = get_bread([("Search error", ' ')]) info['err'] = "Group " + label + " was not found in the database." info['label'] = label return search_input_error(info, bread) data['label_raw'] = label.lower() title = 'Galois Group: ' + label wgg = WebGaloisGroup.from_data(data) n = data['n'] t = data['t'] data['yesno'] = yesno order = data['order'] data['orderfac'] = latex(ZZ(order).factor()) orderfac = latex(ZZ(order).factor()) data['ordermsg'] = "$%s=%s$" % (order, latex(orderfac)) if order == 1: data['ordermsg'] = "$1$" if ZZ(order).is_prime(): data['ordermsg'] = "$%s$ (is prime)" % order pgroup = len(ZZ(order).prime_factors()) < 2 if n == 1: G = gap.SmallGroup(n, t) else: G = gap.TransitiveGroup(n, t) if ZZ(order) < ZZ('10000000000'): ctable = chartable(n, t) else: ctable = 'Group too large' data['gens'] = generators(n, t) if n == 1 and t == 1: data['gens'] = 'None needed' data['chartable'] = ctable data['parity'] = "$%s$" % data['parity'] data['cclasses'] = conjclasses(G, n) data['subinfo'] = subfield_display(C, n, data['subs']) data['resolve'] = resolve_display(C, data['resolve']) data['otherreps'] = wgg.otherrep_list() if len(data['otherreps']) == 0: data['otherreps'] = "There is no other low degree representation." query = {'galois': bson.SON([('n', n), ('t', t)])} C = base.getDBConnection() intreps = C.transitivegroups.Gmodules.find({ 'n': n, 't': t }).sort('index', pymongo.ASCENDING) # turn cursor into a list intreps = [z for z in intreps] if len(intreps) > 0: data['int_rep_classes'] = [str(z[0]) for z in intreps[0]['gens']] for onerep in intreps: onerep['gens'] = [ list_to_latex_matrix(z[1]) for z in onerep['gens'] ] data['int_reps'] = intreps data['int_reps_complete'] = int_reps_are_complete(intreps) dcq = data['moddecompuniq'] if dcq[0] == 0: data['decompunique'] = 0 else: data['decompunique'] = dcq[0] data['isoms'] = [[mult2mult(z[0]), mult2mult(z[1])] for z in dcq[1]] data['isoms'] = [[ modules2string(n, t, z[0]), modules2string(n, t, z[1]) ] for z in data['isoms']] #print dcq[1] #print data['isoms'] friends = [] one = C.numberfields.fields.find_one(query) if one: friends.append( ('Number fields with this Galois group', url_for('number_fields.number_field_render_webpage') + "?galois_group=%dT%d" % (n, t))) prop2 = [ ('Label', label), ('Order', '\(%s\)' % order), ('n', '\(%s\)' % data['n']), ('Cyclic', yesno(data['cyc'])), ('Abelian', yesno(data['ab'])), ('Solvable', yesno(data['solv'])), ('Primitive', yesno(data['prim'])), ('$p$-group', yesno(pgroup)), ] pretty = group_display_pretty(n, t, C) if len(pretty) > 0: prop2.extend([('Group:', pretty)]) info['pretty_name'] = pretty data['name'] = re.sub(r'_(\d+)', r'_{\1}', data['name']) data['name'] = re.sub(r'\^(\d+)', r'^{\1}', data['name']) info.update(data) bread = get_bread([(label, ' ')]) return render_template("gg-show-group.html", credit=GG_credit, title=title, bread=bread, info=info, properties2=prop2, friends=friends)
def db_iqf_labels(): return getDBConnection().elliptic_curves.IQF_labels
def db_nfdb(): global nfdb if nfdb is None: nfdb = getDBConnection().numberfields.fields return nfdb
def db_ecnf(): global ecnf if ecnf is None: ecnf = getDBConnection().elliptic_curves.nfcurves return ecnf
def db(): return base.getDBConnection()
def render_hiwf_webpage(**args): C = getDBConnection() data = None if 'label' in args: label = str(args['label']) data = C.halfintegralmf.forms.find_one({'label': label}) if data is None: return "No such field" info = {} info.update(data) info['friends'] = [] bread = [('Half Integral Weight Cusp Forms', url_for(".half_integral_weight_form_render_webpage")), ('%s' % data['label'], ' ')] t = "Half Integral Weight Cusp Forms %s" % info['label'] credit = 'Samuele Anni and Soma Purkait' f = C.halfintegralmf.forms.find_one({ 'level': data['level'], 'weight': data['weight'] }) dim = f['dim'] dimtheta = f['dimtheta'] dimnew = dim - dimtheta info['dimension'] = dim info['dimtheta'] = dimtheta info['dimnew'] = dimnew chi = f['character'] info['ch_lab'] = chi.replace('.', '/') chi1 = chi.split(".") chi2 = "\chi_{" + chi1[0] + "}(" + chi1[1] + ",\cdot)" info['char'] = chi2 info['newpart'] = f['newpart'] new = [] for n in f['newpart']: v = {} v['dim'] = n['dim_image'] s = [] for h in n['half_forms']: s.append(my_latex_from_qexp(print_q_expansion(h))) v['hiwf'] = s v['mf'] = n['mf_label'] v['nf'] = n['nf_label'] v['field_knowl'] = nf_display_knowl(n['nf_label'], getDBConnection(), n['nf_label']) new.append(v) info['new'] = new if dimtheta != 0: theta = [] for m in f['thetas']: for n in m: n_lab = n.replace('.', '/') n_l = n.split(".") n_lat = "\chi_{" + n_l[0] + "}(" + n_l[1] + ",\cdot)" v = [n_lab, n_lat] theta.append(v) info['theta'] = theta else: info['theta'] = f['thetas'] return render_template("half_integral_weight_form.html", info=info, credit=credit, title=t, bread=bread)
def galois_group_search(**args): info = to_dict(args) bread = get_bread([("Search results", ' ')]) C = base.getDBConnection() query = {} if 'jump_to' in info: return render_group_webpage({'label': info['jump_to']}) def includes_composite(s): s = s.replace(' ', '').replace('..', '-') for interval in s.split(','): if '-' in interval[1:]: ix = interval.index('-', 1) a, b = int(interval[:ix]), int(interval[ix + 1:]) if b == a: if a != 1 and not a.is_prime(): return True if b > a and b > 3: return True else: a = ZZ(interval) if a != 1 and not a.is_prime(): return True try: parse_ints(info, query, 'n', 'degree') parse_ints(info, query, 't') for param in ('cyc', 'solv', 'prim', 'parity'): parse_bool(info, query, param, minus_one_to_zero=(param != 'parity')) degree_str = prep_ranges(info.get('n')) info['show_subs'] = degree_str is None or ( LIST_RE.match(degree_str) and includes_composite(degree_str)) except ValueError as err: info['err'] = str(err) return search_input_error(info, bread) count = parse_count(info, 50) start = parse_start(info) res = C.transitivegroups.groups.find(query).sort([('n', pymongo.ASCENDING), ('t', pymongo.ASCENDING) ]) nres = res.count() res = res.skip(start).limit(count) if (start >= nres): start -= (1 + (start - nres) / count) * count if (start < 0): start = 0 info['groups'] = res info['group_display'] = group_display_prettyC(C) info['report'] = "found %s groups" % nres info['yesno'] = yesno info['wgg'] = WebGaloisGroup.from_data info['start'] = start info['number'] = nres if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % ( start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres return render_template("gg-search.html", info=info, title="Galois Group Search Result", bread=bread, credit=GG_credit)
def half_integral_weight_form_search(**args): C = getDBConnection() C.halfintegralmf.forms.ensure_index([('level', pymongo.ASCENDING), ('label', pymongo.ASCENDING)]) info = to_dict(args) # what has been entered in the search boxes if 'label' in info: args = {'label': info['label']} return render_hiwf_webpage(**args) query = {} for field in ['character', 'weight', 'level']: if info.get(field): if field == 'weight': query[field] = int(info[field]) elif field == 'character': query[field] = parse_field_string(info[field]) elif field == 'label': query[field] = info[field] elif field == 'level': query[field] = int(info[field]) info['query'] = dict(query) res = C.halfintegralmf.forms.find(query).sort([ ('level', pymongo.ASCENDING), ('label', pymongo.ASCENDING) ]) nres = res.count() count = 100 if nres == 1: info['report'] = 'unique match' else: if nres > count: info['report'] = 'displaying first %s of %s matches' % (count, nres) else: info['report'] = 'displaying all %s matches' % nres res_clean = [] for v in res: v_clean = {} v_clean['level'] = v['level'] v_clean['label'] = v['label'] v_clean['weight'] = v['weight'] v_clean['ch_lab'] = v['character'].replace('.', '/') v_clean['char'] = "\chi_{" + v['character'].split( ".")[0] + "}(" + v['character'].split(".")[1] + ",\cdot)" v_clean['dimension'] = v['dim'] res_clean.append(v_clean) info['forms'] = res_clean t = 'Half Integral Weight Cusp Forms search results' bread = [('Half Integral Weight Cusp Forms', url_for(".half_integral_weight_form_render_webpage")), ('Search results', ' ')] properties = [] return render_template("half_integral_weight_form_search.html", info=info, title=t, properties=properties, bread=bread)
def random_group(): label = random_object_from_collection( base.getDBConnection().transitivegroups.groups)['label'] return redirect(url_for(".by_label", label=label), 301)
def render_elliptic_modular_form_navigation_wp1(**args): r""" Renders the webpage for the navigational page. """ from sage.all import is_even info = to_dict(args) args = to_dict(request.args) info.update(args) form = to_dict(request.form) info.update(form) emf_logger.debug("render_c_m_f_n_wp info={0}".format(info)) level = my_get(info, 'level', 0, int) weight = my_get(info, 'weight', 0, int) group = my_get(info, 'group', 1, int) if group == int(0): pass character = my_get(info, 'character', 1, int) label = info.get('label', '') #disp = ClassicalMFDisplay('modularforms2') emf_logger.debug("info={0}".format(info)) emf_logger.debug("level=%s, %s" % (level, type(level))) emf_logger.debug("label=%s, %s" % (label, type(label))) emf_logger.debug("wt=%s, %s" % (weight, type(weight))) emf_logger.debug("character=%s, %s" % (character, type(character))) emf_logger.debug("group=%s, %s" % (group, type(group))) if ('plot' in info and level is not None): return render_fd_plot(level, info) is_set = dict() is_set['weight'] = False is_set['level'] = False limits_weight = extract_limits_as_tuple(info, 'weight') limits_level = extract_limits_as_tuple(info, 'level') if isinstance(weight, int) and weight > 0: is_set['weight'] = True weight = int(weight) else: weight = None info.pop('weight', None) if isinstance(level, int) and level > 0: is_set['level'] = True level = int(level) else: level = None info.pop('level', None) ## This is the list of weights we initially put on the form title = "Holomorphic Cusp Forms" bread = [(MF_TOP, url_for('mf.modular_form_main_page')), (title, url_for('.render_elliptic_modular_forms'))] limits_weight = extract_limits_as_tuple(info, 'weight') limits_level = extract_limits_as_tuple(info, 'level') # Special case: if the range reduces to a singleton for both level # and weight then we return a single page rather than a table: if limits_weight[0] == limits_weight[1] and limits_level[ 0] == limits_level[1]: return render_elliptic_modular_form_space_list_chars( limits_level[0], limits_weight[0]) if is_set['weight']: limits_weight = (weight, weight) elif limits_weight is None: limits_weight = (2, 12) # default values if is_set['level']: limits_level = (level, level) elif limits_level is None: limits_level = (1, 24) # default values try: group = info.get('group', 0) # default group is gamma_0 group = int(group) except ValueError: group = 0 if group not in [0, 1]: group = 0 if group == 0: info['grouptype'] = 0 info['groupother'] = 1 else: info['grouptype'] = 1 info['groupother'] = 0 emf_logger.debug("level:{0},level_range={1}".format(level, limits_level)) emf_logger.debug("weight:{0},weight_range={1}".format( weight, limits_weight)) if limits_weight[0] == limits_weight[1] and limits_level[ 0] == limits_level[1]: return redirect(url_for("emf.render_elliptic_modular_forms", level=limits_level[0], weight=limits_weight[0], group=group), code=301) info['show_switch'] = True db = getDBConnection()['modularforms2']['webmodformspace_dimension'] table = {} q = db.find_one({'group': 'gamma{0}'.format(group)}) if q: table = q.get('data', {}) if table != {}: table = json.loads(table) info['table'] = {} level_range = range(limits_level[0], limits_level[1] + 1) # we don't have weight 1 in database if limits_weight[0] == 1: limits_weight = (2, limits_weight[1]) weight_range = range(limits_weight[0], limits_weight[1] + 1) #print "levels=",level_range #print "weights=",weight_range if len(weight_range) > 1: info['weight_range'] = "{0}-{1}".format(limits_weight[0], limits_weight[1]) if len(level_range) > 1: info['level_range'] = "{0}-{1}".format(limits_level[0], limits_level[1]) if group == 0: weight_range = filter(is_even, weight_range) for n in level_range: info['table'][n] = {} sn = unicode(n) for k in weight_range: info['table'][n][k] = {} sk = unicode(k) if table.has_key(sn): if table[sn].has_key(sk): info['table'][n][k] = table[sn][ sk] #.get(str(n),{}).get(str(k),"n/a") else: emf_logger.debug("Set table for Gamma1") for n in level_range: info['table'][n] = {} for k in weight_range: info['table'][n][k] = table.get(str(n), {}).get(str(k), {}).get( str(-1), "n/a") #print "table=\n",table #print "info=\n",info #info['table']=table info['col_heads'] = level_range info['row_heads'] = weight_range return render_template("emf_browse_spaces.html", info=info, title=title, bread=bread)
def group_alias_table(): C = base.getDBConnection() return aliastable(C)
def get_users(): return base.getDBConnection().userdb.users
def db_dimstats(): return getDBConnection().bmfs.dimensions.stats
def set_info_for_web_newform(level=None, weight=None, character=None, label=None, **kwds): r""" Set the info for on modular form. """ info = to_dict(kwds) info['level'] = level info['weight'] = weight info['character'] = character info['label'] = label if level is None or weight is None or character is None or label is None: s = "In set info for one form but do not have enough args!" s += "level={0},weight={1},character={2},label={3}".format( level, weight, character, label) emf_logger.critical(s) emf_logger.debug("In set_info_for_one_mf: info={0}".format(info)) prec = my_get(info, 'prec', default_prec, int) bprec = my_get(info, 'bprec', default_display_bprec, int) emf_logger.debug("PREC: {0}".format(prec)) emf_logger.debug("BITPREC: {0}".format(bprec)) try: WNF = WebNewForm_cached(level=level, weight=weight, character=character, label=label, prec=prec) emf_logger.debug("defined webnewform for rendering!") except IndexError as e: WNF = None info['error'] = e.message url1 = url_for("emf.render_elliptic_modular_forms") url2 = url_for("emf.render_elliptic_modular_forms", level=level) url3 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight) url4 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight, character=character) bread = [(EMF_TOP, url1)] bread.append(("Level %s" % level, url2)) bread.append(("Weight %s" % weight, url3)) if int(character) == 0: bread.append(("Trivial Character", url4)) else: bread.append(("Character \( %s \)" % (WNF.character.latex_name), url4)) bread.append( ("Newform %d.%d.%d.%s" % (level, weight, int(character), label), '')) info['bread'] = bread properties2 = list() friends = list() space_url = url_for('emf.render_elliptic_modular_forms', level=level, weight=weight, character=character) friends.append( ('\( S_{%s}(%s, %s)\)' % (WNF.weight, WNF.level, WNF.character.latex_name), space_url)) if hasattr(WNF.base_ring, "lmfdb_url") and WNF.base_ring.lmfdb_url: friends.append(('Number field ' + WNF.base_ring.lmfdb_pretty, WNF.base_ring.lmfdb_url)) if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_label: friends.append(('Number field ' + WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_url)) friends = uniq(friends) friends.append(("Dirichlet character \(" + WNF.character.latex_name + "\)", WNF.character.url())) if WNF.dimension == 0: info['error'] = "This space is empty!" info['title'] = 'Newform ' + WNF.hecke_orbit_label info['learnmore'] = [('History of Modular forms', url_for('holomorphic_mf_history'))] if 'error' in info: return info ## Until we have figured out how to do the embeddings correctly we don't display the Satake ## parameters for non-trivial characters.... ## Example to illustrate the different cases ## base = CyclotomicField(n) -- of degree phi(n) ## coefficient_field = NumberField( p(x)) for some p in base['x'] of degree m ## we would then have cdeg = m*phi(n) and bdeg = phi(n) ## and rdeg = m ## Unfortunately, for e.g. base = coefficient_field = CyclotomicField(6) ## we get coefficient_field.relative_degree() == 2 although it should be 1 cdeg = WNF.coefficient_field.absolute_degree() bdeg = WNF.base_ring.absolute_degree() if cdeg == 1: rdeg = 1 else: ## just setting rdeg = WNF.coefficient_field.relative_degree() does not give correct result... ## rdeg = QQ(cdeg) / QQ(bdeg) cf_is_QQ = (cdeg == 1) br_is_QQ = (bdeg == 1) if cf_is_QQ: info['satake'] = WNF.satake if WNF.complexity_of_first_nonvanishing_coefficients( ) > default_max_height: info['qexp'] = "" info['qexp_display'] = '' info['hide_qexp'] = True n, c = WNF.first_nonvanishing_coefficient() info['trace_nv'] = latex(c.trace()) info['norm_nv'] = '\\approx ' + latex(c.norm().n()) info['index_nv'] = n else: info['qexp'] = WNF.q_expansion_latex(prec=10, name='\\alpha ') info['qexp_display'] = url_for(".get_qexp_latex", level=level, weight=weight, character=character, label=label) info["hide_qexp"] = False info['max_cn_qexp'] = WNF.q_expansion.prec() ## All combinations should be tested... ## 13/4/4/a -> base ring = coefficient_field = QQ(zeta_6) ## 13/3/8/a -> base_ring = QQ(zeta_4), coefficient_field has poly x^2+(2\zeta_4+2x-3\zeta_$ over base_ring ## 13/4/3/a -> base_ring = coefficient_field = QQ(zeta_3) ## 13/4/1/a -> all rational ## 13/6/1/a/ -> base_ring = QQ, coefficient_field = Q(sqrt(17)) ## These are variables which needs to be set properly below info['polvars'] = {'base_ring': 'x', 'coefficient_field': '\\alpha'} if not cf_is_QQ: if rdeg > 1: # not WNF.coefficient_field == WNF.base_ring: ## Here WNF.base_ring should be some cyclotomic field and we have an extension over this. p1 = WNF.coefficient_field.relative_polynomial() c_pol_ltx = web_latex_poly(p1, '\\alpha') # make the variable \alpha c_pol_ltx_x = web_latex_poly(p1, 'x') zeta = p1.base_ring().gens()[0] # p2 = zeta.minpoly() #this is not used anymore # b_pol_ltx = web_latex_poly(p2, latex(zeta)) #this is not used anymore z1 = zeta.multiplicative_order() info['coeff_field'] = [ WNF.coefficient_field.absolute_polynomial_latex('x'), c_pol_ltx_x, z1 ] if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_url: info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_label ] if z1 == 4: info[ 'polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\) and \(\zeta_4=i\).</div><br/>'.format( c_pol_ltx) info['polvars']['base_ring'] = 'i' elif z1 <= 2: info[ 'polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\).</div><br/>'.format( c_pol_ltx) else: info[ 'polynomial_st'] = '<div class="where">where</div> %s\(\mathstrut=0\) and \(\zeta_{%s}=e^{\\frac{2\\pi i}{%s}}\) ' % ( c_pol_ltx, z1, z1) info['polvars']['base_ring'] = '\zeta_{{ {0} }}'.format(z1) if z1 == 3: info[ 'polynomial_st'] += 'is a primitive cube root of unity.' else: info[ 'polynomial_st'] += 'is a primitive {0}-th root of unity.'.format( z1) elif not br_is_QQ: ## Now we have base and coefficient field being equal, meaning that since the coefficient field is not QQ it is some cyclotomic field ## generated by some \zeta_n p1 = WNF.coefficient_field.absolute_polynomial() z1 = WNF.coefficient_field.gens()[0].multiplicative_order() c_pol_ltx = web_latex_poly(p1, '\\zeta_{{{0}}}'.format(z1)) c_pol_ltx_x = web_latex_poly(p1, 'x') info['coeff_field'] = [ WNF.coefficient_field.absolute_polynomial_latex('x'), c_pol_ltx_x ] if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_url: info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_label ] if z1 == 4: info[ 'polynomial_st'] = '<div class="where">where \(\zeta_4=e^{{\\frac{{\\pi i}}{{ 2 }} }}=i \).</div>'.format( c_pol_ltx) info['polvars']['coefficient_field'] = 'i' elif z1 <= 2: info['polynomial_st'] = '' else: info[ 'polynomial_st'] = '<div class="where">where \(\zeta_{{{0}}}=e^{{\\frac{{2\\pi i}}{{ {0} }} }}\) '.format( z1) info['polvars']['coefficient_field'] = '\zeta_{{{0}}}'.format( z1) if z1 == 3: info[ 'polynomial_st'] += 'is a primitive cube root of unity.</div>' else: info[ 'polynomial_st'] += 'is a primitive {0}-th root of unity.</div>'.format( z1) else: info['polynomial_st'] = '' if info["hide_qexp"]: info['polynomial_st'] = '' info['degree'] = int(cdeg) if cdeg == 1: info['is_rational'] = 1 info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty ] else: info['is_rational'] = 0 emf_logger.debug("PREC2: {0}".format(prec)) info['embeddings'] = WNF._embeddings[ 'values'] #q_expansion_embeddings(prec, bprec,format='latex') info['embeddings_len'] = len(info['embeddings']) properties2 = [('Level', str(level)), ('Weight', str(weight)), ('Character', '$' + WNF.character.latex_name + '$'), ('Label', WNF.hecke_orbit_label), ('Dimension of Galois orbit', str(WNF.dimension))] if (ZZ(level)).is_squarefree(): info['twist_info'] = WNF.twist_info if isinstance(info['twist_info'], list) and len(info['twist_info']) > 0: info['is_minimal'] = info['twist_info'][0] if (info['twist_info'][0]): s = 'Is minimal<br>' else: s = 'Is a twist of lower level<br>' properties2 += [('Twist info', s)] else: info['twist_info'] = 'Twist info currently not available.' properties2 += [('Twist info', 'not available')] args = list() for x in range(5, 200, 10): args.append({'digits': x}) alev = None CM = WNF._cm_values if CM is not None: if CM.has_key('tau') and len(CM['tau']) != 0: info['CM_values'] = CM info['is_cm'] = WNF.is_cm if WNF.is_cm == 1: info['cm_field'] = "2.0.{0}.1".format(-WNF.cm_disc) info['cm_disc'] = WNF.cm_disc info['cm_field_knowl'] = nf_display_knowl( info['cm_field'], getDBConnection(), field_pretty(info['cm_field'])) info['cm_field_url'] = url_for("number_fields.by_label", label=info["cm_field"]) if WNF.is_cm is None or WNF.is_cm == -1: s = '- Unknown (insufficient data)<br>' elif WNF.is_cm == 1: s = 'Yes<br>' else: s = 'No<br>' properties2.append(('CM', s)) alev = WNF.atkin_lehner_eigenvalues() info['atkinlehner'] = None if isinstance(alev, dict) and len(alev.keys()) > 0 and level != 1: s1 = " Atkin-Lehner eigenvalues " s2 = "" for Q in alev.keys(): s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q]) properties2.append((s1, s2)) emf_logger.debug("properties={0}".format(properties2)) # alev = WNF.atkin_lehner_eigenvalues_for_all_cusps() # if isinstance(alev,dict) and len(alev.keys())>0: # emf_logger.debug("alev={0}".format(alev)) # info['atkinlehner'] = list() # for Q in alev.keys(): # s = "\(" + latex(c) + "\)" # Q = alev[c][0] # ev = alev[c][1] # info['atkinlehner'].append([Q, c, ev]) if (level == 1): poly = WNF.explicit_formulas.get('as_polynomial_in_E4_and_E6', '') if poly != '': d, monom, coeffs = poly emf_logger.critical("poly={0}".format(poly)) info['explicit_formulas'] = '\(' for i in range(len(coeffs)): c = QQ(coeffs[i]) s = "" if d > 1 and i > 0 and c > 0: s = "+" if c < 0: s = "-" if c.denominator() > 1: cc = "\\frac{{ {0} }}{{ {1} }}".format( abs(c.numerator()), c.denominator()) else: cc = str(abs(c)) s += "{0} \cdot ".format(cc) a = monom[i][0] b = monom[i][1] if a == 0 and b != 0: s += "E_6^{{ {0} }}".format(b) elif b == 0 and a != 0: s += "E_4^{{ {0} }}".format(a) else: s += "E_4^{{ {0} }}E_6^{{ {1} }}".format(a, b) info['explicit_formulas'] += s info['explicit_formulas'] += " \)" cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + \ '&label=' + str(label) if len(WNF.parent.hecke_orbits) > 1: for label_other in WNF.parent.hecke_orbits.keys(): if (label_other != label): s = 'Modular form ' if character: s += newform_label(level, weight, character, label_other) else: s += newform_label(level, weight, 1, label_other) url = url_for('emf.render_elliptic_modular_forms', level=level, weight=weight, character=character, label=label_other) friends.append((s, url)) s = 'L-Function ' if character: s += newform_label(level, weight, character, label) else: s += newform_label(level, weight, 1, label) # url = # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s" # %(level,weight,character,label,0) url = '/L' + url_for('emf.render_elliptic_modular_forms', level=level, weight=weight, character=character, label=label) if WNF.coefficient_field_degree > 1: for h in range(WNF.coefficient_field_degree): s0 = s + ".{0}".format(h) url0 = url + "{0}/".format(h) friends.append((s0, url0)) else: friends.append((s, url)) # if there is an elliptic curve over Q associated to self we also list that if WNF.weight == 2 and WNF.coefficient_field_degree == 1: llabel = str(level) + '.' + label s = 'Elliptic curve isogeny class ' + llabel url = '/EllipticCurve/Q/' + llabel friends.append((s, url)) info['properties2'] = properties2 info['friends'] = friends info['max_cn'] = WNF.max_available_prec() return info
def db_nf_fields(): return getDBConnection().numberfields.fields
def render_passport(args): info = {} if 'passport_label' in args: label = clean_input(args['passport_label']) C = base.getDBConnection() dataz = C.curve_automorphisms.passports.find({'passport_label': label}) if dataz.count() is 0: bread = get_bread([("Search error", url_for('.search'))]) flash_error( "No refined passport with label %s was found in the database.", label) return redirect(url_for(".index")) data = dataz[0] g = data['genus'] GG = ast.literal_eval(data['group']) gn = GG[0] gt = GG[1] gp_string = str(gn) + '.' + str(gt) pretty_group = sg_pretty(gp_string) if gp_string == pretty_group: spname = False else: spname = True numb = dataz.count() title = 'One refined passport of genus ' + str( g) + ' with automorphism group $' + pretty_group + '$' smallgroup = "[" + str(gn) + "," + str(gt) + "]" prop2 = [ ('Genus', '\(%d\)' % g), ('Small Group', '\(%s\)' % pretty_group), ('Signature', '\(%s\)' % sign_display(ast.literal_eval(data['signature']))), ('Generating Vectors', '\(%d\)' % numb) ] info.update({ 'genus': data['genus'], 'cc': cc_display(data['con']), 'sign': sign_display(ast.literal_eval(data['signature'])), 'group': pretty_group, 'gpid': smallgroup }) if spname: info.update({'specialname': True}) Ldata = [] HypColumn = False Lfriends = [] for dat in dataz: x1 = dat['total_label'] if 'full_auto' in dat: x2 = 'No' if dat['full_label'] not in Lfriends: Lfriends.append(dat['full_label']) else: x2 = 'Yes' if 'hyperelliptic' in dat: x3 = tfTOyn(dat['hyperelliptic']) HypColumn = True else: x3 = ' ' x4 = [] for perm in dat['gen_vectors']: cycperm = Permutation(perm).cycle_string() x4.append(sep.join(split_perm(cycperm))) Ldata.append([x1, x2, x3, x4]) info.update({'genvects': Ldata, 'HypColumn': HypColumn}) info.update({'passport_cc': cc_display(ast.literal_eval(data['con']))}) if 'eqn' in data: info.update({'eqns': data['eqn']}) other_data = False if 'hyperelliptic' in data: info.update({'ishyp': tfTOyn(data['hyperelliptic'])}) other_data = True if 'hyp_involution' in data: inv = Permutation(data['hyp_involution']).cycle_string() info.update({'hypinv': sep.join(split_perm(inv))}) if 'cyclic_trigonal' in data: info.update({'iscyctrig': tfTOyn(data['cyclic_trigonal'])}) other_data = True if 'cinv' in data: cinv = Permutation(data['cinv']).cycle_string() info.update({'cinv': sep.join(split_perm(cinv))}) info.update({'other_data': other_data}) if 'full_auto' in data: full_G = ast.literal_eval(data['full_auto']) full_gn = full_G[0] full_gt = full_G[1] full_gp_string = str(full_gn) + '.' + str(full_gt) full_pretty_group = sg_pretty(full_gp_string) info.update({ 'fullauto': full_pretty_group, 'signH': sign_display(ast.literal_eval(data['signH'])), 'higgenlabel': data['full_label'] }) urlstrng, br_g, br_gp, br_sign, refined_p = split_passport_label(label) if Lfriends: for Lf in Lfriends: friends = [("Full automorphism " + Lf, Lf), ("Family containing this refined passport ", urlstrng)] else: friends = [("Family containing this refined passport", urlstrng)] bread_sign = label_to_breadcrumbs(br_sign) bread_gp = label_to_breadcrumbs(br_gp) bread = get_bread([(br_g, './?genus=' + br_g), ('$' + pretty_group + '$', './?genus=' + br_g + '&group=' + bread_gp), (bread_sign, urlstrng), (data['cc'][0], ' ')]) learnmore = [('Completeness of the data', url_for(".completeness_page")), ('Source of the data', url_for(".how_computed_page")), ('Labeling convention', url_for(".labels_page"))] downloads = [('Download Magma code', url_for(".hgcwa_code_download", label=label, download_type='magma')), ('Download Gap code', url_for(".hgcwa_code_download", label=label, download_type='gap'))] return render_template("hgcwa-show-passport.html", title=title, bread=bread, info=info, properties2=prop2, friends=friends, learnmore=learnmore, downloads=downloads)
def db_ecnf(): return getDBConnection().elliptic_curves.nfcurves
def hgcwa_code(**args): import time label = args['label'] C = base.getDBConnection() lang = args['download_type'] code = "%s %s code for the lmfdb family of higher genus curves %s\n" % ( Comment[lang], Fullname[lang], label) code += "%s The results are stored in a list of records called 'result_record'\n\n" % ( Comment[lang]) code += code_list['top_matter'][lang] + '\n' + '\n' code += "result_record:=[];" + '\n' + '\n' if label_is_one_passport(label): data = C.curve_automorphisms.passports.find({"passport_label": label}) elif label_is_one_family(label): data = C.curve_automorphisms.passports.find({"label": label}) code += Comment[lang] + code_list['gp_comment'][lang] + '\n' code += code_list['group'][lang] + str(data[0]['group']) + ';\n' if lang == 'magma': code += code_list['group_construct'][lang] + '\n' for k in same_for_all: code += code_list[k][lang] + str(data[0][k]) + ';\n' for k in other_same_for_all: code += code_list[k][lang] + '\n' code += '\n' # create formatting templates to be filled in with each record in data startstr = Comment[lang] + ' Here we add an action to result_record.\n' stdfmt = '' for k in depends_on_action: stdfmt += code_list[k][lang] + '{' + k + '}' + ';\n' if lang == 'magma': stdfmt += code_list['con'][lang] + '{con}' + ';\n' stdfmt += code_list['gen_gp'][lang] + '\n' stdfmt += code_list['passport_label'][lang] + '{cc[0]}' + ';\n' stdfmt += code_list['gen_vect_label'][lang] + '{cc[1]}' + ';\n' # extended formatting template for when signH is present signHfmt = stdfmt signHfmt += code_list['full_auto'][lang] + '{full_auto}' + ';\n' signHfmt += code_list['full_sign'][lang] + '{signH}' + ';\n' signHfmt += code_list['add_to_total_full'][lang] + '\n' # additional info for hyperelliptic cases hypfmt = code_list['hyp'][lang] + code_list['tr'][lang] + ';\n' hypfmt += code_list['hyp_inv'][lang] + '{hyp_involution}' + code_list[ 'hyp_inv_last'][lang] hypfmt += code_list['cyc'][lang] + code_list['fal'][lang] + ';\n' hypfmt += code_list['add_to_total_hyp'][lang] + '\n' cyctrigfmt = code_list['hyp'][lang] + code_list['fal'][lang] + ';\n' cyctrigfmt += code_list['cyc'][lang] + code_list['tr'][lang] + ';\n' cyctrigfmt += code_list['cyc_auto'][lang] + '{cinv}' + code_list[ 'hyp_inv_last'][lang] cyctrigfmt += code_list['add_to_total_cyc_trig'][lang] + '\n' nhypcycstr = code_list['hyp'][lang] + code_list['fal'][lang] + ';\n' nhypcycstr += code_list['cyc'][lang] + code_list['fal'][lang] + ';\n' nhypcycstr += code_list['add_to_total_basic'][lang] + '\n' start = time.time() lines = [(startstr + (signHfmt if 'signH' in dataz else stdfmt).format(**dataz) + ((hypfmt.format( **dataz) if dataz['hyperelliptic'] else cyctrigfmt.format( **dataz) if dataz['cyclic_trigonal'] else nhypcycstr) if 'hyperelliptic' in dataz else '')) for dataz in data] code += '\n'.join(lines) print "%s seconds for %d bytes" % (time.time() - start, len(code)) return code
def render_elliptic_modular_form_navigation_wp(**args): r""" Renders the webpage for the navigational page. """ from sage.all import is_even from lmfdb.modular_forms.elliptic_modular_forms import WebModFormSpace dimension_table_name = WebModFormSpace._dimension_table_name info = to_dict(args) args = to_dict(request.args) info.update(args) form = to_dict(request.form) info.update(form) emf_logger.debug("render_c_m_f_n_wp info={0}".format(info)) level = my_get(info, 'level', None, int) weight = my_get(info, 'weight', None, int) # character = my_get(info, 'character', 1, int) # not used # label = info.get('label', '') # not used if('plot' in info and isinstance(level,int) and level > 0): return render_fd_plot(level, info) is_set = dict() is_set['weight'] = False is_set['level'] = False limits_weight = extract_limits_as_tuple(info, 'weight') limits_level = extract_limits_as_tuple(info, 'level') title = "Holomorphic Cusp Forms" bread = [(MF_TOP, url_for('mf.modular_form_main_page')), (EMF_TOP, url_for('.render_elliptic_modular_forms'))] if isinstance(level,int) and level > 0: is_set['level'] = True level = int(level) bread.append(('Level %d'%level, url_for('emf.render_elliptic_modular_forms', level=level))) title += " of level %d"%level else: level = None info.pop('level',None) if isinstance(weight,int) and weight > 0: is_set['weight'] = True weight = int(weight) bread.append(('Weight %d'%weight, url_for('emf.render_elliptic_modular_forms', level=level, weight=weight))) title += " of weight %d"%weight else: weight = None info.pop('weight',None) ## This is the list of weights we initially put on the form if is_set['weight']: limits_weight = (weight, weight) elif limits_weight is None: limits_weight = (2, 12) # default values # we don't have weight 1 in database, reset range here to exclude it if limits_weight[0]==1: limits_weight=(2,limits_weight[1]) if is_set['level']: limits_level = (level, level) elif limits_level is None: limits_level = (1, 24) # default values try: group = info.get('group',0) # default group is gamma_0 group = int(group) except ValueError: group = 0 if group not in [0,1]: group = 0 if group == 0: info['grouptype'] = 0; info['groupother'] = 1 else: info['grouptype'] = 1; info['groupother'] = 0 # Special case: if the range reduces to a singleton for both level # and weight then we return a single page rather than a table: if limits_weight[0] == limits_weight[1] and limits_level[0] == limits_level[1]: return redirect(url_for("emf.render_elliptic_modular_forms", level=limits_level[0],weight=limits_weight[0],group=group), code=301) info['show_switch'] = True db_dim = getDBConnection()['modularforms2'][dimension_table_name] s = {'level':{"$lt":int(limits_level[1]+1),"$gt":int(limits_level[0]-1)}, 'weight' : {"$lt":int(limits_weight[1]+1),"$gt":int(limits_weight[0]-1)}} if group == 0: s['cchi']=int(1) else: s['gamma1_label']={"$exists":True} info['table'] = {} level_range = range(limits_level[0],limits_level[1]+1) weight_range = range(limits_weight[0],limits_weight[1]+1) if group == 0: weight_range = filter(is_even,weight_range) if len(weight_range)>1: info['weight_range']="{0}-{1}".format(limits_weight[0],limits_weight[1]) elif len(weight_range)==1: info['weight_range']="{0}".format(limits_weight[0]) if len(level_range)>1: info['level_range']="{0}-{1}".format(limits_level[0],limits_level[1]) if len(level_range)==1: info['level_range']="{0}".format(limits_level[0]) for n in level_range: info['table'][n]={} for k in weight_range: info['table'][n][k]={'dim_new':int(0), 'in_db':-1} for r in db_dim.find(s): N = r['level'] k = r['weight'] if group != 0 or k%2==0: #emf_logger.debug("Found:k={0},N={1}".format(k,N)) dim = r['d_newf'] # dimension of newforms info['table'][N][k]['dim_new'] = dim if group == 0: indb = r['in_wdb'] # 1 if it is in the webmodforms db else 0 else: indb = r.get('one_in_wdb',0) # 1 if it is in the webmodforms db else 0 if dim == 0: indb = 1 info['table'][N][k]['in_db'] = indb info['col_heads'] = level_range info['row_heads'] = weight_range lm = [('History of modular forms', url_for(".holomorphic_mf_history"))] return render_template("emf_browse_spaces.html", info=info, title=title, bread=bread, learnmore=lm)
def render_family(args): info = {} if 'label' in args: label = clean_input(args['label']) C = base.getDBConnection() dataz = C.curve_automorphisms.passports.find({'label': label}) if dataz.count() is 0: flash_error("No family with label %s was found in the database.", label) return redirect(url_for(".index")) data = dataz[0] g = data['genus'] GG = ast.literal_eval(data['group']) gn = GG[0] gt = GG[1] gp_string = str(gn) + '.' + str(gt) pretty_group = sg_pretty(gp_string) if gp_string == pretty_group: spname = False else: spname = True title = 'Family of genus ' + str( g) + ' curves with automorphism group $' + pretty_group + '$' smallgroup = "[" + str(gn) + "," + str(gt) + "]" prop2 = [('Genus', '\(%d\)' % g), ('Group', '\(%s\)' % pretty_group), ('Signature', '\(%s\)' % sign_display(ast.literal_eval(data['signature']))) ] info.update({ 'genus': data['genus'], 'sign': sign_display(ast.literal_eval(data['signature'])), 'group': pretty_group, 'g0': data['g0'], 'dim': data['dim'], 'r': data['r'], 'gpid': smallgroup }) if spname: info.update({'specialname': True}) Lcc = [] Lall = [] i = 1 for dat in dataz: if ast.literal_eval(dat['con']) not in Lcc: urlstrng = dat['passport_label'] Lcc.append(ast.literal_eval(dat['con'])) Lall.append([ cc_display(ast.literal_eval(dat['con'])), dat['passport_label'], urlstrng ]) i = i + 1 info.update({'passport': Lall}) g2List = [ '[2,1]', '[4,2]', '[8,3]', '[10,2]', '[12,4]', '[24,8]', '[48,29]' ] if g == 2 and data['group'] in g2List: g2url = "/Genus2Curve/Q/?geom_aut_grp_id=" + data['group'] friends = [("Genus 2 curves over $\Q$", g2url)] else: friends = [] br_g, br_gp, br_sign = split_family_label(label) bread_sign = label_to_breadcrumbs(br_sign) bread_gp = label_to_breadcrumbs(br_gp) bread = get_bread([(br_g, './?genus=' + br_g), ('$' + pretty_group + '$', './?genus=' + br_g + '&group=' + bread_gp), (bread_sign, ' ')]) learnmore = [('Completeness of the data', url_for(".completeness_page")), ('Source of the data', url_for(".how_computed_page")), ('Labeling convention', url_for(".labels_page"))] downloads = [('Download Magma code', url_for(".hgcwa_code_download", label=label, download_type='magma')), ('Download Gap code', url_for(".hgcwa_code_download", label=label, download_type='gap'))] return render_template("hgcwa-show-family.html", title=title, bread=bread, info=info, properties2=prop2, friends=friends, learnmore=learnmore, downloads=downloads)
# -*- coding: utf-8 -*- import os import sage from sage.repl import preparse from sage.interfaces.magma import magma from sage.all import PolynomialRing, Rationals from lmfdb.base import getDBConnection print "getting connection" C = getDBConnection() C['admin'].authenticate('lmfdb', 'lmfdb') # read-only import yaml pw_dict = yaml.load( open( os.path.join(os.getcwd(), os.extsep, os.extsep, os.extsep, "passwords.yaml"))) username = pw_dict['data']['username'] password = pw_dict['data']['password'] C['hmfs'].authenticate(username, password) hmf_forms = C.hmfs.forms hmf_fields = C.hmfs.fields C['admin'].authenticate('lmfdb', 'lmfdb') # read-only fields = C.numberfields.fields # hmf_forms.create_index('field_label') # hmf_forms.create_index('level_norm') # hmf_forms.create_index('level_ideal') # hmf_forms.create_index('dimension') magma.eval(
def elliptic_curve_search(info): if info.get('download') == '1' and info.get('Submit') and info.get( 'query'): return download_search(info) if not 'query' in info: info['query'] = {} bread = info.get('bread', [('Elliptic Curves', url_for(".index")), ('Search Results', '.')]) if 'jump' in info: label = info.get('label', '').replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label.strip()) except ValueError: info['err'] = '' return search_input_error(info, bread) return redirect( url_for(".show_ecnf", nf=nf, conductor_label=cond_label, class_label=iso_label, number=number), 301) query = {} if 'jinv' in info: if info.get('field', '').strip() == '2.2.5.1': info['jinv'] = info['jinv'].replace('phi', 'a') if info.get('field', '').strip() == '2.0.4.1': info['jinv'] = info['jinv'].replace('i', 'a') try: parse_ints(info, query, 'conductor_norm') parse_noop(info, query, 'conductor_label') parse_nf_string(info, query, 'field', name="base number field", qfield='field_label') parse_nf_elt(info, query, 'jinv', name='j-invariant') parse_ints(info, query, 'torsion', name='Torsion order', qfield='torsion_order') parse_bracketed_posints(info, query, 'torsion_structure', maxlength=2) if 'torsion_structure' in query and not 'torsion_order' in query: query['torsion_order'] = reduce( mul, [int(n) for n in query['torsion_structure']], 1) parse_ints(info, query, field='isodeg', qfield='isogeny_degrees') except (TypeError, ValueError): return search_input_error(info, bread) if query.get('jinv'): query['jinv'] = ','.join(query['jinv']) if query.get('field_label') == '1.1.1.1': return redirect(url_for("ec.rational_elliptic_curves", **request.args), 301) if 'include_isogenous' in info and info['include_isogenous'] == 'off': info['number'] = 1 query['number'] = 1 if 'include_base_change' in info and info['include_base_change'] == 'off': query['base_change'] = [] else: info['include_base_change'] = "on" if 'include_Q_curves' in info: if info['include_Q_curves'] == 'exclude': query['q_curve'] = False elif info['include_Q_curves'] == 'only': query['q_curve'] = True if 'include_cm' in info: if info['include_cm'] == 'exclude': query['cm'] = 0 elif info['include_cm'] == 'only': query['cm'] = {'$ne': 0} info['query'] = query count = parse_count(info, 50) start = parse_start(info) # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if (start >= nres): start -= (1 + (start - nres) / count) * count if (start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_nlabel', ASC), ('number', ASC)]).skip(start).limit(count) res = list(res) for e in res: e['numb'] = str(e['number']) e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), field_pretty(e['field_label'])) info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % ( start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = info.get('title', 'Elliptic Curve search results') return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def db_latstats(): return getDBConnection().Lattices.lat.stats
def random_passport(): C = base.getDBConnection() label = random_value_from_collection(C.curve_automorphisms.passports, 'passport_label') return redirect(url_for(".by_passport_label", passport_label=label))