def rep_galois_modl_search(info, query): for field, name in (('dim','Dimension'), ('det','Determinant'), ('level',None), ('minimum','Minimal vector length'), ('class_number',None), ('aut','Group order')): parse_ints(info, query, field, name) # Check if length of gram is triangular gram = info.get('gram') if gram and not (9 + 8*ZZ(gram.count(','))).is_square(): flash(Markup("Error: <span style='color:black'>%s</span> is not a valid input for Gram matrix. It must be a list of integer vectors of triangular length, such as [1,2,3]." % (gram)),"error") raise ValueError parse_list(info, query, 'gram', process=vect_to_sym)
def higher_genus_w_automorphisms_search(**args): info = to_dict(args) bread = get_bread([("Search results", url_for('.search'))]) C = base.getDBConnection() query = {} if 'jump_to' in info: return render_hgcwa_webpage({'label': info['jump_to']}) try: parse_list(info,query,'group', name='Group') parse_ints(info,query,'genus',name='Genus') parse_list(info,query,'signature',name='Signature') 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 except ValueError: return search_input_error(info, bread) count = parse_count(info) start = parse_start(info) res = C.curve_automorphisms.families.find(query).sort([( 'g', pymongo.ASCENDING), ('dim', 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['fields'] = res info['number'] = nres info['group_display'] = group_display_shortC(C) 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="Higher Genus Curves with Automorphisms Search Result", bread=bread, credit=HGCwA_credit)
def lattice_search(**args): info = to_dict(args) # what has been entered in the search boxes if 'download' in info: return download_search(info) if 'label' in info and info.get('label'): return lattice_by_label_or_name(info.get('label')) query = {} try: for field, name in (('dim','Dimension'),('det','Determinant'),('level',None), ('minimum','Minimal vector length'), ('class_number',None), ('aut','Group order')): parse_ints(info, query, field, name) # Check if length of gram is triangular gram = info.get('gram') if gram and not (9 + 8*ZZ(gram.count(','))).is_square(): flash(Markup("Error: <span style='color:black'>%s</span> is not a valid input for Gram matrix. It must be a list of integer vectors of triangular length, such as [1,2,3]." % (gram)),"error") raise ValueError parse_list(info, query, 'gram', process=vect_to_sym) except ValueError as err: info['err'] = str(err) return search_input_error(info) count = parse_count(info,50) start = parse_start(info) info['query'] = dict(query) res = lattice_db().find(query).sort([('dim', ASC), ('det', ASC), ('level', ASC), ('class_number', ASC), ('label', ASC), ('minimum', ASC), ('aut', ASC)]).skip(start).limit(count) nres = res.count() # here we are checking for isometric lattices if the user enters a valid gram matrix but not one stored in the database_names, this may become slow in the future: at the moment we compare against list of stored matrices with same dimension and determinant (just compare with respect to dimension is slow) if nres==0 and info.get('gram'): A=query['gram']; n=len(A[0]) d=matrix(A).determinant() result=[B for B in lattice_db().find({'dim': int(n), 'det' : int(d)}) if isom(A, B['gram'])] if len(result)>0: result=result[0]['gram'] query_gram={ 'gram' : result } query.update(query_gram) res = lattice_db().find(query) nres = res.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 info['number'] = nres info['start'] = int(start) info['more'] = int(start + count < nres) if nres == 1: info['report'] = 'unique match' else: if nres == 0: info['report'] = 'no matches' 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 res_clean = [] for v in res: v_clean = {} v_clean['label']=v['label'] v_clean['dim']=v['dim'] v_clean['det']=v['det'] v_clean['level']=v['level'] v_clean['class_number']=v['class_number'] v_clean['min']=v['minimum'] v_clean['aut']=v['aut'] res_clean.append(v_clean) info['lattices'] = res_clean t = 'Integral Lattices Search Results' bread = [('Lattices', url_for(".lattice_render_webpage")),('Search Results', ' ')] properties = [] return render_template("lattice-search.html", info=info, title=t, properties=properties, bread=bread, learnmore=learnmore_list())
def rep_galois_modl_search(**args): C = getDBConnection() info = to_dict(args) # what has been entered in the search boxes if 'download' in info: return download_search(info) if 'label' in info and info.get('label'): return rep_galois_modl_by_label_or_name(info.get('label'), C) query = {} try: for field, name in (('dim','Dimension'),('det','Determinant'),('level',None), ('minimum','Minimal vector length'), ('class_number',None), ('aut','Group order')): parse_ints(info, query, field, name) # Check if length of gram is triangular gram = info.get('gram') if gram and not (9 + 8*ZZ(gram.count(','))).is_square(): flash(Markup("Error: <span style='color:black'>%s</span> is not a valid input for Gram matrix. It must be a list of integer vectors of triangular length, such as [1,2,3]." % (gram)),"error") raise ValueError parse_list(info, query, 'gram', process=vect_to_sym) except ValueError as err: info['err'] = str(err) return search_input_error(info) count = parse_count(info,50) start = parse_start(info) info['query'] = dict(query) res = C.mod_l_galois.reps.find(query).sort([('dim', ASC), ('det', ASC), ('level', ASC), ('class_number', ASC), ('label', ASC)]).skip(start).limit(count) nres = res.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 info['number'] = nres info['start'] = int(start) info['more'] = int(start + count < nres) if nres == 1: info['report'] = 'unique match' else: if nres == 0: info['report'] = 'no matches' 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 res_clean = [] for v in res: v_clean = {} v_clean['label']=v['label'] v_clean['dim']=v['dim'] v_clean['det']=v['det'] v_clean['level']=v['level'] v_clean['gram']=vect_to_matrix(v['gram']) res_clean.append(v_clean) info['rep_galois_modls'] = res_clean t = 'Mod ℓ Galois representations Search Results' bread = [('Representations', "/Representation"),("mod ℓ", url_for(".index")), ('Search Results', ' ')] properties = [] return render_template("rep_galois_modl-search.html", info=info, title=t, properties=properties, bread=bread, learnmore=learnmore_list())
def rep_galois_modl_search(**args): C = getDBConnection() info = to_dict(args) # what has been entered in the search boxes if 'download' in info: return download_search(info) if 'label' in info and info.get('label'): return rep_galois_modl_by_label_or_name(info.get('label'), C) query = {} try: for field, name in (('dim', 'Dimension'), ('det', 'Determinant'), ('level', None), ('minimum', 'Minimal vector length'), ('class_number', None), ('aut', 'Group order')): parse_ints(info, query, field, name) # Check if length of gram is triangular gram = info.get('gram') if gram and not (9 + 8 * ZZ(gram.count(','))).is_square(): flash( Markup( "Error: <span style='color:black'>%s</span> is not a valid input for Gram matrix. It must be a list of integer vectors of triangular length, such as [1,2,3]." % (gram)), "error") raise ValueError parse_list(info, query, 'gram', process=vect_to_sym) except ValueError as err: info['err'] = str(err) return search_input_error(info) count = parse_count(info, 50) start = parse_start(info) info['query'] = dict(query) res = C.mod_l_galois.reps.find(query).sort([('dim', ASC), ('det', ASC), ('level', ASC), ('class_number', ASC), ('label', ASC) ]).skip(start).limit(count) nres = res.count() if (start >= nres): start -= (1 + (start - nres) / count) * count if (start < 0): start = 0 info['number'] = nres info['start'] = int(start) info['more'] = int(start + count < nres) if nres == 1: info['report'] = 'unique match' else: if nres == 0: info['report'] = 'no matches' 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 res_clean = [] for v in res: v_clean = {} v_clean['label'] = v['label'] v_clean['dim'] = v['dim'] v_clean['det'] = v['det'] v_clean['level'] = v['level'] v_clean['gram'] = vect_to_matrix(v['gram']) res_clean.append(v_clean) info['rep_galois_modls'] = res_clean t = 'Mod ℓ Galois representations Search Results' bread = [('Representations', "/Representation"), ("mod ℓ", url_for(".index")), ('Search Results', ' ')] properties = [] return render_template("rep_galois_modl-search.html", info=info, title=t, properties=properties, bread=bread, learnmore=learnmore_list())
def lattice_search(**args): C = getDBConnection() C.Lattices.lat.ensure_index([('dim', ASC), ('label', ASC)]) info = to_dict(args) # what has been entered in the search boxes if 'label' in info: lab = info.get('label') control = by_label_or_name(lab, C) if control == "ok": args = {'label': lab} return render_lattice_webpage(**args) else: check = lattice_label_error(control, lab, url_for(".lattice_render_webpage")) if check is not None: return check query = {} for field in [ 'dim', 'det', 'level', 'gram', 'minimum', 'class_number', 'aut' ]: if info.get(field): if field in [ 'dim', 'det', 'level', 'minimum', 'class_number', 'aut' ]: try: info['start'] check = parse_ints(info.get(field), query, field) except: check = parse_ints(info.get(field), query, field, url_for(".lattice_render_webpage")) if check is not None: return check elif field == 'gram': try: info['start'] check = parse_list(info.get(field), query, field, vect_to_sym) except: check = parse_list(info.get(field), query, field, vect_to_sym, url_for(".lattice_render_webpage")) if check is not None: return check info['query'] = dict(query) res = C.Lattices.lat.find(query).sort([('level', ASC), ('label', ASC)]) 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['label'] = v['label'] v_clean['dim'] = v['dim'] v_clean['det'] = v['det'] v_clean['level'] = v['level'] v_clean['gram'] = vect_to_matrix(v['gram']) res_clean.append(v_clean) info['lattices'] = res_clean t = 'Integral Lattices search results' bread = [('Lattices', url_for(".lattice_render_webpage")), ('Search results', ' ')] properties = [] return render_template("lattice-search.html", info=info, title=t, properties=properties, bread=bread)
def lattice_search(**args): C = getDBConnection() C.Lattices.lat.ensure_index([('dim', ASC), ('label', ASC)]) info = to_dict(args) # what has been entered in the search boxes if 'label' in info: lab = info.get('label') control= by_label_or_name(lab, C) if control == "ok": args = {'label': lab } return render_lattice_webpage(**args) else: check=lattice_label_error(control, lab , url_for(".lattice_render_webpage")) if check is not None: return check query = {} for field in ['dim','det','level', 'gram', 'minimum', 'class_number', 'aut']: if info.get(field): if field in ['dim', 'det', 'level', 'minimum', 'class_number', 'aut']: try: info['start'] check= parse_ints(info.get(field), query, field) except: check= parse_ints(info.get(field), query, field, url_for(".lattice_render_webpage")) if check is not None: return check elif field == 'gram': try: info['start'] check= parse_list(info.get(field), query, field, vect_to_sym) except: check= parse_list(info.get(field), query, field, vect_to_sym, url_for(".lattice_render_webpage")) if check is not None: return check info['query'] = dict(query) res = C.Lattices.lat.find(query).sort([('dim', ASC), ('det', ASC), ('label', ASC)]) 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['label']=v['label'] v_clean['dim']=v['dim'] v_clean['det']=v['det'] v_clean['level']=v['level'] v_clean['gram']=vect_to_matrix(v['gram']) res_clean.append(v_clean) info['lattices'] = res_clean t = 'Integral Lattices search results' bread = [('Lattices', url_for(".lattice_render_webpage")),('Search results', ' ')] properties = [] return render_template("lattice-search.html", info=info, title=t, properties=properties, bread=bread)
def rep_galois_modl_search(**args): C = getDBConnection() info = to_dict(args) # what has been entered in the search boxes if "download" in info: return download_search(info) if "label" in info and info.get("label"): return rep_galois_modl_by_label_or_name(info.get("label"), C) query = {} try: for field, name in ( ("dim", "Dimension"), ("det", "Determinant"), ("level", None), ("minimum", "Minimal vector length"), ("class_number", None), ("aut", "Group order"), ): parse_ints(info, query, field, name) # Check if length of gram is triangular gram = info.get("gram") if gram and not (9 + 8 * ZZ(gram.count(","))).is_square(): flash( Markup( "Error: <span style='color:black'>%s</span> is not a valid input for Gram matrix. It must be a list of integer vectors of triangular length, such as [1,2,3]." % (gram) ), "error", ) raise ValueError parse_list(info, query, "gram", process=vect_to_sym) except ValueError as err: info["err"] = str(err) return search_input_error(info) count = parse_count(info, 50) start = parse_start(info) info["query"] = dict(query) res = ( C.mod_l_galois.reps.find(query) .sort([("dim", ASC), ("det", ASC), ("level", ASC), ("class_number", ASC), ("label", ASC)]) .skip(start) .limit(count) ) nres = res.count() if start >= nres: start -= (1 + (start - nres) / count) * count if start < 0: start = 0 info["number"] = nres info["start"] = int(start) info["more"] = int(start + count < nres) if nres == 1: info["report"] = "unique match" else: if nres == 0: info["report"] = "no matches" 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 res_clean = [] for v in res: v_clean = {} v_clean["label"] = v["label"] v_clean["dim"] = v["dim"] v_clean["det"] = v["det"] v_clean["level"] = v["level"] v_clean["gram"] = vect_to_matrix(v["gram"]) res_clean.append(v_clean) info["rep_galois_modls"] = res_clean t = "Mod ℓ Galois representations Search Results" bread = [("Representations", "/Representation"), ("mod ℓ", url_for(".index")), ("Search Results", " ")] properties = [] return render_template( "rep_galois_modl-search.html", info=info, title=t, properties=properties, bread=bread, learnmore=learnmore_list(), )