Beispiel #1
0
def render_curve_webpage_by_label(label):
    from sage.misc.misc import cputime
    cpt0 = cputime()
    t0 = time.time()
    data = WebEC.by_label(label)
    if data == "Invalid label":
        return elliptic_curve_jump_error(label, {}, wellformed_label=False)
    if data == "Curve not found":
        return elliptic_curve_jump_error(label, {}, wellformed_label=True)
    try:
        lmfdb_label = data.lmfdb_label
    except AttributeError:
        return elliptic_curve_jump_error(label, {}, wellformed_label=False)

    data.modform_display = url_for(".modular_form_display", label=lmfdb_label, number="")

    code = data.code()
    code['show'] = {'magma':'','pari':'','sage':''} # use default show names
    T =  render_template("ec-curve.html",
                           properties2=data.properties,
                           credit=ec_credit(),
                           data=data,
                           # set default show names but actually code snippets are filled in only when needed
                           code=code,
                           bread=data.bread, title=data.title,
                           friends=data.friends,
                           downloads=data.downloads,
                           learnmore=learnmore_list())
    ec_logger.debug("Total walltime: %ss"%(time.time() - t0))
    ec_logger.debug("Total cputime: %ss"%(cputime(cpt0)))
    return T
Beispiel #2
0
def render_curve_webpage_by_label(label):
    cpt0 = cputime()
    t0 = time.time()
    data = WebEC.by_label(label)
    if data == "Invalid label":
        return elliptic_curve_jump_error(label, {})
    if data == "Curve not found":
        return elliptic_curve_jump_error(label, {}, missing_curve=True)
    try:
        lmfdb_label = data.lmfdb_label
    except AttributeError:
        return elliptic_curve_jump_error(label, {})

    data.modform_display = url_for(".modular_form_display", label=lmfdb_label, number="")

    code = data.code()
    code['show'] = {'magma':'','pari':'','sage':''} # use default show names
    T =  render_template("ec-curve.html",
                         properties=data.properties,
                         credit=ec_credit(),
                         data=data,
                         # set default show names but actually code snippets are filled in only when needed
                         code=code,
                         bread=data.bread, title=data.title,
                         friends=data.friends,
                         downloads=data.downloads,
                         KNOWL_ID="ec.q.%s"%lmfdb_label,
                         BACKUP_KNOWL_ID="ec.q.%s"%data.lmfdb_iso,
                         learnmore=learnmore_list())
    ec_logger.debug("Total walltime: %ss"%(time.time() - t0))
    ec_logger.debug("Total cputime: %ss"%(cputime(cpt0)))
    return T
Beispiel #3
0
def by_ec_label(label):
    ec_logger.debug(label)
    try:
        N, iso, number = split_lmfdb_label(label)
    except AttributeError:
        ec_logger.debug("%s not a valid lmfdb label, trying cremona")
        try:
            N, iso, number = split_cremona_label(label)
        except AttributeError:
            ec_logger.debug("%s not a valid cremona label either, trying Weierstrass")
            eqn = label.replace(" ","")
            if weierstrass_eqn_regex.match(eqn) or short_weierstrass_eqn_regex.match(eqn):
                return by_weierstrass(eqn)
            else:
                return elliptic_curve_jump_error(label, {})

        # We permanently redirect to the lmfdb label
        if number:
            data = db_ec().find_one({'label': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
            return redirect(url_for(".by_ec_label", label=data['lmfdb_label']), 301)
        else:
            data = db_ec().find_one({'iso': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
            return redirect(url_for(".by_ec_label", label=data['lmfdb_iso']), 301)
    if number:
        return redirect(url_for(".by_triple_label", conductor=N, iso_label=iso, number=number))
    else:
        return redirect(url_for(".by_double_iso_label", conductor=N, iso_label=iso))
Beispiel #4
0
    def __init__(self, dbdata):
        """
        Arguments:

            - dbdata: the data from the database
        """
        ec_logger.debug("Constructing an instance of ECisog_class")
        self.__dict__.update(dbdata)
        self.make_class()
Beispiel #5
0
    def __init__(self, dbdata):
        """
        Arguments:

            - dbdata: the data from the database
        """
        ec_logger.debug("Constructing an instance of ECisog_class")
        self.__dict__.update(dbdata)
        self.make_class()
Beispiel #6
0
def download_EC_qexp(label, limit):
    ec_logger.debug(label)
    CDB = lmfdb.base.getDBConnection().elliptic_curves.curves
    N, iso, number = split_lmfdb_label(label)
    if number:
        data = CDB.find_one({'lmfdb_label': label})
    else:
        data = CDB.find_one({'lmfdb_iso': label})
    ainvs = data['ainvs']
    ec_logger.debug(ainvs)
    E = EllipticCurve([int(a) for a in ainvs])
    response = make_response(','.join(str(an) for an in E.anlist(int(limit), python_ints=True)))
    response.headers['Content-type'] = 'text/plain'
    return response
Beispiel #7
0
def download_EC_qexp(label, limit):
    ec_logger.debug(label)
    CDB = lmfdb.base.getDBConnection().elliptic_curves.curves
    N, iso, number = split_lmfdb_label(label)
    if number:
        data = CDB.find_one({'lmfdb_label': label})
    else:
        data = CDB.find_one({'lmfdb_iso': label})
    ainvs = data['ainvs']
    ec_logger.debug(ainvs)
    E = EllipticCurve([int(a) for a in ainvs])
    response = make_response(','.join(str(an) for an in E.anlist(int(limit), python_ints=True)))
    response.headers['Content-type'] = 'text/plain'
    return response
Beispiel #8
0
def by_ec_label(label):
    ec_logger.debug(label)
    try:
        N, iso, number = split_lmfdb_label(label)
    except AttributeError:
        ec_logger.debug("%s not a valid lmfdb label, trying cremona")
        try:
            N, iso, number = split_cremona_label(label)
        except AttributeError:
            ec_logger.debug(
                "%s not a valid cremona label either, trying Weierstrass")
            eqn = label.replace(" ", "")
            if weierstrass_eqn_regex.match(
                    eqn) or short_weierstrass_eqn_regex.match(eqn):
                return by_weierstrass(eqn)
            else:
                return elliptic_curve_jump_error(label, {})

        # We permanently redirect to the lmfdb label
        if number:  # it's a curve
            data = db_ec().find_one({'label': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
            #return redirect(url_for(".by_ec_label", label=data['lmfdb_label']), 301)
            return render_curve_webpage_by_label(data['label'])
        else:  # it's an isogeny class
            data = db_ec().find_one({'iso': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
            #return redirect(url_for(".by_ec_label", label=data['iso']), 301)
            return render_isogeny_class(data['iso'])

    if number:
        return redirect(
            url_for(".by_triple_label",
                    conductor=N,
                    iso_label=iso,
                    number=number))
    else:
        return redirect(
            url_for(".by_double_iso_label", conductor=N, iso_label=iso))
Beispiel #9
0
def by_ec_label(label):
    ec_logger.debug(label)
    try:
        N, iso, number = lmfdb_label_regex.match(label).groups()
    except AttributeError:
        try:
            N, iso, number = cremona_label_regex.match(label).groups()
        except AttributeError:
            return elliptic_curve_jump_error(label, {})
        C = lmfdb.base.getDBConnection()
        # We permanently redirect to the lmfdb label
        if number:
            data = C.elliptic_curves.curves.find_one({'label': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
            return redirect(url_for(".by_ec_label", label=data['lmfdb_label']),
                            301)
        else:
            data = C.elliptic_curves.curves.find_one({'iso': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
            return redirect(url_for(".by_ec_label", label=data['lmfdb_iso']),
                            301)
        # N,d1, iso,d2, number = sw_label_regex.match(label).groups()
    if number:
        return render_curve_webpage_by_label(label=label)
    else:
        return render_isogeny_class(str(N) + '.' + iso)
Beispiel #10
0
def by_ec_label(label):
    ec_logger.debug(label)

    # First see if we have an LMFDB label of a curve or class:
    try:
        N, iso, number = split_lmfdb_label(label)
        if number:
            return redirect(
                url_for(".by_triple_label",
                        conductor=N,
                        iso_label=iso,
                        number=number))
        else:
            return redirect(
                url_for(".by_double_iso_label", conductor=N, iso_label=iso))

    except AttributeError:
        ec_logger.debug("%s not a valid lmfdb label, trying cremona")
        # Next see if we have a Cremona label of a curve or class:
        try:
            N, iso, number = split_cremona_label(label)
        except AttributeError:
            ec_logger.debug(
                "%s not a valid cremona label either, trying Weierstrass")
            eqn = label.replace(" ", "")
            if weierstrass_eqn_regex.match(
                    eqn) or short_weierstrass_eqn_regex.match(eqn):
                return by_weierstrass(eqn)
            else:
                return elliptic_curve_jump_error(label, {})

        if number:  # it's a curve
            label_type = 'label'
        else:
            label_type = 'iso'

        data = db_ec().find_one({label_type: label})
        if data is None:
            return elliptic_curve_jump_error(label, {})
        ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
        iso = data['lmfdb_iso'].split(".")[1]
        if number:
            return redirect(
                url_for(".by_triple_label",
                        conductor=N,
                        iso_label=iso,
                        number=data['lmfdb_number']))
        else:
            return redirect(
                url_for(".by_double_iso_label", conductor=N, iso_label=iso))
def by_ec_label(label):
    ec_logger.debug(label)
    try:
        N, iso, number = lmfdb_label_regex.match(label).groups()
    except AttributeError:
        try:
            N, iso, number = cremona_label_regex.match(label).groups()
        except AttributeError:
            return elliptic_curve_jump_error(label, {})
        C = lmfdb.base.getDBConnection()
        # We permanently redirect to the lmfdb label
        if number:
            data = C.elliptic_curves.curves.find_one({'label': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for("by_ec_label", label=data['lmfdb_label']))
            return redirect(url_for("by_ec_label", label=data['lmfdb_label']), 301)
        else:
            data = C.elliptic_curves.curves.find_one({'iso': label})
            if data is None:
                return elliptic_curve_jump_error(label, {})
            ec_logger.debug(url_for("by_ec_label", label=data['lmfdb_label']))
            return redirect(url_for("by_ec_label", label=data['lmfdb_iso']), 301)
        # N,d1, iso,d2, number = sw_label_regex.match(label).groups()
    if number:
        return render_curve_webpage_by_label(label=label)
    else:
        return render_isogeny_class(str(N) + '.' + iso)
Beispiel #12
0
def by_ec_label(label):
    ec_logger.debug(label)

    # First see if we have an LMFDB label of a curve or class:
    try:
        N, iso, number = split_lmfdb_label(label)
        if number:
            return redirect(url_for(".by_triple_label", conductor=N, iso_label=iso, number=number))
        else:
            return redirect(url_for(".by_double_iso_label", conductor=N, iso_label=iso))

    except AttributeError:
        ec_logger.debug("%s not a valid lmfdb label, trying cremona")
        # Next see if we have a Cremona label of a curve or class:
        try:
            N, iso, number = split_cremona_label(label)
        except AttributeError:
            ec_logger.debug("%s not a valid cremona label either, trying Weierstrass")
            eqn = label.replace(" ","")
            if weierstrass_eqn_regex.match(eqn) or short_weierstrass_eqn_regex.match(eqn):
                return by_weierstrass(eqn)
            else:
                return elliptic_curve_jump_error(label, {})

        if number: # it's a curve
            label_type = 'label'
        else:
            label_type = 'iso'

        data = db.ec_curves.lucky({label_type: label}, projection=1)
        if data is None:
            return elliptic_curve_jump_error(label, {}, wellformed_label=True, missing_curve=True)
        ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label']))
        iso = data['lmfdb_iso'].split(".")[1]
        if number:
            return render_curve_webpage_by_label(label)
            #return redirect(url_for(".by_triple_label", conductor=N, iso_label=iso, number=data['lmfdb_number']))
        else:
            return render_isogeny_class(label)