コード例 #1
0
ファイル: main.py プロジェクト: paulhus/lmfdb
def show_ecnf_isoclass(nf, conductor_label, class_label):
    nf_label = parse_field_string(nf)
    label = "-".join([nf_label, conductor_label, class_label])
    full_class_label = "-".join([conductor_label, class_label])
    cl = ECNF_isoclass.by_label(label)
    title = "Elliptic Curve isogeny class %s over Number Field %s" % (
        full_class_label, cl.ECNF.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append(
        (cl.ECNF.field.field_pretty(), url_for(".show_ecnf1", nf=nf_label)))
    bread.append((conductor_label,
                  url_for(".show_ecnf_conductor",
                          nf=nf_label,
                          conductor_label=conductor_label)))
    bread.append((class_label,
                  url_for(".show_ecnf_isoclass",
                          nf=nf_label,
                          conductor_label=conductor_label,
                          class_label=class_label)))
    info = {}
    return render_template("show-ecnf-isoclass.html",
                           credit=ecnf_credit,
                           title=title,
                           bread=bread,
                           cl=cl,
                           properties2=cl.properties,
                           friends=cl.friends)
コード例 #2
0
ファイル: main.py プロジェクト: paulhus/lmfdb
def show_ecnf(nf, conductor_label, class_label, number):
    nf_label = parse_field_string(nf)
    label = "".join(
        ["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    bread = [("Elliptic Curves", url_for(".index"))]
    if not ec:
        info = {}
        info['query'] = {}
        info['err'] = 'No elliptic curve in the database has label %s.' % label
        return search_input_error(info, bread)

    title = "Elliptic Curve %s over Number Field %s" % (
        ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls['field']))
    bread.append((ec.conductor_label, ec.urls['conductor']))
    bread.append((ec.iso_label, ec.urls['class']))
    bread.append((ec.number, ec.urls['curve']))
    info = {}

    return render_template(
        "show-ecnf.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
        #        properties = ec.properties,
        properties2=ec.properties,
        friends=ec.friends,
        info=info)
コード例 #3
0
ファイル: main.py プロジェクト: sibilant/lmfdb
def show_ecnf(nf, conductor_label, class_label, number):
    nf_label = parse_field_string(nf)
    label = "".join(["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    bread = [("Elliptic Curves", url_for(".index"))]
    if not ec:
        info = {}
        info['query'] = {}
        info['err'] = 'No elliptic curve in the database has label %s.' % label
        return search_input_error(info, bread)

    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls['field']))
    bread.append((ec.conductor_label, ec.urls['conductor']))
    bread.append((ec.iso_label, ec.urls['class']))
    bread.append((ec.number, ec.urls['curve']))
    info = {}

    return render_template("show-ecnf.html",
                           credit=ecnf_credit,
                           title=title,
                           bread=bread,
                           ec=ec,
                           #        properties = ec.properties,
                           properties2=ec.properties,
                           friends=ec.friends,
                           info=info)
コード例 #4
0
ファイル: main.py プロジェクト: paulhus/lmfdb
def show_ecnf_conductor(nf, conductor_label):
    nf_label = parse_field_string(nf)
    return elliptic_curve_search(data={
        'nf_label': nf_label,
        'conductor_label': conductor_label
    },
                                 **request.args)
コード例 #5
0
ファイル: main.py プロジェクト: zhuhuilin2015/lmfdb
def show_ecnf_isoclass(nf, conductor_label, class_label):
    nf_label = parse_field_string(nf)
    label = "-".join([nf_label, conductor_label, class_label])
    full_class_label = "-".join([conductor_label, class_label])
    cl = ECNF_isoclass.by_label(label)
    title = "Elliptic Curve isogeny class %s over Number Field %s" % (full_class_label, cl.ECNF.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((cl.ECNF.field.field_pretty(), url_for(".show_ecnf1", nf=nf_label)))
    bread.append((conductor_label, url_for(".show_ecnf_conductor", nf=nf_label, conductor_label=conductor_label)))
    bread.append(
        (
            class_label,
            url_for(".show_ecnf_isoclass", nf=nf_label, conductor_label=conductor_label, class_label=class_label),
        )
    )
    info = {}
    return render_template(
        "show-ecnf-isoclass.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        cl=cl,
        properties2=cl.properties,
        friends=cl.friends,
    )
コード例 #6
0
ファイル: main.py プロジェクト: sfrechet/lmfdb
def show_ecnf1(nf):
    if nf == "1.1.1.1":
        return redirect(url_for("ec.rational_elliptic_curves", **request.args))
    if request.args:
        return elliptic_curve_search(data=request.args)
    start = 0
    count = 50
    nf_label = parse_field_string(nf)
    query = {"field_label": nf_label}
    cursor = db_ecnf().find(query)
    nres = cursor.count()
    if start >= nres:
        start -= (1 + (start - nres) / count) * count
    if start < 0:
        start = 0
    res = (
        cursor.sort(
            [
                ("field_label", ASC),
                ("conductor_norm", ASC),
                ("conductor_label", ASC),
                ("iso_label", ASC),
                ("number", ASC),
            ]
        )
        .skip(start)
        .limit(count)
    )

    bread = [("Elliptic Curves", url_for(".index")), (nf_label, url_for(".show_ecnf1", nf=nf_label))]

    res = list(res)
    for e in res:
        e["field_knowl"] = nf_display_knowl(e["field_label"], getDBConnection(), e["field_label"])
    info = {}
    info["field"] = nf_label
    info["query"] = query
    info["curves"] = res  # [ECNF(e) for e in res]
    info["number"] = nres
    info["start"] = start
    info["count"] = count
    info["more"] = int(start + count < nres)
    info["field_pretty"] = field_pretty
    info["web_ainvs"] = web_ainvs
    if nres == 1:
        info["report"] = "unique match"
    else:
        if nres > count or start != 0:
            info["report"] = "displaying matches %s-%s of %s" % (start + 1, min(nres, start + count), nres)
        else:
            info["report"] = "displaying all %s matches" % nres
    t = "Elliptic Curves over %s" % field_pretty(nf_label)
    return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
コード例 #7
0
ファイル: main.py プロジェクト: paulhus/lmfdb
def show_ecnf1(nf):
    if nf == "1.1.1.1":
        return redirect(url_for("ec.rational_elliptic_curves", **request.args))
    if request.args:
        return elliptic_curve_search(data=request.args)
    start = 0
    count = 50
    nf_label = parse_field_string(nf)
    query = {'field_label': nf_label}
    cursor = db_ecnf().find(query)
    nres = cursor.count()
    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0
    res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC),
                       ('conductor_label', ASC), ('iso_nlabel', ASC),
                       ('number', ASC)]).skip(start).limit(count)

    bread = [('Elliptic Curves', url_for(".index")),
             (nf_label, url_for('.show_ecnf1', nf=nf_label))]

    res = list(res)
    for e in res:
        e['field_knowl'] = nf_display_knowl(e['field_label'],
                                            getDBConnection(),
                                            e['field_label'])
    info = {}
    info['field'] = nf_label
    info['query'] = query
    info['curves'] = res  # [ECNF(e) for e in res]
    info['number'] = nres
    info['start'] = start
    info['count'] = count
    info['more'] = int(start + count < nres)
    info['field_pretty'] = field_pretty
    info['web_ainvs'] = web_ainvs
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (
                start + 1, min(nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres
    t = 'Elliptic Curves over %s' % field_pretty(nf_label)
    return render_template("ecnf-search-results.html",
                           info=info,
                           credit=ecnf_credit,
                           bread=bread,
                           title=t)
コード例 #8
0
ファイル: main.py プロジェクト: elguindy/lmfdb
def show_ecnf(nf, label):
    nf_label = parse_field_string(nf)
    label = "-".join([nf_label, label])
    ec = ECNF.by_label(label)
    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(),url_for(".show_ecnf1", nf=nf_label)))
    bread.append((ec.short_label, url_for(".show_ecnf", label = ec.short_label, nf = nf_label)))
    info = {}

    return render_template("show-ecnf.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
#        properties = ec.properties,
        properties2 = ec.properties,
        friends = ec.friends,
        info=info)
コード例 #9
0
ファイル: main.py プロジェクト: sibilant/lmfdb
def show_ecnf1(nf):
    if nf == "1.1.1.1":
        return redirect(url_for("ec.rational_elliptic_curves", **request.args))
    if request.args:
        return elliptic_curve_search(data=request.args)
    start = 0
    count = 50
    nf_label = parse_field_string(nf)
    query = {'field_label': nf_label}
    cursor = db_ecnf().find(query)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0
    res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_label', ASC), ('number', ASC)]).skip(start).limit(count)

    bread = [('Elliptic Curves', url_for(".index")),
             (nf_label, url_for('.show_ecnf1', nf=nf_label))]

    res = list(res)
    for e in res:
        e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), e['field_label'])
    info = {}
    info['field'] = nf_label
    info['query'] = query
    info['curves'] = res  # [ECNF(e) for e in res]
    info['number'] = nres
    info['start'] = start
    info['count'] = count
    info['more'] = int(start + count < nres)
    info['field_pretty'] = field_pretty
    info['web_ainvs'] = web_ainvs
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres
    t = 'Elliptic Curves over %s' % field_pretty(nf_label)
    return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
コード例 #10
0
ファイル: main.py プロジェクト: zhuhuilin2015/lmfdb
def show_ecnf(nf, class_label, conductor_label, number):
    nf_label = parse_field_string(nf)
    label = "".join(["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls["field"]))
    bread.append((ec.conductor_label, ec.urls["conductor"]))
    bread.append((ec.iso_label, ec.urls["class"]))
    bread.append((ec.number, ec.urls["curve"]))
    info = {}

    return render_template(
        "show-ecnf.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
        #        properties = ec.properties,
        properties2=ec.properties,
        friends=ec.friends,
        info=info,
    )
コード例 #11
0
def hilbert_modular_form_search(**args):
    C = getDBConnection()
    C.hmfs.forms.ensure_index([('level_norm', pymongo.ASCENDING),
                               ('label', pymongo.ASCENDING)])

    info = to_dict(args)  # what has been entered in the search boxes
    if 'label' in info:
        args = {'label': info['label']}
        return render_hmf_webpage(**args)
    query = {}
    for field in ['field_label', 'weight', 'level_norm', 'dimension']:
        if info.get(field):
            if field == 'weight':
                try:
                    parallelweight = int(info[field])
                    query['parallel_weight'] = parallelweight
                except:
                    query[field] = str(parse_list(info[field]))
            elif field == 'field_label':
                query[field] = parse_field_string(info[field])
            elif field == 'label':
                query[field] = info[field]
            elif field == 'dimension':
                query[field] = parse_range(str(info[field]))
            elif field == 'level_norm':
                query[field] = parse_range(info[field])
            else:
                query[field] = info[field]

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

    info['query'] = dict(query)
    res = C.hmfs.forms.find(query).sort([('level_norm', pymongo.ASCENDING),
                                         ('label', pymongo.ASCENDING)
                                         ]).limit(count)
    nres = res.count()

    if nres > 0:
        info['field_pretty_name'] = field_pretty(res[0]['field_label'])
    else:
        info['field_pretty_name'] = ''
    info['number'] = nres
    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['field_label'] = v['field_label']
        v_clean['short_label'] = v['short_label']
        v_clean['label'] = v['label']
        v_clean['level_ideal'] = teXify_pol(v['level_ideal'])
        v_clean['dimension'] = v['dimension']
        res_clean.append(v_clean)

    info['forms'] = res_clean

    t = 'Hilbert Modular Form search results'

    bread = [('Hilbert Modular Forms',
              url_for(".hilbert_modular_form_render_webpage")),
             ('Search results', ' ')]
    properties = []
    return render_template("hilbert_modular_form_search.html",
                           info=info,
                           title=t,
                           properties=properties,
                           bread=bread)
コード例 #12
0
def hilbert_modular_form_search(**args):
    C = getDBConnection()
    C.hmfs.forms.ensure_index([("level_norm", pymongo.ASCENDING), ("label", pymongo.ASCENDING)])

    info = to_dict(args)  # what has been entered in the search boxes
    if "label" in info:
        args = {"label": info["label"]}
        return render_hmf_webpage(**args)
    query = {}
    for field in ["field_label", "weight", "level_norm", "dimension"]:
        if info.get(field):
            if field == "weight":
                try:
                    parallelweight = int(info[field])
                    query["parallel_weight"] = parallelweight
                except:
                    query[field] = str(parse_list(info[field]))
            elif field == "field_label":
                query[field] = parse_field_string(info[field])
            elif field == "label":
                query[field] = info[field]
            elif field == "dimension":
                query[field] = parse_range(str(info[field]))
            elif field == "level_norm":
                query[field] = parse_range(info[field])
            else:
                query[field] = info[field]

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

    info["query"] = dict(query)
    res = C.hmfs.forms.find(query).sort([("level_norm", pymongo.ASCENDING), ("label", pymongo.ASCENDING)]).limit(count)
    nres = res.count()

    if nres > 0:
        info["field_pretty_name"] = field_pretty(res[0]["field_label"])
    else:
        info["field_pretty_name"] = ""
    info["number"] = nres
    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["field_label"] = v["field_label"]
        v_clean["short_label"] = v["short_label"]
        v_clean["label"] = v["label"]
        v_clean["level_ideal"] = teXify_pol(v["level_ideal"])
        v_clean["dimension"] = v["dimension"]
        res_clean.append(v_clean)

    info["forms"] = res_clean

    t = "Hilbert Modular Form search results"

    bread = [("Hilbert Modular Forms", url_for(".hilbert_modular_form_render_webpage")), ("Search results", " ")]
    properties = []
    return render_template("hilbert_modular_form_search.html", info=info, title=t, properties=properties, bread=bread)
コード例 #13
0
ファイル: main.py プロジェクト: sibilant/lmfdb
def show_ecnf_conductor(nf, conductor_label):
    nf_label = parse_field_string(nf)
    return elliptic_curve_search(data={'nf_label': nf_label, 'conductor_label': conductor_label}, **request.args)
コード例 #14
0
ファイル: main.py プロジェクト: sfrechet/lmfdb
def elliptic_curve_search(**args):
    info = to_dict(args["data"])
    if "jump" in info:
        label = info.get("label", "").replace(" ", "")
        # This label should be a full isogeny class label or a full
        # curve label (including the field_label component)
        try:
            nf, cond_label, iso_label, number = split_full_label(label)
        except IndexError:
            if not "query" in info:
                info["query"] = {}
            bread = [("Elliptic Curves", url_for(".index"))]
            info["err"] = "No elliptic curve in the database has label %s." % label
            return search_input_error(info, bread)

        return show_ecnf(nf, cond_label, iso_label, number)

    query = {}
    bread = [("Elliptic Curves", url_for(".index")), ("Search Results", ".")]

    if "conductor_norm" in info:
        Nnorm = clean_input(info["conductor_norm"])
        Nnorm = Nnorm.replace("..", "-").replace(" ", "")
        tmp = parse_range2(Nnorm, "conductor_norm")
        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 "conductor_label" in info:
        query["conductor_label"] = info["conductor_label"]

    if "jinv" in info:
        query["jinv"] = info["jinv"]

    if info.get("torsion"):
        ran = info["torsion"] = clean_input(info["torsion"])
        ran = ran.replace("..", "-").replace(" ", "")
        if not LIST_RE.match(ran):
            info[
                "err"
            ] = "Error parsing input for the torsion order.  It needs to be an integer (such as 5), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121)."
            return search_input_error(info, bread)
        # Past input check
        tmp = parse_range2(ran, "torsion_order")
        # 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 "torsion_structure" in info and info["torsion_structure"]:
        res = parse_torsion_structure(info["torsion_structure"], 2)
        if "Error" in res:
            info["err"] = res
            return search_input_error(info, bread)
        # update info for repeat searches
        info["torsion_structure"] = str(res).replace(" ", "")
        query["torsion_structure"] = [int(r) for r in res]

    if "include_isogenous" in info and info["include_isogenous"] == "off":
        query["number"] = 1

    if "include_base_change" in info and info["include_base_change"] == "off":
        query["base_change"] = []
    else:
        info["include_base_change"] = "on"

    if "field" in info:
        query["field_label"] = parse_field_string(info["field"])

    info["query"] = query

    # process count and start if not default:

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

    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

    # make the query and trim results according to start/count:

    cursor = db_ecnf().find(query)
    nres = cursor.count()
    if start >= nres:
        start -= (1 + (start - nres) / count) * count
    if start < 0:
        start = 0
    res = (
        cursor.sort(
            [
                ("field_label", ASC),
                ("conductor_norm", ASC),
                ("conductor_label", ASC),
                ("iso_label", ASC),
                ("number", ASC),
            ]
        )
        .skip(start)
        .limit(count)
    )

    res = list(res)
    for e in res:
        e["numb"] = str(e["number"])
        e["field_knowl"] = nf_display_knowl(e["field_label"], getDBConnection(), e["field_label"])

    info["curves"] = res  # [ECNF(e) for e in res]
    info["number"] = nres
    info["start"] = start
    info["count"] = count
    info["more"] = int(start + count < nres)
    info["field_pretty"] = field_pretty
    info["web_ainvs"] = web_ainvs
    if nres == 1:
        info["report"] = "unique match"
    else:
        if nres > count or start != 0:
            info["report"] = "displaying matches %s-%s of %s" % (start + 1, min(nres, start + count), nres)
        else:
            info["report"] = "displaying all %s matches" % nres
    t = "Elliptic Curve search results"
    return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
コード例 #15
0
ファイル: main.py プロジェクト: paulhus/lmfdb
def elliptic_curve_search(**args):
    info = to_dict(args['data'])
    if 'jump' in info:
        label = info.get('label', '').replace(" ", "")
        # This label should be a full isogeny class label or a full
        # curve label (including the field_label component)
        try:
            nf, cond_label, iso_label, number = split_full_label(label.strip())
        except IndexError:
            if not 'query' in info:
                info['query'] = {}
            bread = [("Elliptic Curves", url_for(".index"))]
            info[
                'err'] = 'No elliptic curve in the database has label %s.' % label
            return search_input_error(info, bread)

        return show_ecnf(nf, cond_label, iso_label, number)

    query = {}
    bread = [('Elliptic Curves', url_for(".index")), ('Search Results', '.')]

    if 'conductor_norm' in info:
        Nnorm = clean_input(info['conductor_norm'])
        Nnorm = Nnorm.replace('..', '-').replace(' ', '')
        tmp = parse_range2(Nnorm, 'conductor_norm')
        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 'conductor_label' in info:
        query['conductor_label'] = info['conductor_label']

    if 'jinv' in info:
        query['jinv'] = info['jinv']

    if info.get('torsion'):
        ran = info['torsion'] = clean_input(info['torsion'])
        ran = ran.replace('..', '-').replace(' ', '')
        if not LIST_RE.match(ran):
            info[
                'err'] = 'Error parsing input for the torsion order.  It needs to be an integer (such as 5), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121).'
            return search_input_error(info, bread)
        # Past input check
        tmp = parse_range2(ran, 'torsion_order')
        # 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 'torsion_structure' in info and info['torsion_structure']:
        res = parse_torsion_structure(info['torsion_structure'], 2)
        if 'Error' in res:
            info['err'] = res
            return search_input_error(info, bread)
        #update info for repeat searches
        info['torsion_structure'] = str(res).replace(' ', '')
        query['torsion_structure'] = [int(r) for r in res]

    if 'include_isogenous' in info and info['include_isogenous'] == 'off':
        query['number'] = 1

    if 'include_base_change' in info and info['include_base_change'] == 'off':
        query['base_change'] = []
    else:
        info['include_base_change'] = "on"

    if 'field' in info:
        query['field_label'] = parse_field_string(info['field'])

    info['query'] = query

    # process count and start if not default:

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

    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


# make the query and trim results according to start/count:

    cursor = db_ecnf().find(query)
    nres = cursor.count()
    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0
    res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC),
                       ('conductor_label', ASC), ('iso_nlabel', ASC),
                       ('number', ASC)]).skip(start).limit(count)

    res = list(res)
    for e in res:
        e['numb'] = str(e['number'])
        e['field_knowl'] = nf_display_knowl(e['field_label'],
                                            getDBConnection(),
                                            e['field_label'])

    info['curves'] = res  # [ECNF(e) for e in res]
    info['number'] = nres
    info['start'] = start
    info['count'] = count
    info['more'] = int(start + count < nres)
    info['field_pretty'] = field_pretty
    info['web_ainvs'] = web_ainvs
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (
                start + 1, min(nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres
    t = 'Elliptic Curve search results'
    return render_template("ecnf-search-results.html",
                           info=info,
                           credit=ecnf_credit,
                           bread=bread,
                           title=t)
コード例 #16
0
def hilbert_modular_form_search(**args):
    C = getDBConnection()
    C.hmfs.forms.ensure_index([('level_norm', pymongo.ASCENDING), ('label', pymongo.ASCENDING)])

    info = to_dict(args)  # what has been entered in the search boxes
    if 'label' in info:
        args = {'label': info['label']}
        return render_hmf_webpage(**args)
    query = {}
    for field in ['field_label', 'weight', 'level_norm', 'dimension']:
        if info.get(field):
            if field == 'weight':
                try:
                    parallelweight = int(info[field])
                    query['parallel_weight'] = parallelweight
                except:
                    query[field] = str(parse_list(info[field]))
            elif field == 'field_label':
                query[field] = parse_field_string(info[field])
            elif field == 'label':
                query[field] = info[field]
            elif field == 'dimension':
                query[field] = parse_range(str(info[field]))
            elif field == 'level_norm':
                query[field] = parse_range(info[field])
            else:
                query[field] = info[field]

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

    info['query'] = dict(query)
    res = C.hmfs.forms.find(
        query).sort([('level_norm', pymongo.ASCENDING), ('label', pymongo.ASCENDING)]).limit(count)
    nres = res.count()

    if nres > 0:
        info['field_pretty_name'] = field_pretty(res[0]['field_label'])
    else:
        info['field_pretty_name'] = ''
    info['number'] = nres
    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['field_label'] = v['field_label']
        v_clean['short_label'] = v['short_label']
        v_clean['label'] = v['label']
        v_clean['level_ideal'] = teXify_pol(v['level_ideal'])
        v_clean['dimension'] = v['dimension']
        res_clean.append(v_clean)

    info['forms'] = res_clean

    t = 'Hilbert Modular Form search results'

    bread = [('Hilbert Modular Forms', url_for(".hilbert_modular_form_render_webpage")), (
        'Search results', ' ')]
    properties = []
    return render_template("hilbert_modular_form_search.html", info=info, title=t, properties=properties, bread=bread)
コード例 #17
0
ファイル: main.py プロジェクト: sibilant/lmfdb
def elliptic_curve_search(**args):
    info = to_dict(args['data'])
    if 'jump' in info:
        label = info.get('label', '').replace(" ", "")
        # This label should be a full isogeny class label or a full
        # curve label (including the field_label component)
        try:
            nf, cond_label, iso_label, number = split_full_label(label)
        except IndexError:
            if not 'query' in info:
                info['query'] = {}
            bread = [("Elliptic Curves", url_for(".index"))]
            info['err'] = 'No elliptic curve in the database has label %s.' % label
            return search_input_error(info, bread)

        return show_ecnf(nf, cond_label, iso_label, number)

    query = {}
    bread = [('Elliptic Curves', url_for(".index")),
             ('Search Results', '.')]

    if 'conductor_norm' in info:
        Nnorm = clean_input(info['conductor_norm'])
        Nnorm = Nnorm.replace('..', '-').replace(' ', '')
        tmp = parse_range2(Nnorm, 'conductor_norm')
        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 'conductor_label' in info:
        query['conductor_label'] = info['conductor_label']

    if 'jinv' in info:
        query['jinv'] = info['jinv']

    if info.get('torsion'):
        ran = info['torsion'] = clean_input(info['torsion'])
        ran = ran.replace('..', '-').replace(' ', '')
        if not LIST_RE.match(ran):
            info['err'] = 'Error parsing input for the torsion order.  It needs to be an integer (such as 5), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121).'
            return search_input_error(info, bread)
        # Past input check
        tmp = parse_range2(ran, 'torsion_order')
        # 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 'torsion_structure' in info and info['torsion_structure']:
        info['torsion_structure'] = clean_input(info['torsion_structure'])
        if not TORS_RE.match(info['torsion_structure']):
            info['err'] = 'Error parsing input for the torsion structure.  It needs to be one or more integers in square brackets, such as [6], [2,2], or [2,4].  Moreover, each integer should be bigger than 1, and each divides the next.'
            return search_input_error(info, bread)
        query['torsion_structure'] = parse_list(info['torsion_structure'])

    if 'include_isogenous' in info and info['include_isogenous'] == 'off':
        query['number'] = 1

    if 'include_base_change' in info and info['include_base_change'] == 'off':
        query['base_change'] = []
    else:
        info['include_base_change'] = "on"

    if 'field' in info:
        query['field_label'] = parse_field_string(info['field'])

    info['query'] = query

# process count and start if not default:

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

    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

# make the query and trim results according to start/count:

    cursor = db_ecnf().find(query)
    nres = cursor.count()
    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0
    res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_label', ASC), ('number', ASC)]).skip(start).limit(count)

    res = list(res)
    for e in res:
        e['numb'] = str(e['number'])
        e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), e['field_label'])

    info['curves'] = res  # [ECNF(e) for e in res]
    info['number'] = nres
    info['start'] = start
    info['count'] = count
    info['more'] = int(start + count < nres)
    info['field_pretty'] = field_pretty
    info['web_ainvs'] = web_ainvs
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres
    t = 'Elliptic Curve search results'
    return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
コード例 #18
0
def hilbert_modular_form_search(**args):
    C = getDBConnection()
#    C.hmfs.forms.ensure_index([('level_norm', pymongo.ASCENDING), ('label', pymongo.ASCENDING)])

    info = to_dict(args)  # what has been entered in the search boxes
    if 'label' in info:
        args = {'label': info['label']}
        return render_hmf_webpage(**args)
    query = {}
    for field in ['field_degree', 'field_disc', 'field_label', 'weight', 'level_norm', 'dimension']:
        if info.get(field):
            if field == 'weight':
                try:
                    parallelweight = int(info[field])
                    query['parallel_weight'] = parallelweight
                except:
                    query[field] = str(parse_list(info[field]))
            elif field == 'field_label':
                query[field] = parse_field_string(info[field])
            elif field == 'field_degree':
                query['deg'] = parse_range(info[field])
            elif field == 'field_disc':
                query['disc'] = parse_range(info[field])
            elif field == 'label':
                query[field] = info[field]
            elif field == 'dimension':
                query[field] = parse_range(str(info[field]))
            elif field == 'level_norm':
                query[field] = parse_range(info[field])
            else:
                query[field] = info[field]

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

    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

    info['query'] = dict(query)
    res = C.hmfs.forms.find(
        query).sort([('deg', pymongo.ASCENDING), ('disc', pymongo.ASCENDING), ('level_norm', pymongo.ASCENDING), ('level_label', pymongo.ASCENDING), ('label_nsuffix', pymongo.ASCENDING)]).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'] = 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['field_label'] = v['field_label']
        v_clean['short_label'] = v['short_label']
        v_clean['label'] = v['label']
        v_clean['level_ideal'] = teXify_pol(v['level_ideal'])
        v_clean['dimension'] = v['dimension']
        res_clean.append(v_clean)

    info['forms'] = res_clean

    t = 'Hilbert Modular Form search results'

    bread = [('Hilbert Modular Forms', url_for(".hilbert_modular_form_render_webpage")), (
        'Search results', ' ')]
    properties = []
    return render_template("hilbert_modular_form_search.html", info=info, title=t, credit=hmf_credit, properties=properties, bread=bread)
コード例 #19
0
def hilbert_modular_form_search(**args):
    C = getDBConnection()
    #    C.hmfs.forms.ensure_index([('level_norm', pymongo.ASCENDING), ('label', pymongo.ASCENDING)])

    info = to_dict(args)  # what has been entered in the search boxes
    if 'label' in info:
        args = {'label': info['label']}
        return render_hmf_webpage(**args)
    query = {}
    for field in [
            'field_degree', 'field_disc', 'field_label', 'weight',
            'level_norm', 'dimension'
    ]:
        if info.get(field):
            if field == 'weight':
                try:
                    parallelweight = int(info[field])
                    query['parallel_weight'] = parallelweight
                except:
                    query[field] = str(parse_list(info[field]))
            elif field == 'field_label':
                query[field] = parse_field_string(info[field])
            elif field == 'field_degree':
                query['deg'] = parse_range(info[field])
            elif field == 'field_disc':
                query['disc'] = parse_range(info[field])
            elif field == 'label':
                query[field] = info[field]
            elif field == 'dimension':
                query[field] = parse_range(str(info[field]))
            elif field == 'level_norm':
                query[field] = parse_range(info[field])
            else:
                query[field] = info[field]

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

    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

    info['query'] = dict(query)
    res = C.hmfs.forms.find(query).sort([('deg', pymongo.ASCENDING),
                                         ('disc', pymongo.ASCENDING),
                                         ('level_norm', pymongo.ASCENDING),
                                         ('level_label', pymongo.ASCENDING),
                                         ('label_nsuffix', pymongo.ASCENDING)
                                         ]).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'] = 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['field_label'] = v['field_label']
        v_clean['short_label'] = v['short_label']
        v_clean['label'] = v['label']
        v_clean['level_ideal'] = teXify_pol(v['level_ideal'])
        v_clean['dimension'] = v['dimension']
        res_clean.append(v_clean)

    info['forms'] = res_clean

    t = 'Hilbert Modular Form search results'

    bread = [('Hilbert Modular Forms',
              url_for(".hilbert_modular_form_render_webpage")),
             ('Search results', ' ')]
    properties = []
    return render_template("hilbert_modular_form_search.html",
                           info=info,
                           title=t,
                           credit=hmf_credit,
                           properties=properties,
                           bread=bread)