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())
s += download_assignment_end[lang] s += '\n' strIO = StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False) @search_wrap(template="rep_galois_modl-search.html", table=db.modlgal_reps, title='Mod ℓ Galois representations Search Results', err_title='Mod ℓ Galois representations Search Results Error', per_page=50, shortcuts={'download':download_search, 'label':lambda info:rep_galois_modl_by_label_or_name(info.get('label'))}, projection=['label','dim','det','level','gram'], cleaners={'gram':lambda v:vect_to_matrix(v['gram'])}, bread=lambda:[('Representations', "/Representation"),("mod ℓ", url_for(".index")), ('Search Results', ' ')], properties=lambda:[], learnmore=learnmore_list) 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_error("%s 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) raise ValueError parse_list(info, query, 'gram', process=vect_to_sym)
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) @search_wrap(template="rep_galois_modl-search.html", table=db.modlgal_reps, title='Mod ℓ Galois representations Search Results', err_title='Mod ℓ Galois representations Search Results Error', per_page=50, shortcuts={'download':download_search, 'label':lambda info:rep_galois_modl_by_label_or_name(info.get('label'))}, projection=['label','dim','det','level','gram'], cleaners={'gram':lambda v:vect_to_matrix(v['gram'])}, bread=lambda:[('Representations', "/Representation"),("mod ℓ", url_for(".index")), ('Search Results', ' ')], properties=lambda:[], learnmore=learnmore_list) 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)