示例#1
0
    def make_class(self):
        curves_data = db_g2c().curves.find({"class" : self.label}).sort([("disc_key", pymongo.ASCENDING), ("label", pymongo.ASCENDING)])
        self.curves = [ {"label" : c['label'], "equation_formatted" : list_to_min_eqn(c['min_eqn']), "url": url_for_label(c['label'])} for c in curves_data ]
        self.ncurves = curves_data.count()
        self.bad_lfactors = [ [c[0], list_to_factored_poly_otherorder(c[1])] for c in self.bad_lfactors]
        for endalgtype in ['end_alg', 'rat_end_alg', 'real_end_alg', 'geom_end_alg', 'rat_geom_end_alg', 'real_geom_end_alg']:
            if hasattr(self, endalgtype):
                setattr(self,endalgtype + '_name',end_alg_name(getattr(self,endalgtype)))
            else:
                setattr(self,endalgtype + '_name','')

        self.st_group_name = st_group_name(self.st_group)

        if hasattr(self, 'geom_end_field') and self.geom_end_field <> '':
            self.geom_end_field_name = field_pretty(self.geom_end_field)
        else:
            self.geom_end_field_name = ''

        if self.is_gl2_type:
            self.is_gl2_type_name = 'yes'
        else:
            self.is_gl2_type_name = 'no'
        if hasattr(self, 'is_simple'):
            if self.is_simple:
                self.is_simple_name = 'yes'
            else:
                self.is_simple_name = 'no'
        else:
            self.is_simple_name = '?'
        if hasattr(self, 'is_geom_simple'):
            if self.is_geom_simple:
                self.is_geom_simple_name = 'yes'
            else:
                self.is_geom_simple_name = 'no'
        else:
            self.is_geom_simple_name = '?'

        x = self.label.split('.')[1]
        
        self.friends = [
          ('L-function', url_for("l_functions.l_function_genus2_page", cond=self.cond,x=x)),
          ('Siegel modular form someday', '.')]

        self.ecproduct_wurl = []
        if hasattr(self, 'ecproduct'):
            for i in range(2):
                curve_label = self.ecproduct[i]
                crv_url = url_for("ec.by_ec_label", label=curve_label)
                if i == 1 or len(set(self.ecproduct)) <> 1:
                    self.friends.append(('Elliptic curve ' + curve_label, crv_url))
                self.ecproduct_wurl.append({'label' : curve_label, 'url' : crv_url})

        self.ecquadratic_wurl = []
        if hasattr(self, 'ecquadratic'):
            for i in range(len(self.ecquadratic)):
                curve_label = self.ecquadratic[i]
                crv_spl = curve_label.split('-')
                crv_url = url_for("ecnf.show_ecnf_isoclass", nf = crv_spl[0], conductor_label = crv_spl[1], class_label = crv_spl[2])
                self.friends.append(('Elliptic curve ' + curve_label, crv_url))
                self.ecquadratic_wurl.append({'label' : curve_label, 'url' : crv_url, 'nf' : crv_spl[0]})

        if hasattr(self, 'mfproduct'):
            for i in range(len(self.mfproduct)):
                mf_label = self.mfproduct[i]
                mf_spl = mf_label.split('.')
                mf_spl.append(mf_spl[2][-1])
                mf_spl[2] = mf_spl[2][:-1] # Need a splitting function
                mf_url = url_for("emf.render_elliptic_modular_forms", level=mf_spl[0], weight=mf_spl[1], character=mf_spl[2], label=mf_spl[3])
                self.friends.append(('Modular form ' + mf_label, mf_url))

        if hasattr(self, 'mfhilbert'):
            for i in range(len(self.mfhilbert)):
                mf_label = self.mfhilbert[i]
                mf_spl = mf_label.split('-')
                mf_url = url_for("hmf.render_hmf_webpage", field_label=mf_spl[0], label=mf_label)
                self.friends.append(('Hilbert modular form ' + mf_label, mf_url))

        self.properties = [('Label', self.label),
                           ('Number of curves', str(self.ncurves)),
                           ('Conductor','%s' % self.cond),
                           ('Sato-Tate group', '\(%s\)' % self.st_group_name),
                           ('\(\mathrm{End}(J_{\overline{\Q}}) \otimes \R\)','\(%s\)' % self.real_geom_end_alg_name),
                           ('\(\mathrm{GL}_2\)-type','%s' % self.is_gl2_type_name)]

        self.title = "Genus 2 Isogeny Class %s" % (self.label)
        self.downloads = [
                          ('Download Euler factors', ".")] # url_for(".download_g2c_eulerfactors", label=self.label)),
#                          ('Download stored data for all curves', url_for(".download_g2c_all", label=self.label))]
        
        self.bread = [
                       ('Genus 2 Curves', url_for(".index")),
                       ('$\Q$', url_for(".index_Q")),
                       ('%s' % self.cond, url_for(".by_conductor", conductor=self.cond)),
                       ('%s' % self.label, ' ')
                     ]
示例#2
0
文件: main.py 项目: koffie/lmfdb
    data_description = 'defining the hyperelliptic curve y^2+h(x)y=f(x).'
    function_body = {'magma':['R<x>:=PolynomialRing(Rationals());',
                              'return [HyperellipticCurve(R!r[1],R!r[2]):r in data];'],
                     'sage':['R.<x>=PolynomialRing(QQ)',
                             'return [HyperellipticCurve(R(r[0]),R(r[1])) for r in data]'],
                     'gp':['[apply(Polrev,c)|c<-data];']}

@search_wrap(template="g2c_search_results.html",
             table=db.g2c_curves,
             title='Genus 2 Curve Search Results',
             err_title='Genus 2 Curves Search Input Error',
             shortcuts={'jump':genus2_jump,
                        'download':G2C_download()},
             projection=['label','eqn','st_group','is_gl2_type','is_simple_geom','analytic_rank'],
             cleaners={"class": lambda v: class_from_curve_label(v["label"]),
                       "equation_formatted": lambda v: list_to_min_eqn(literal_eval(v.pop("eqn"))),
                       "st_group_link": lambda v: st_link_by_name(1,4,v.pop('st_group'))},
             bread=lambda:[('Genus 2 Curves', url_for(".index")),
                           ('$\Q$', url_for(".index_Q")),
                           ('Search Results', '.')],
             learnmore=learnmore_list,
             credit=lambda:credit_string)
def genus2_curve_search(info, query):
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
示例#3
0
    data_description = 'defining the hyperelliptic curve y^2+h(x)y=f(x).'
    function_body = {'magma':['R<x>:=PolynomialRing(Rationals());',
                              'return [HyperellipticCurve(R![c:c in r[1]],R![c:c in r[2]]):r in data];'],
                     'sage':['R.<x>=PolynomialRing(QQ)',
                             'return [HyperellipticCurve(R(r[0]),R(r[1])) for r in data]'],
                     'gp':['[apply(Polrev,c)|c<-data];']}

@search_wrap(template="g2c_search_results.html",
             table=db.g2c_curves,
             title='Genus 2 Curve Search Results',
             err_title='Genus 2 Curves Search Input Error',
             shortcuts={'jump':genus2_jump,
                        'download':G2C_download()},
             projection=['label','eqn','st_group','is_gl2_type','is_simple_geom','analytic_rank'],
             cleaners={"class": lambda v: class_from_curve_label(v["label"]),
                       "equation_formatted": lambda v: list_to_min_eqn(literal_eval(v.pop("eqn"))),
                       "st_group_link": lambda v: st_link_by_name(1,4,v.pop('st_group'))},
             bread=lambda:[('Genus 2 Curves', url_for(".index")),
                           ('$\Q$', url_for(".index_Q")),
                           ('Search Results', '.')],
             learnmore=learnmore_list,
             credit=lambda:credit_string)
def genus2_curve_search(info, query):
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
示例#4
0
def genus2_curve_search(**args):
    info = to_dict(args)
    
    if 'download' in info and info['download'] == '1':
        return download_search(info)
    
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    query = {}  # database callable
    bread = [('Genus 2 Curves', url_for(".index")),
             ('$\Q$', url_for(".index_Q")),
             ('Search Results', '.')]
    #if 'SearchAgain' in args:
    #    return rational_genus2_curves()

    if 'jump' in args:
        curve_label_regex = re.compile(r'\d+\.[a-z]+.\d+.\d+$')
        if curve_label_regex.match(info["jump"].strip()):
            data = render_curve_webpage_by_label(info["jump"].strip())
        else:
            class_label_regex = re.compile(r'\d+\.[a-z]+$')
            if class_label_regex.match(info["jump"].strip()):
                data = render_isogeny_class(info["jump"].strip())
            else:
                class_label_regex = re.compile(r'#\d+$')
                if class_label_regex.match(info["jump"].strip()) and ZZ(info["jump"][1:]) < 2**61:
                    c = g2cdb().isogeny_classes.find_one({'hash':int(info["jump"][1:])})
                    if c:
                        data = render_isogeny_class(c["label"])
                    else:
                        data = "Hash not found"
                else:
                    data = "Invalid label"
        if isinstance(data,str):
            flash(Markup(data + " <span style='color:black'>%s</span>"%(info["jump"])),"error")
            return redirect(url_for(".index"))
        return data
    try:
        parse_ints(info,query,'abs_disc','absolute discriminant')
        parse_bool(info,query,'is_gl2_type')
        parse_bool(info,query,'has_square_sha')
        parse_bool(info,query,'locally_solvable')
        parse_bracketed_posints(info, query, 'torsion', 'torsion structure', maxlength=4,check_divisibility="increasing")
        parse_ints(info,query,'cond','conductor')
        parse_ints(info,query,'num_rat_wpts','Weierstrass points')
        parse_ints(info,query,'torsion_order')
        parse_ints(info,query,'two_selmer_rank','2-Selmer rank')
        parse_ints(info,query,'analytic_rank','analytic rank')
        # G2 invariants and drop-list items don't require parsing -- they are all strings (supplied by us, not the user)
        if info.get('g20') and info.get('g21') and info.get('g22'):
            query['g2inv'] = [ info['g20'], info['g21'], info['g22'] ]
        for fld in ('st_group', 'real_geom_end_alg', 'aut_grp_id', 'geom_aut_grp_id'):
            if info.get(fld): query[fld] = info[fld]
    except ValueError as err:
        info['err'] = str(err)
        return render_template("search_results_g2.html", info=info, title='Genus 2 Curves Search Input Error', bread=bread, credit=credit_string)
    info["query"] = dict(query)
    count = parse_count(info, 50)
    start = parse_start(info)
    cursor = g2cdb().curves.find(query)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    res = cursor.sort([("cond", pymongo.ASCENDING), ("class", pymongo.ASCENDING),  ("disc_key", pymongo.ASCENDING),  ("label", pymongo.ASCENDING)]).skip(start).limit(count)
    nres = res.count()

    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
    res_clean = []

    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["isog_label"] = v["class"]
        isogeny_class = g2cdb().isogeny_classes.find_one({'label' :
            isog_label(v["label"])})
        v_clean["is_gl2_type"] = isogeny_class["is_gl2_type"]
        if isogeny_class["is_gl2_type"] == True:
            v_clean["is_gl2_type_display"] = '&#10004;' #checkmark
        else:
            v_clean["is_gl2_type_display"] = ''
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        v_clean["st_group_name"] = st_group_name(isogeny_class['st_group'])
        v_clean["st_group_href"] = st_group_href(isogeny_class['st_group'])
        v_clean["analytic_rank"] = v["analytic_rank"]
        res_clean.append(v_clean)

    info["curves"] = res_clean
    info["curve_url"] = lambda dbc: url_for_label(dbc['label'])
    info["isog_url"] = lambda dbc: isog_url_for_label(dbc['label'])
    info["start"] = start
    info["count"] = count
    info["more"] = int(start+count<nres)
    
    credit = credit_string
    title = 'Genus 2 Curves search results'
    return render_template("search_results_g2.html", info=info, credit=credit,learnmore=learnmore_list(), bread=bread, title=title)
示例#5
0
文件: main.py 项目: AurelPage/lmfdb
def genus2_curve_search(info):
    if 'jump' in info:
        jump = info["jump"].strip()
        if re.match(r'^\d+\.[a-z]+\.\d+\.\d+$',jump):
            return redirect(url_for_curve_label(jump), 301)
        else:
            if re.match(r'^\d+\.[a-z]+$', jump):
                return redirect(url_for_isogeny_class_label(jump), 301)
            else:
                # Handle direct Lhash input
                if re.match(r'^\#\d+$',jump) and ZZ(jump[1:]) < 2**61:
                    c = g2c_db_curves().find_one({'Lhash': jump[1:].strip()})
                    if c:
                        return redirect(url_for_isogeny_class_label(c["class"]), 301)
                    else:
                        errmsg = "hash %s not found"
                else:
                    errmsg = "%s is not a valid genus 2 curve or isogeny class label"
        flash_error (errmsg, jump)
        return redirect(url_for(".index"))

    if info.get('download','').strip() == '1':
        return download_search(info)

    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    bread = info.get('bread',(('Genus 2 Curves', url_for(".index")), ('$\Q$', url_for(".index_Q")), ('Search Results', '.')))

    query = {}
    try:
        parse_ints(info,query,'abs_disc','absolute discriminant')
        parse_bool(info,query,'is_gl2_type','is of GL2-type')
        parse_bool(info,query,'has_square_sha','has square Sha')
        parse_bool(info,query,'locally_solvable','is locally solvable')
        parse_bool(info,query,'is_simple_geom','is geometrically simple')
        parse_ints(info,query,'cond','conductor')
        parse_ints(info,query,'num_rat_wpts','rational Weierstrass points')
        parse_bracketed_posints(info, query, 'torsion', 'torsion structure', maxlength=4,check_divisibility="increasing")
        parse_ints(info,query,'torsion_order','torsion order')
        if 'torsion' in query and not 'torsion_order' in query:
            query['torsion_order'] = reduce(mul,[int(n) for n in query['torsion']],1)
        if 'torsion' in query:
            query['torsion_subgroup'] = str(query['torsion']).replace(" ","")
            query.pop('torsion') # search using string key, not array of ints
        parse_ints(info,query,'two_selmer_rank','2-Selmer rank')
        parse_ints(info,query,'analytic_rank','analytic rank')
        # G2 invariants and drop-list items don't require parsing -- they are all strings (supplied by us, not the user)
        if 'g20' in info and 'g21' in info and 'g22' in info:
            query['g2_inv'] = "['%s','%s','%s']"%(info['g20'], info['g21'], info['g22'])
        if 'class' in info:
            query['class'] = info['class']
        for fld in ('st_group', 'real_geom_end_alg', 'aut_grp_id', 'geom_aut_grp_id'):
            if info.get(fld): query[fld] = info[fld]
    except ValueError as err:
        info['err'] = str(err)
        return render_template("g2c_search_results.html", info=info, title='Genus 2 Curves Search Input Error', bread=bread, credit=credit_string)
    # Database query happens here
    info["query"] = query # save query for reuse in download_search
    cursor = g2c_db_curves().find(query, {'_id':False, 'label':True, 'eqn':True, 'st_group':True, 'is_gl2_type':True, 'is_simple_geom':True, 'analytic_rank':True})

    count = parse_count(info, 50)
    start = parse_start(info)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    res = cursor.sort([("cond", ASCENDING), ("class", ASCENDING),  ("disc_key", ASCENDING),  ("label", ASCENDING)]).skip(start).limit(count)
    nres = res.count()

    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
    res_clean = []

    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["class"] = class_from_curve_label(v["label"])
        v_clean["is_gl2_type"] = v["is_gl2_type"] 
        v_clean["is_simple_geom"] = v["is_simple_geom"] 
        v_clean["equation_formatted"] = list_to_min_eqn(literal_eval(v["eqn"]))
        v_clean["st_group_link"] = st_link_by_name(1,4,v['st_group'])
        v_clean["analytic_rank"] = v["analytic_rank"]
        res_clean.append(v_clean)

    info["curves"] = res_clean
    info["curve_url"] = lambda label: url_for_curve_label(label)
    info["class_url"] = lambda label: url_for_isogeny_class_label(label)
    info["start"] = start
    info["count"] = count
    info["more"] = int(start+count<nres)
    
    title = info.get('title','Genus 2 Curve search results')
    credit = credit_string
    
    return render_template("g2c_search_results.html", info=info, credit=credit,learnmore=learnmore_list(), bread=bread, title=title)
示例#6
0
def genus2_curve_search(**args):
    info = to_dict(args['data'])
    if 'jump' in info:
        jump = info["jump"].strip()
        curve_label_regex = re.compile(r'\d+\.[a-z]+.\d+.\d+$')
        if curve_label_regex.match(jump):
            return redirect(url_for_curve_label(jump), 301)
        else:
            class_label_regex = re.compile(r'\d+\.[a-z]+$')
            if class_label_regex.match(jump):
                return redirect(url_for_isogeny_class_label(jump), 301)
            else:
                # Handle direct Lhash input
                class_label_regex = re.compile(r'#\d+$')
                if class_label_regex.match(jump) and ZZ(jump[1:]) < 2**61:
                    c = g2cdb().isogeny_classes.find_one({'Lhash': jump[1:].strip()})
                    if c:
                        return redirect(url_for_isogeny_class_label(c["label"]), 301)
                    else:
                        errmsg = "Hash not found"
                else:
                    errmsg = "Invalid label"
        flash(Markup(errmsg + " <span style='color:black'>%s</span>"%(jump)),"error")
        return redirect(url_for(".index"))

    if 'download' in info and info['download'] == '1':
        return download_search(info)
    
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    bread = info.get('bread',(('Genus 2 Curves', url_for(".index")), ('$\Q$', url_for(".index_Q")), ('Search Results', '.')))

    query = {}
    try:
        parse_ints(info,query,'abs_disc','absolute discriminant')
        parse_bool(info,query,'is_gl2_type')
        parse_bool(info,query,'has_square_sha')
        parse_bool(info,query,'locally_solvable')
        parse_bool(info,query,'is_simple_geom')
        parse_bracketed_posints(info, query, 'torsion', 'torsion structure', maxlength=4,check_divisibility="increasing")
        parse_ints(info,query,'cond')
        parse_ints(info,query,'num_rat_wpts','Weierstrass points')
        parse_ints(info,query,'torsion_order')
        if 'torsion' in query and not 'torsion_order' in query:
            query['torsion_order'] = reduce(mul,[int(n) for n in query['torsion']],1)
        parse_ints(info,query,'two_selmer_rank','2-Selmer rank')
        parse_ints(info,query,'analytic_rank','analytic rank')
        # G2 invariants and drop-list items don't require parsing -- they are all strings (supplied by us, not the user)
        if 'g20' in info and 'g21' in info and 'g22' in info:
            query['g2inv'] = [ info['g20'], info['g21'], info['g22'] ]
        if 'class' in info:
            query['class'] = info['class']
        for fld in ('st_group', 'real_geom_end_alg', 'aut_grp_id', 'geom_aut_grp_id'):
            if info.get(fld): query[fld] = info[fld]
    except ValueError as err:
        info['err'] = str(err)
        return render_template("search_results_g2.html", info=info, title='Genus 2 Curves Search Input Error', bread=bread, credit=credit_string)
    info["query"] = dict(query)
    
    # Database query happens here
    cursor = g2cdb().curves.find(query,{'_id':int(0),'label':int(1),'min_eqn':int(1),'st_group':int(1),'is_gl2_type':int(1),'analytic_rank':int(1)})

    count = parse_count(info, 50)
    start = parse_start(info)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    res = cursor.sort([("cond", ASCENDING), ("class", ASCENDING),  ("disc_key", ASCENDING),  ("label", ASCENDING)]).skip(start).limit(count)
    nres = res.count()

    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
    res_clean = []

    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["class"] = class_from_curve_label(v["label"])
        v_clean["is_gl2_type"] = v["is_gl2_type"] 
        v_clean["is_gl2_type_display"] = '&#10004;' if v["is_gl2_type"] else '' # display checkmark if true, blank otherwise
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        v_clean["st_group_name"] = st_group_name(v['st_group'])
        v_clean["st_group_href"] = st_group_href(v['st_group'])
        v_clean["analytic_rank"] = v["analytic_rank"]
        res_clean.append(v_clean)

    info["curves"] = res_clean
    info["curve_url"] = lambda label: url_for_curve_label(label)
    info["class_url"] = lambda label: url_for_isogeny_class_label(label)
    info["start"] = start
    info["count"] = count
    info["more"] = int(start+count<nres)
    
    title = info.get('title','Genus 2 Curve search results')
    credit = credit_string
    
    return render_template("search_results_g2.html", info=info, credit=credit,learnmore=learnmore_list(), bread=bread, title=title)
示例#7
0
def genus2_curve_search(**args):
    info = to_dict(args)
    query = {}  # database callable
    bread = [('Genus 2 Curves', url_for(".index")),
             ('$\Q$', url_for(".index_Q")),
             ('Search Results', '.')]
    #if 'SearchAgain' in args:
    #    return rational_genus2_curves()

    if 'jump' in args:
        return render_curve_webpage_by_label(info["jump"])

    if info.get("disc"):
        field = "abs_disc"
        ran = info["disc"]
        ran = ran.replace('..', '-').replace(' ','')
        # Past input check
        dlist = parse_discs(ran)
        tmp = g2_list_to_query(dlist)

        if len(tmp) == 1:
            tmp = tmp[0]
        else:
            query[tmp[0][0]] = tmp[0][1]
            tmp = tmp[1]

        print tmp

        # work around syntax for $or
        # we have to foil out multiple or conditions
        if tmp[0] == '$or' and '$or' in query:
            newors = []
            for y in tmp[1]:
                oldors = [dict.copy(x) for x in query['$or']]
                for x in oldors:
                    x.update(y)
                newors.extend(oldors)
            tmp[1] = newors
        query[tmp[0]] = tmp[1]
        
    if info.get("is_gl2_type"):
       query['is_gl2_type']=bool(info['is_gl2_type'])    

    for fld in ['aut_grp', 'geom_aut_grp','st_group','real_geom_end_alg']:
        if info.get(fld):
            query[fld] = info[fld]
    for fld in ['aut_grp', 'geom_aut_grp']:
        if info.get(fld):
            query[fld] = eval(info[fld])

    if info.get("cond"):
        field = "cond"
        ran = str(info[field])
        ran = ran.replace('..', '-').replace(' ','')
        # Past input check
        tmp = parse_range2(ran, field)

        print tmp

        # work around syntax for $or
        # we have to foil out multiple or conditions
        if tmp[0] == '$or' and '$or' in query:
            newors = []
            for y in tmp[1]:
                oldors = [dict.copy(x) for x in query['$or']]
                for x in oldors:
                    x.update(y)
                newors.extend(oldors)
            tmp[1] = newors
        query[tmp[0]] = tmp[1]


    if info.get("count"):
        try:
            count = int(info["count"])
        except:
            count = 100
    else:
        count = 100

    info["query"] = dict(query)
    #res = db_g2c().curves.find(query).sort([("cond", pymongo.ASCENDING),
    #("label", pymongo.ASCENDING)]).limit(count)
    res = db_g2c().curves.find(query).sort([("cond", pymongo.ASCENDING),
                                            ("class", pymongo.ASCENDING),
                                            ("disc_key", pymongo.ASCENDING),
                                            ("label", pymongo.ASCENDING)])
    nres = res.count()
    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["isog_label"] = v["class"]
        isogeny_class = db_g2c().isogeny_classes.find_one({'label' : isog_label(v["label"])})
        v_clean["is_gl2_type"] = isogeny_class["is_gl2_type"]
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        res_clean.append(v_clean)

    info["curves"] = res_clean

    info["curve_url"] = lambda dbc: url_for_label(dbc['label'])
    info["isog_url"] = lambda dbc: isog_url_for_label(dbc['label'])
    credit = 'Genus 2 Team'
    title = 'Genus 2 Curves search results'
    return render_template("search_results_g2.html", info=info, credit=credit, bread=bread, title=title)
示例#8
0
def genus2_curve_search(**args):
    info = to_dict(args['data'])
    if 'jump' in info:
        jump = info["jump"].strip()
        curve_label_regex = re.compile(r'\d+\.[a-z]+.\d+.\d+$')
        if curve_label_regex.match(jump):
            return redirect(url_for_curve_label(jump), 301)
        else:
            class_label_regex = re.compile(r'\d+\.[a-z]+$')
            if class_label_regex.match(jump):
                return redirect(url_for_isogeny_class_label(jump), 301)
            else:
                # Handle direct Lhash input
                class_label_regex = re.compile(r'#\d+$')
                if class_label_regex.match(jump) and ZZ(jump[1:]) < 2**61:
                    c = g2cdb().isogeny_classes.find_one(
                        {'Lhash': jump[1:].strip()})
                    if c:
                        return redirect(
                            url_for_isogeny_class_label(c["label"]), 301)
                    else:
                        errmsg = "Hash not found"
                else:
                    errmsg = "Invalid label"
        flash(Markup(errmsg + " <span style='color:black'>%s</span>" % (jump)),
              "error")
        return redirect(url_for(".index"))

    if 'download' in info and info['download'] == '1':
        return download_search(info)

    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    bread = info.get('bread',
                     (('Genus 2 Curves', url_for(".index")),
                      ('$\Q$', url_for(".index_Q")), ('Search Results', '.')))

    query = {}
    try:
        parse_ints(info, query, 'abs_disc', 'absolute discriminant')
        parse_bool(info, query, 'is_gl2_type')
        parse_bool(info, query, 'has_square_sha')
        parse_bool(info, query, 'locally_solvable')
        parse_bool(info, query, 'is_simple_geom')
        parse_bracketed_posints(info,
                                query,
                                'torsion',
                                'torsion structure',
                                maxlength=4,
                                check_divisibility="increasing")
        parse_ints(info, query, 'cond')
        parse_ints(info, query, 'num_rat_wpts', 'Weierstrass points')
        parse_ints(info, query, 'torsion_order')
        if 'torsion' in query and not 'torsion_order' in query:
            query['torsion_order'] = reduce(mul,
                                            [int(n) for n in query['torsion']],
                                            1)
        parse_ints(info, query, 'two_selmer_rank', '2-Selmer rank')
        parse_ints(info, query, 'analytic_rank', 'analytic rank')
        # G2 invariants and drop-list items don't require parsing -- they are all strings (supplied by us, not the user)
        if 'g20' in info and 'g21' in info and 'g22' in info:
            query['g2inv'] = [info['g20'], info['g21'], info['g22']]
        if 'class' in info:
            query['class'] = info['class']
        for fld in ('st_group', 'real_geom_end_alg', 'aut_grp_id',
                    'geom_aut_grp_id'):
            if info.get(fld): query[fld] = info[fld]
    except ValueError as err:
        info['err'] = str(err)
        return render_template("search_results_g2.html",
                               info=info,
                               title='Genus 2 Curves Search Input Error',
                               bread=bread,
                               credit=credit_string)
    info["query"] = dict(query)

    # Database query happens here
    cursor = g2cdb().curves.find(
        query, {
            '_id': int(0),
            'label': int(1),
            'min_eqn': int(1),
            'st_group': int(1),
            'is_gl2_type': int(1),
            'analytic_rank': int(1)
        })

    count = parse_count(info, 50)
    start = parse_start(info)
    nres = cursor.count()
    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0

    res = cursor.sort([("cond", ASCENDING), ("class", ASCENDING),
                       ("disc_key", ASCENDING),
                       ("label", ASCENDING)]).skip(start).limit(count)
    nres = res.count()

    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
    res_clean = []

    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["class"] = class_from_curve_label(v["label"])
        v_clean["is_gl2_type"] = v["is_gl2_type"]
        v_clean["is_gl2_type_display"] = '&#10004;' if v[
            "is_gl2_type"] else ''  # display checkmark if true, blank otherwise
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        v_clean["st_group_name"] = st_group_name(v['st_group'])
        v_clean["st_group_href"] = st_group_href(v['st_group'])
        v_clean["analytic_rank"] = v["analytic_rank"]
        res_clean.append(v_clean)

    info["curves"] = res_clean
    info["curve_url"] = lambda label: url_for_curve_label(label)
    info["class_url"] = lambda label: url_for_isogeny_class_label(label)
    info["start"] = start
    info["count"] = count
    info["more"] = int(start + count < nres)

    title = info.get('title', 'Genus 2 Curve search results')
    credit = credit_string

    return render_template("search_results_g2.html",
                           info=info,
                           credit=credit,
                           learnmore=learnmore_list(),
                           bread=bread,
                           title=title)
示例#9
0
def genus2_curve_search(**args):
    info = to_dict(args)
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_dict"] = real_geom_end_alg_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    query = {}  # database callable
    bread = [('Genus 2 Curves', url_for(".index")),
             ('$\Q$', url_for(".index_Q")),
             ('Search Results', '.')]
    #if 'SearchAgain' in args:
    #    return rational_genus2_curves()

    if 'jump' in args:
        return render_curve_webpage_by_label(info["jump"])

    if info.get("disc"):
        field = "abs_disc"
        ran = info["disc"]
        ran = ran.replace('..', '-').replace(' ','')
        # Past input check
        dlist = parse_discs(ran)
        tmp = g2_list_to_query(dlist)

        if len(tmp) == 1:
            tmp = tmp[0]
        else:
            query[tmp[0][0]] = tmp[0][1]
            tmp = tmp[1]

        # work around syntax for $or
        # we have to foil out multiple or conditions
        if tmp[0] == '$or' and '$or' in query:
            newors = []
            for y in tmp[1]:
                oldors = [dict.copy(x) for x in query['$or']]
                for x in oldors:
                    x.update(y)
                newors.extend(oldors)
            tmp[1] = newors
        query[tmp[0]] = tmp[1]
        
    if info.get("is_gl2_type"):
        if info['is_gl2_type'] == "True":
            query['is_gl2_type']= True
        elif info['is_gl2_type'] == "False":
            query['is_gl2_type']= False

    for fld in ['st_group', 'real_geom_end_alg']:
        if info.get(fld):
            query[fld] = info[fld]
    for fld in ['aut_grp', 'geom_aut_grp','igusa_clebsch']:
        if info.get(fld):
            query[fld] = map(int,info[fld].strip()[1:-1].split(","))
    if info.get('torsion'):
        res = parse_torsion_structure(info['torsion'],4)
        if 'Error' in res:
            # no error handling of malformed input yet!
            info['torsion'] = ''
            #info['err'] = res
            #return search_input_error(info, bread)
        else:
            #update info for repeat searches
            info['torsion'] = str(res).replace(' ','')
            query['torsion'] = [int(r) for r in res]

    if info.get('ic0'):
        query['igusa_clebsch']=[info['ic0'], info['ic1'], info['ic2'], info['ic3'] ]
        

    for fld in ["cond", "num_rat_wpts", "torsion_order", "two_selmer_rank"]:
        if info.get(fld):
            field = fld
            ran = str(info[field])
            ran = ran.replace('..', '-').replace(' ','')
            # Past input check
            tmp = parse_range2(ran, field)
            # work around syntax for $or
            # we have to foil out multiple or conditions
            if tmp[0] == '$or' and '$or' in query:
                newors = []
                for y in tmp[1]:
                    oldors = [dict.copy(x) for x in query['$or']]
                    for x in oldors:
                        x.update(y)
                    newors.extend(oldors)
                tmp[1] = newors
            query[tmp[0]] = tmp[1]

    info["query"] = dict(query)

    count_default = 50
    if info.get('count'):
        try:
            count = int(info['count'])
        except:
            count = count_default
    else:
        count = count_default
    info['count'] = count

    start_default = 0
    if info.get('start'):
        try:
            start = int(info['start'])
            if(start < 0):
                start += (1 - (start + 1) / count) * count
        except:
            start = start_default
    else:
        start = start_default

    cursor = db_g2c().curves.find(query)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    res = cursor.sort([("cond", pymongo.ASCENDING),
                                            ("class", pymongo.ASCENDING),
                                            ("disc_key", pymongo.ASCENDING),
                                            ("label", pymongo.ASCENDING)]).skip(start).limit(count)
    nres = res.count()
    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
    res_clean = []
    
    
    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["isog_label"] = v["class"]
        isogeny_class = db_g2c().isogeny_classes.find_one({'label' : isog_label(v["label"])})
        v_clean["is_gl2_type"] = isogeny_class["is_gl2_type"]
        if isogeny_class["is_gl2_type"] == True:
            v_clean["is_gl2_type_display"] = '&#10004;' #checkmark
        else:
            v_clean["is_gl2_type_display"] = ''
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        v_clean["st_group_name"] = st_group_name(isogeny_class['st_group'])
        res_clean.append(v_clean)

    info["curves"] = res_clean

    info["curve_url"] = lambda dbc: url_for_label(dbc['label'])
    info["isog_url"] = lambda dbc: isog_url_for_label(dbc['label'])
    info["start"] = start
    info["count"] = count
    info["more"] = int(start+count<nres)
    credit = credit_string
    title = 'Genus 2 Curves search results'
    return render_template("search_results_g2.html", info=info, credit=credit, bread=bread, title=title)
示例#10
0
def genus2_curve_search(**args):
    info = to_dict(args)
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_dict"] = real_geom_end_alg_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    query = {}  # database callable
    bread = [('Genus 2 Curves', url_for(".index")),
             ('$\Q$', url_for(".index_Q")),
             ('Search Results', '.')]
    #if 'SearchAgain' in args:
    #    return rational_genus2_curves()

    if 'jump' in args:
        return render_curve_webpage_by_label(info["jump"])

    if info.get("disc"):
        field = "abs_disc"
        ran = info["disc"]
        ran = ran.replace('..', '-').replace(' ','')
        # Past input check
        dlist = parse_discs(ran)
        tmp = g2_list_to_query(dlist)

        if len(tmp) == 1:
            tmp = tmp[0]
        else:
            query[tmp[0][0]] = tmp[0][1]
            tmp = tmp[1]

        # work around syntax for $or
        # we have to foil out multiple or conditions
        if tmp[0] == '$or' and '$or' in query:
            newors = []
            for y in tmp[1]:
                oldors = [dict.copy(x) for x in query['$or']]
                for x in oldors:
                    x.update(y)
                newors.extend(oldors)
            tmp[1] = newors
        query[tmp[0]] = tmp[1]
        
    if info.get("is_gl2_type"):
        if info['is_gl2_type'] == "True":
            query['is_gl2_type']= True
        elif info['is_gl2_type'] == "False":
            query['is_gl2_type']= False

    for fld in ['st_group', 'real_geom_end_alg']:
        if info.get(fld):
            query[fld] = info[fld]
    for fld in ['aut_grp', 'geom_aut_grp','torsion','igusa_clebsch']:
        if info.get(fld):
            query[fld] = map(int,info[fld].strip()[1:-1].split(","))
    if info.get('ic0'):
        query['igusa_clebsch']=[info['ic0'], info['ic1'], info['ic2'], info['ic3'] ]
        

    for fld in ["cond", "num_rat_wpts", "torsion_order", "two_selmer_rank"]:
        if info.get(fld):
            field = fld
            ran = str(info[field])
            ran = ran.replace('..', '-').replace(' ','')
            # Past input check
            tmp = parse_range2(ran, field)
            # work around syntax for $or
            # we have to foil out multiple or conditions
            if tmp[0] == '$or' and '$or' in query:
                newors = []
                for y in tmp[1]:
                    oldors = [dict.copy(x) for x in query['$or']]
                    for x in oldors:
                        x.update(y)
                    newors.extend(oldors)
                tmp[1] = newors
            query[tmp[0]] = tmp[1]

    info["query"] = dict(query)

    count_default = 50
    if info.get('count'):
        try:
            count = int(info['count'])
        except:
            count = count_default
    else:
        count = count_default
    info['count'] = count

    start_default = 0
    if info.get('start'):
        try:
            start = int(info['start'])
            if(start < 0):
                start += (1 - (start + 1) / count) * count
        except:
            start = start_default
    else:
        start = start_default

    cursor = db_g2c().curves.find(query)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    res = cursor.sort([("cond", pymongo.ASCENDING),
                                            ("class", pymongo.ASCENDING),
                                            ("disc_key", pymongo.ASCENDING),
                                            ("label", pymongo.ASCENDING)]).skip(start).limit(count)
    nres = res.count()
    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
    res_clean = []
    
    
    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["isog_label"] = v["class"]
        isogeny_class = db_g2c().isogeny_classes.find_one({'label' : isog_label(v["label"])})
        v_clean["is_gl2_type"] = isogeny_class["is_gl2_type"]
        if isogeny_class["is_gl2_type"] == True:
            v_clean["is_gl2_type_display"] = '&#10004;' #checkmark
        else:
            v_clean["is_gl2_type_display"] = ''
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        v_clean["st_group_name"] = st_group_name(isogeny_class['st_group'])
        res_clean.append(v_clean)

    info["curves"] = res_clean

    info["curve_url"] = lambda dbc: url_for_label(dbc['label'])
    info["isog_url"] = lambda dbc: isog_url_for_label(dbc['label'])
    info["start"] = start
    info["count"] = count
    info["more"] = int(start+count<nres)
    credit = credit_string
    title = 'Genus 2 Curves search results'
    return render_template("search_results_g2.html", info=info, credit=credit, bread=bread, title=title)
示例#11
0
def genus2_curve_search(**args):
    info = to_dict(args)
    print "info", info
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    query = {}  # database callable
    bread = [('Genus 2 Curves', url_for(".index")),
             ('$\Q$', url_for(".index_Q")),
             ('Search Results', '.')]
    #if 'SearchAgain' in args:
    #    return rational_genus2_curves()

    if 'jump' in args:
        label_regex = re.compile(r'\d+\.[a-z]+.\d+.\d+')
        if label_regex.match(info["jump"].strip()):
            data = render_curve_webpage_by_label(info["jump"].strip())
        else:
            data = "Invalid label"
        print data
        if data == "Invalid label":
            flash(Markup("The label <span style='color:black'>%s</span> is invalid."%(info["jump"])),"error")
            return redirect(url_for(".index"))
        if data == "Data for curve not found":
            flash(Markup("No genus 2 curve with label <span style='color:black'>%s</span> was found in the database."%(info["jump"])),"error")
            return redirect(url_for(".index"))
        return data
    try:
        parse_ints(info,query,'abs_disc','absolute discriminant')
        parse_bool(info,query,'is_gl2_type')
        parse_bool(info,query,'has_square_sha')
        parse_bool(info,query,'locally_solvable')
        for fld in ('st_group', 'real_geom_end_alg'):
            if info.get(fld): query[fld] = info[fld]
        for fld in ('aut_grp', 'geom_aut_grp'):
            #Encoded into a GAP ID.
            parse_bracketed_posints(info,query,fld,exactlength=2)
        # igusa and igusa_clebsch invariants not currently searchable
        parse_bracketed_posints(info, query, 'torsion', 'torsion structure', maxlength=4,check_divisibility="increasing")
        parse_ints(info,query,'cond','conductor')
        parse_ints(info,query,'num_rat_wpts','Weierstrass points')
        parse_ints(info,query,'torsion_order')
        parse_ints(info,query,'two_selmer_rank','2-Selmer rank')
        parse_ints(info,query,'analytic_rank','analytic rank')
    except ValueError as err:
        info['err'] = str(err)
        return render_template("search_results_g2.html", info=info, title='Genus 2 Curves Search Input Error', bread=bread, credit=credit_string)

    info["query"] = dict(query)
    print "query", info["query"]
    print "info", info
    count = parse_count(info, 50)
    start = parse_start(info)
    cursor = db_g2c().curves.find(query)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    res = cursor.sort([("cond", pymongo.ASCENDING),
                       ("class", pymongo.ASCENDING),
                       ("disc_key", pymongo.ASCENDING),
                       ("label", pymongo.ASCENDING)]).skip(start).limit(count)
    nres = res.count()
    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
    res_clean = []

    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["isog_label"] = v["class"]
        isogeny_class = db_g2c().isogeny_classes.find_one({'label' :
            isog_label(v["label"])})
        v_clean["is_gl2_type"] = isogeny_class["is_gl2_type"]
        if isogeny_class["is_gl2_type"] == True:
            v_clean["is_gl2_type_display"] = '&#10004;' #checkmark
        else:
            v_clean["is_gl2_type_display"] = ''
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        v_clean["st_group_name"] = st_group_name(isogeny_class['st_group'])
        v_clean["analytic_rank"] = v["analytic_rank"]
        res_clean.append(v_clean)

    info["curves"] = res_clean

    info["curve_url"] = lambda dbc: url_for_label(dbc['label'])
    info["isog_url"] = lambda dbc: isog_url_for_label(dbc['label'])
    info["start"] = start
    info["count"] = count
    info["more"] = int(start+count<nres)
    credit = credit_string
    title = 'Genus 2 Curves search results'
    return render_template("search_results_g2.html", info=info, credit=credit,learnmore=learnmore_list(),
            bread=bread, title=title)
    credit =  credit_string
    title = 'Genus 2 curves over $\Q$'
    bread = [('Genus 2 Curves', url_for(".index")), ('$\Q$', ' ')]
示例#12
0
             table=db.g2c_curves,
             title='Genus 2 Curve Search Results',
             err_title='Genus 2 Curves Search Input Error',
             shortcuts={
                 'jump': genus2_jump,
                 'download': download_search
             },
             projection=[
                 'label', 'eqn', 'st_group', 'is_gl2_type', 'is_simple_geom',
                 'analytic_rank'
             ],
             cleaners={
                 "class":
                 lambda v: class_from_curve_label(v["label"]),
                 "equation_formatted":
                 lambda v: list_to_min_eqn(literal_eval(v.pop("eqn"))),
                 "st_group_link":
                 lambda v: st_link_by_name(1, 4, v.pop('st_group'))
             },
             bread=lambda: [('Genus 2 Curves', url_for(".index")),
                            ('$\Q$', url_for(".index_Q")),
                            ('Search Results', '.')],
             learnmore=learnmore_list,
             credit=lambda: credit_string)
def genus2_curve_search(info, query):
    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
示例#13
0
def genus2_curve_search(**args):
    info = to_dict(args)

    if 'download' in info and info['download'] == '1':
        return download_search(info)

    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    query = {}  # database callable
    bread = [('Genus 2 Curves', url_for(".index")),
             ('$\Q$', url_for(".index_Q")), ('Search Results', '.')]
    #if 'SearchAgain' in args:
    #    return rational_genus2_curves()

    if 'jump' in args:
        label_regex = re.compile(r'\d+\.[a-z]+.\d+.\d+')
        if label_regex.match(info["jump"].strip()):
            data = render_curve_webpage_by_label(info["jump"].strip())
        else:
            data = "Invalid label"
        if data == "Invalid label":
            flash(
                Markup(
                    "The label <span style='color:black'>%s</span> is invalid."
                    % (info["jump"])), "error")
            return redirect(url_for(".index"))
        if data == "Data for curve not found":
            flash(
                Markup(
                    "No genus 2 curve with label <span style='color:black'>%s</span> was found in the database."
                    % (info["jump"])), "error")
            return redirect(url_for(".index"))
        return data
    try:
        parse_ints(info, query, 'abs_disc', 'absolute discriminant')
        parse_bool(info, query, 'is_gl2_type')
        parse_bool(info, query, 'has_square_sha')
        parse_bool(info, query, 'locally_solvable')
        for fld in ('st_group', 'real_geom_end_alg'):
            if info.get(fld): query[fld] = info[fld]
        for fld in ('aut_grp', 'geom_aut_grp'):
            parse_bracketed_posints(info, query, fld,
                                    exactlength=2)  #Encoded into a GAP ID.
        # igusa and igusa_clebsch invariants not currently searchable
        parse_bracketed_posints(info,
                                query,
                                'torsion',
                                'torsion structure',
                                maxlength=4,
                                check_divisibility="increasing")
        parse_ints(info, query, 'cond', 'conductor')
        parse_ints(info, query, 'num_rat_wpts', 'Weierstrass points')
        parse_ints(info, query, 'torsion_order')
        parse_ints(info, query, 'two_selmer_rank', '2-Selmer rank')
        parse_ints(info, query, 'analytic_rank', 'analytic rank')
    except ValueError as err:
        info['err'] = str(err)
        return render_template("search_results_g2.html",
                               info=info,
                               title='Genus 2 Curves Search Input Error',
                               bread=bread,
                               credit=credit_string)

    info["query"] = dict(query)
    count = parse_count(info, 50)
    start = parse_start(info)
    cursor = db_g2c().curves.find(query)
    nres = cursor.count()
    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0

    res = cursor.sort([("cond", pymongo.ASCENDING),
                       ("class", pymongo.ASCENDING),
                       ("disc_key", pymongo.ASCENDING),
                       ("label", pymongo.ASCENDING)]).skip(start).limit(count)
    nres = res.count()

    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
    res_clean = []

    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["isog_label"] = v["class"]
        isogeny_class = db_g2c().isogeny_classes.find_one(
            {'label': isog_label(v["label"])})
        v_clean["is_gl2_type"] = isogeny_class["is_gl2_type"]
        if isogeny_class["is_gl2_type"] == True:
            v_clean["is_gl2_type_display"] = '&#10004;'  #checkmark
        else:
            v_clean["is_gl2_type_display"] = ''
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        v_clean["st_group_name"] = st_group_name(isogeny_class['st_group'])
        v_clean["analytic_rank"] = v["analytic_rank"]
        res_clean.append(v_clean)

    info["curves"] = res_clean
    info["curve_url"] = lambda dbc: url_for_label(dbc['label'])
    info["isog_url"] = lambda dbc: isog_url_for_label(dbc['label'])
    info["start"] = start
    info["count"] = count
    info["more"] = int(start + count < nres)

    credit = credit_string
    title = 'Genus 2 Curves search results'
    return render_template("search_results_g2.html",
                           info=info,
                           credit=credit,
                           learnmore=learnmore_list(),
                           bread=bread,
                           title=title)
示例#14
0
def genus2_curve_search(info):
    if 'jump' in info:
        jump = info["jump"].strip()
        if re.match(r'^\d+\.[a-z]+\.\d+\.\d+$', jump):
            return redirect(url_for_curve_label(jump), 301)
        else:
            if re.match(r'^\d+\.[a-z]+$', jump):
                return redirect(url_for_isogeny_class_label(jump), 301)
            else:
                # Handle direct Lhash input
                if re.match(r'^\#\d+$', jump) and ZZ(jump[1:]) < 2**61:
                    c = g2c_db_curves().find_one({'Lhash': jump[1:].strip()})
                    if c:
                        return redirect(
                            url_for_isogeny_class_label(c["class"]), 301)
                    else:
                        errmsg = "hash %s not found"
                else:
                    errmsg = "%s is not a valid genus 2 curve or isogeny class label"
        flash_error(errmsg, jump)
        return redirect(url_for(".index"))

    if info.get('download', '').strip() == '1':
        return download_search(info)

    info["st_group_list"] = st_group_list
    info["st_group_dict"] = st_group_dict
    info["real_geom_end_alg_list"] = real_geom_end_alg_list
    info["real_geom_end_alg_to_ST0_dict"] = real_geom_end_alg_to_ST0_dict
    info["aut_grp_list"] = aut_grp_list
    info["aut_grp_dict"] = aut_grp_dict
    info["geom_aut_grp_list"] = geom_aut_grp_list
    info["geom_aut_grp_dict"] = geom_aut_grp_dict
    bread = info.get('bread',
                     (('Genus 2 Curves', url_for(".index")),
                      ('$\Q$', url_for(".index_Q")), ('Search Results', '.')))

    query = {}
    try:
        parse_ints(info, query, 'abs_disc', 'absolute discriminant')
        parse_bool(info, query, 'is_gl2_type', 'is of GL2-type')
        parse_bool(info, query, 'has_square_sha', 'has square Sha')
        parse_bool(info, query, 'locally_solvable', 'is locally solvable')
        parse_bool(info, query, 'is_simple_geom', 'is geometrically simple')
        parse_ints(info, query, 'cond', 'conductor')
        parse_ints(info, query, 'num_rat_wpts', 'rational Weierstrass points')
        parse_bracketed_posints(info,
                                query,
                                'torsion',
                                'torsion structure',
                                maxlength=4,
                                check_divisibility="increasing")
        parse_ints(info, query, 'torsion_order', 'torsion order')
        if 'torsion' in query and not 'torsion_order' in query:
            query['torsion_order'] = reduce(mul,
                                            [int(n) for n in query['torsion']],
                                            1)
        if 'torsion' in query:
            query['torsion_subgroup'] = str(query['torsion']).replace(" ", "")
            query.pop('torsion')  # search using string key, not array of ints
        parse_ints(info, query, 'two_selmer_rank', '2-Selmer rank')
        parse_ints(info, query, 'analytic_rank', 'analytic rank')
        # G2 invariants and drop-list items don't require parsing -- they are all strings (supplied by us, not the user)
        if 'g20' in info and 'g21' in info and 'g22' in info:
            query['g2_inv'] = "['%s','%s','%s']" % (info['g20'], info['g21'],
                                                    info['g22'])
        if 'class' in info:
            query['class'] = info['class']
        for fld in ('st_group', 'real_geom_end_alg', 'aut_grp_id',
                    'geom_aut_grp_id'):
            if info.get(fld): query[fld] = info[fld]
    except ValueError as err:
        info['err'] = str(err)
        return render_template("g2c_search_results.html",
                               info=info,
                               title='Genus 2 Curves Search Input Error',
                               bread=bread,
                               credit=credit_string)
    # Database query happens here
    info["query"] = query  # save query for reuse in download_search
    cursor = g2c_db_curves().find(
        query, {
            '_id': False,
            'label': True,
            'eqn': True,
            'st_group': True,
            'is_gl2_type': True,
            'is_simple_geom': True,
            'analytic_rank': True
        })

    count = parse_count(info, 50)
    start = parse_start(info)
    nres = cursor.count()
    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0

    res = cursor.sort([("cond", ASCENDING), ("class", ASCENDING),
                       ("disc_key", ASCENDING),
                       ("label", ASCENDING)]).skip(start).limit(count)
    nres = res.count()

    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
    res_clean = []

    for v in res:
        v_clean = {}
        v_clean["label"] = v["label"]
        v_clean["class"] = class_from_curve_label(v["label"])
        v_clean["is_gl2_type"] = v["is_gl2_type"]
        v_clean["is_simple_geom"] = v["is_simple_geom"]
        v_clean["equation_formatted"] = list_to_min_eqn(literal_eval(v["eqn"]))
        v_clean["st_group_link"] = st_link_by_name(1, 4, v['st_group'])
        v_clean["analytic_rank"] = v["analytic_rank"]
        res_clean.append(v_clean)

    info["curves"] = res_clean
    info["curve_url"] = lambda label: url_for_curve_label(label)
    info["class_url"] = lambda label: url_for_isogeny_class_label(label)
    info["start"] = start
    info["count"] = count
    info["more"] = int(start + count < nres)

    title = info.get('title', 'Genus 2 Curve search results')
    credit = credit_string

    return render_template("g2c_search_results.html",
                           info=info,
                           credit=credit,
                           learnmore=learnmore_list(),
                           bread=bread,
                           title=title)
示例#15
0
    def make_class(self):
        from lmfdb.genus2_curves.genus2_curve import url_for_curve_label

        # Data
        curves_data = g2cdb().curves.find({"class" : self.label},{'_id':int(0),'label':int(1),'min_eqn':int(1),'disc_key':int(1)}).sort([("disc_key", ASCENDING), ("label", ASCENDING)])
        assert curves_data
        self.curves = [ {"label" : c['label'], "equation_formatted" : list_to_min_eqn(c['min_eqn']),
            "url": url_for_curve_label(c['label'])} for c in curves_data ]
        self.ncurves = curves_data.count()
        self.bad_lfactors = [ [c[0], list_to_factored_poly_otherorder(c[1])]
            for c in self.bad_lfactors]

        # Data derived from Sato-Tate group
        self.st_group_name = st_group_name(self.st_group)
        self.st_group_href = st_group_href(self.st_group)
        self.st0_group_name = st0_group_name(self.real_geom_end_alg)
        # Later used in Lady Gaga box:
        self.real_geom_end_alg_disp = [r'\End(J_{\overline{\Q}}) \otimes \R',
                end_alg_name(self.real_geom_end_alg)]
        if self.is_gl2_type:
            self.is_gl2_type_name = 'yes'
        else:
            self.is_gl2_type_name = 'no'

        # Endomorphism data
        endodata = g2cdb().endomorphisms.find_one({"label" :
            self.curves[0]['label']})
        self.gl2_statement_base = \
            gl2_statement_base(endodata['factorsRR_base'], r'\(\Q\)')
        self.endo_statement_base = \
            """Endomorphism algebra over \(\Q\):<br>""" + \
            endo_statement_isog(endodata['factorsQQ_base'],
                endodata['factorsRR_base'], r'')
        endodata['fod_poly'] = intlist_to_poly(endodata['fod_coeffs'])
        self.fod_statement = fod_statement(endodata['fod_label'],
            endodata['fod_poly'])
        if endodata['fod_label'] != '1.1.1.1':
            self.endo_statement_geom = \
                """Endomorphism algebra over \(\overline{\Q}\):<br>""" + \
                endo_statement_isog(endodata['factorsQQ_geom'],
                    endodata['factorsRR_geom'], r'\overline{\Q}')
        else:
            self.endo_statement_geom = ''

        # Title
        self.title = "Genus 2 Isogeny Class %s" % (self.label)

        # Lady Gaga box
        self.properties = (
                ('Label', self.label),
                ('Number of curves', str(self.ncurves)),
                ('Conductor','%s' % self.cond),
                ('Sato-Tate group', self.st_group_href),
                ('\(%s\)' % self.real_geom_end_alg_disp[0],
                 '\(%s\)' % self.real_geom_end_alg_disp[1]),
                ('\(\mathrm{GL}_2\)-type','%s' % self.is_gl2_type_name)
                )
        x = self.label.split('.')[1]
        self.friends = [('L-function', url_for("l_functions.l_function_genus2_page", cond=self.cond,x=x))]
        #self.downloads = [('Download Euler factors', ".")]
        #self.downloads = [
        #        ('Download Euler factors', "."),
        #            url_for(".download_g2c_eulerfactors", label=self.label)),
        #        ('Download stored data for all curves',
        #            url_for(".download_g2c_all", label=self.label))
        #        ]

        # Breadcrumbs
        self.bread = (
                       ('Genus 2 Curves', url_for(".index")),
                       ('$\Q$', url_for(".index_Q")),
                       ('%s' % self.cond, url_for(".by_conductor", cond=self.cond)),
                       ('%s' % self.label, ' ')
                     )

        # More friends (NOTE: to be improved)
        self.ecproduct_wurl = []
        if hasattr(self, 'ecproduct'):
            for i in range(2):
                curve_label = self.ecproduct[i]
                crv_url = url_for("ec.by_ec_label", label=curve_label)
                if i == 1 or len(set(self.ecproduct)) != 1:
                    self.friends.append(('Elliptic curve ' + curve_label,
                        crv_url))
                self.ecproduct_wurl.append({'label' : curve_label, 'url' :
                    crv_url})

        self.ecquadratic_wurl = []
        if hasattr(self, 'ecquadratic'):
            for i in range(len(self.ecquadratic)):
                curve_label = self.ecquadratic[i]
                crv_spl = curve_label.split('-')
                crv_url = url_for("ecnf.show_ecnf_isoclass", nf = crv_spl[0],
                        conductor_label = crv_spl[1], class_label = crv_spl[2])
                self.friends.append(('Elliptic curve ' + curve_label, crv_url))
                self.ecquadratic_wurl.append({'label' : curve_label, 'url' :
                    crv_url, 'nf' : crv_spl[0]})

        if hasattr(self, 'mfproduct'):
            for i in range(len(self.mfproduct)):
                mf_label = self.mfproduct[i]
                mf_spl = mf_label.split('.')
                mf_spl.append(mf_spl[2][-1])
                mf_spl[2] = mf_spl[2][:-1] # Need a splitting function
                mf_url = url_for("emf.render_elliptic_modular_forms",
                        level=mf_spl[0], weight=mf_spl[1], character=mf_spl[2],
                        label=mf_spl[3])
                self.friends.append(('Modular form ' + mf_label, mf_url))

        if hasattr(self, 'mfhilbert'):
            for i in range(len(self.mfhilbert)):
                mf_label = self.mfhilbert[i]
                mf_spl = mf_label.split('-')
                mf_url = url_for("hmf.render_hmf_webpage",
                        field_label=mf_spl[0], label=mf_label)
                self.friends.append(('Hilbert modular form ' + mf_label, mf_url))
示例#16
0
    def make_class(self):
        curves_data = db_g2c().curves.find({
            "class": self.label
        }).sort([("disc_key", pymongo.ASCENDING),
                 ("label", pymongo.ASCENDING)])
        self.curves = [{
            "label": c['label'],
            "equation_formatted": list_to_min_eqn(c['min_eqn']),
            "url": url_for_label(c['label'])
        } for c in curves_data]
        self.ncurves = curves_data.count()
        self.bad_lfactors = [[c[0],
                              list_to_factored_poly_otherorder(c[1])]
                             for c in self.bad_lfactors]
        for endalgtype in [
                'end_alg', 'rat_end_alg', 'real_end_alg', 'geom_end_alg',
                'rat_geom_end_alg', 'real_geom_end_alg'
        ]:
            if hasattr(self, endalgtype):
                setattr(self, endalgtype + '_name',
                        end_alg_name(getattr(self, endalgtype)))
            else:
                setattr(self, endalgtype + '_name', '')

        self.st_group_name = st_group_name(self.st_group)

        if hasattr(self, 'geom_end_field') and self.geom_end_field <> '':
            self.geom_end_field_name = field_pretty(self.geom_end_field)
        else:
            self.geom_end_field_name = ''

        if self.is_gl2_type:
            self.is_gl2_type_name = 'yes'
        else:
            self.is_gl2_type_name = 'no'
        if hasattr(self, 'is_simple'):
            if self.is_simple:
                self.is_simple_name = 'yes'
            else:
                self.is_simple_name = 'no'
        else:
            self.is_simple_name = '?'
        if hasattr(self, 'is_geom_simple'):
            if self.is_geom_simple:
                self.is_geom_simple_name = 'yes'
            else:
                self.is_geom_simple_name = 'no'
        else:
            self.is_geom_simple_name = '?'

        x = self.label.split('.')[1]

        self.friends = [('L-function',
                         url_for("l_functions.l_function_genus2_page",
                                 cond=self.cond,
                                 x=x)), ('Siegel modular form someday', '.')]

        self.ecproduct_wurl = []
        if hasattr(self, 'ecproduct'):
            for i in range(2):
                curve_label = self.ecproduct[i]
                crv_url = url_for("ec.by_ec_label", label=curve_label)
                if i == 1 or len(set(self.ecproduct)) <> 1:
                    self.friends.append(
                        ('Elliptic curve ' + curve_label, crv_url))
                self.ecproduct_wurl.append({
                    'label': curve_label,
                    'url': crv_url
                })

        self.ecquadratic_wurl = []
        if hasattr(self, 'ecquadratic'):
            for i in range(len(self.ecquadratic)):
                curve_label = self.ecquadratic[i]
                crv_spl = curve_label.split('-')
                crv_url = url_for("ecnf.show_ecnf_isoclass",
                                  nf=crv_spl[0],
                                  conductor_label=crv_spl[1],
                                  class_label=crv_spl[2])
                self.friends.append(('Elliptic curve ' + curve_label, crv_url))
                self.ecquadratic_wurl.append({
                    'label': curve_label,
                    'url': crv_url,
                    'nf': crv_spl[0]
                })

        if hasattr(self, 'mfproduct'):
            for i in range(len(self.mfproduct)):
                mf_label = self.mfproduct[i]
                mf_spl = mf_label.split('.')
                mf_spl.append(mf_spl[2][-1])
                mf_spl[2] = mf_spl[2][:-1]  # Need a splitting function
                mf_url = url_for("emf.render_elliptic_modular_forms",
                                 level=mf_spl[0],
                                 weight=mf_spl[1],
                                 character=mf_spl[2],
                                 label=mf_spl[3])
                self.friends.append(('Modular form ' + mf_label, mf_url))

        if hasattr(self, 'mfhilbert'):
            for i in range(len(self.mfhilbert)):
                mf_label = self.mfhilbert[i]
                mf_spl = mf_label.split('-')
                mf_url = url_for("hmf.render_hmf_webpage",
                                 field_label=mf_spl[0],
                                 label=mf_label)
                self.friends.append(
                    ('Hilbert modular form ' + mf_label, mf_url))

        self.properties = [('Label', self.label),
                           ('Number of curves', str(self.ncurves)),
                           ('Conductor', '%s' % self.cond),
                           ('Sato-Tate group', '\(%s\)' % self.st_group_name),
                           ('\(\mathrm{End}(J_{\overline{\Q}}) \otimes \R\)',
                            '\(%s\)' % self.real_geom_end_alg_name),
                           ('\(\mathrm{GL}_2\)-type',
                            '%s' % self.is_gl2_type_name)]

        self.title = "Genus 2 Isogeny Class %s" % (self.label)
        self.downloads = [
            ('Download Euler factors', ".")
        ]  # url_for(".download_g2c_eulerfactors", label=self.label)),
        #                          ('Download stored data for all curves', url_for(".download_g2c_all", label=self.label))]

        self.bread = [('Genus 2 Curves', url_for(".index")),
                      ('$\Q$', url_for(".index_Q")),
                      ('%s' % self.cond,
                       url_for(".by_conductor", conductor=self.cond)),
                      ('%s' % self.label, ' ')]
示例#17
0
def genus2_curve_search(**args):
    info = to_dict(args)
    query = {}  # database callable
    bread = [('Genus 2 Curves', url_for(".index")),
             ('$\Q$', url_for(".index_Q")), ('Search Results', '.')]
    #if 'SearchAgain' in args:
    #    return rational_genus2_curves()

    if 'jump' in args:
        return render_curve_webpage_by_label(info["jump"])

    if info.get("disc"):
        field = "abs_disc"
        ran = info["disc"]
        ran = ran.replace('..', '-').replace(' ', '')
        # Past input check
        dlist = parse_discs(ran)
        tmp = g2_list_to_query(dlist)

        if len(tmp) == 1:
            tmp = tmp[0]
        else:
            query[tmp[0][0]] = tmp[0][1]
            tmp = tmp[1]

        print tmp

        # work around syntax for $or
        # we have to foil out multiple or conditions
        if tmp[0] == '$or' and '$or' in query:
            newors = []
            for y in tmp[1]:
                oldors = [dict.copy(x) for x in query['$or']]
                for x in oldors:
                    x.update(y)
                newors.extend(oldors)
            tmp[1] = newors
        query[tmp[0]] = tmp[1]

    if info.get("is_gl2_type"):
        query['is_gl2_type'] = bool(info['is_gl2_type'])

    for fld in ['aut_grp', 'geom_aut_grp', 'st_group', 'real_geom_end_alg']:
        if info.get(fld):
            query[fld] = info[fld]
    for fld in ['aut_grp', 'geom_aut_grp']:
        if info.get(fld):
            query[fld] = eval(info[fld])

    if info.get("cond"):
        field = "cond"
        ran = str(info[field])
        ran = ran.replace('..', '-').replace(' ', '')
        # Past input check
        tmp = parse_range2(ran, field)

        print tmp

        # work around syntax for $or
        # we have to foil out multiple or conditions
        if tmp[0] == '$or' and '$or' in query:
            newors = []
            for y in tmp[1]:
                oldors = [dict.copy(x) for x in query['$or']]
                for x in oldors:
                    x.update(y)
                newors.extend(oldors)
            tmp[1] = newors
        query[tmp[0]] = tmp[1]

    if info.get("count"):
        try:
            count = int(info["count"])
        except:
            count = 100
    else:
        count = 100

    info["query"] = dict(query)
    #res = db_g2c().curves.find(query).sort([("cond", pymongo.ASCENDING),
    #("label", pymongo.ASCENDING)]).limit(count)
    res = db_g2c().curves.find(query).sort([("cond", pymongo.ASCENDING),
                                            ("class", pymongo.ASCENDING),
                                            ("disc_key", pymongo.ASCENDING),
                                            ("label", pymongo.ASCENDING)])
    nres = res.count()
    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["isog_label"] = v["class"]
        isogeny_class = db_g2c().isogeny_classes.find_one(
            {'label': isog_label(v["label"])})
        v_clean["is_gl2_type"] = isogeny_class["is_gl2_type"]
        v_clean["equation_formatted"] = list_to_min_eqn(v["min_eqn"])
        res_clean.append(v_clean)

    info["curves"] = res_clean

    info["curve_url"] = lambda dbc: url_for_label(dbc['label'])
    info["isog_url"] = lambda dbc: isog_url_for_label(dbc['label'])
    credit = credit_string
    title = 'Genus 2 Curves search results'
    return render_template("search_results_g2.html",
                           info=info,
                           credit=credit,
                           bread=bread,
                           title=title)