Exemplo n.º 1
0
    def __init__(self, dbdata):
        """
        Arguments:

            - dbdata: the data from the database
        """
        logger.debug("Constructing an instance of ECisog_class")
        self.__dict__.update(dbdata)
        # Next lines because the hyphens make trouble
        self.xintcoords = split_list(dbdata["x-coordinates_of_integral_points"])
        self.non_surjective_primes = dbdata["non-surjective_primes"]
        # Next lines because the python identifiers cannot start with 2
        self.twoadic_index = dbdata["2adic_index"]
        self.twoadic_log_level = dbdata["2adic_log_level"]
        self.twoadic_gens = dbdata["2adic_gens"]
        self.twoadic_label = dbdata["2adic_label"]
        # All other fields are handled here
        self.make_curve()
Exemplo n.º 2
0
    def __init__(self, dbdata):
        """
        Arguments:

            - dbdata: the data from the database
        """
        logger.debug("Constructing an instance of WebEC")
        self.__dict__.update(dbdata)
        # Next lines because the hyphens make trouble
        self.xintcoords = split_list(
            dbdata['x-coordinates_of_integral_points'])
        self.non_surjective_primes = dbdata['non-surjective_primes']
        # Next lines because the python identifiers cannot start with 2
        self.twoadic_index = dbdata['2adic_index']
        self.twoadic_log_level = dbdata['2adic_log_level']
        self.twoadic_gens = dbdata['2adic_gens']
        self.twoadic_label = dbdata['2adic_label']
        # All other fields are handled here
        self.make_curve()
Exemplo n.º 3
0
    def __init__(self, dbdata):
        """
        Arguments:

            - dbdata: the data from the database
        """
        logger.debug("Constructing an instance of WebEC")
        self.__dict__.update(dbdata)
        # Next lines because the hyphens make trouble
        self.xintcoords = split_list(dbdata['x-coordinates_of_integral_points'])
        self.non_maximal_primes = dbdata['non-maximal_primes']
        self.mod_p_images = dbdata['mod-p_images']

        # Next lines because the python identifiers cannot start with 2
        self.twoadic_index = dbdata['2adic_index']
        self.twoadic_log_level = dbdata['2adic_log_level']
        self.twoadic_gens = dbdata['2adic_gens']
        self.twoadic_label = dbdata['2adic_label']
        # All other fields are handled here
        self.make_curve()
Exemplo n.º 4
0
def download_EC_all(label):
    CDB = lmfdb.base.getDBConnection().elliptic_curves.curves
    N, iso, number = split_lmfdb_label(label)
    if number:
        data = CDB.find_one({'lmfdb_label': label})
        if data is None:
            return elliptic_curve_jump_error(label, {})
        data_list = [data]
    else:
        data_list = sorted(list(CDB.find({'lmfdb_iso': label})),
                           key=lambda E: E['number'])
        if len(data_list) == 0:
            return elliptic_curve_jump_error(label, {})

    # titles of all entries of curves
    dump_data = []
    titles = [str(c) for c in data_list[0]]
    titles = [t for t in titles if t[0] != '_']
    titles.sort()
    dump_data.append(titles)
    for data in data_list:
        data1 = []
        for t in titles:
            d = data[t]
            if t == 'ainvs':
                data1.append(format_ainvs(d))
            elif t in ['torsion_generators', 'torsion_structure']:
                data1.append([eval(g) for g in d])
            elif t == 'x-coordinates_of_integral_points':
                data1.append(split_list(d))
            elif t == 'gens':
                data1.append(parse_points(d))
            elif t in ['iso', 'label', 'lmfdb_iso', 'lmfdb_label']:
                data1.append(str(d))
            else:
                data1.append(d)
        dump_data.append(data1)
    response = make_response('\n'.join(str(an) for an in dump_data))
    response.headers['Content-type'] = 'text/plain'
    return response
Exemplo n.º 5
0
def download_EC_all(label):
    CDB = lmfdb.base.getDBConnection().elliptic_curves.curves
    N, iso, number = split_lmfdb_label(label)
    if number:
        data = CDB.find_one({'lmfdb_label': label})
        if data is None:
            return elliptic_curve_jump_error(label, {})
        data_list = [data]
    else:
        data_list = sorted(list(CDB.find({'lmfdb_iso': label})), key=lambda E: E['number'])
        if len(data_list) == 0:
            return elliptic_curve_jump_error(label, {})

    # titles of all entries of curves
    dump_data = []
    titles = [str(c) for c in data_list[0]]
    titles = [t for t in titles if t[0] != '_']
    titles.sort()
    dump_data.append(titles)
    for data in data_list:
        data1 = []
        for t in titles:
            d = data[t]
            if t == 'ainvs':
                data1.append(format_ainvs(d))
            elif t in ['torsion_generators', 'torsion_structure']:
                data1.append([eval(g) for g in d])
            elif t == 'x-coordinates_of_integral_points':
                data1.append(split_list(d))
            elif t == 'gens':
                data1.append(parse_points(d))
            elif t in ['iso', 'label', 'lmfdb_iso', 'lmfdb_label']:
                data1.append(str(d))
            else:
                data1.append(d)
        dump_data.append(data1)
    response = make_response('\n'.join(str(an) for an in dump_data))
    response.headers['Content-type'] = 'text/plain'
    return response
Exemplo n.º 6
0
def download_EC_all(label):
    CDB = lmfdb.base.getDBConnection().elliptic_curves.curves
    N, iso, number = split_lmfdb_label(label)
    if number:
        data = CDB.find_one({"lmfdb_label": label})
        if data is None:
            return elliptic_curve_jump_error(label, {})
        data_list = [data]
    else:
        data_list = sorted(list(CDB.find({"lmfdb_iso": label})), key=lambda E: E["number"])
        if len(data_list) == 0:
            return elliptic_curve_jump_error(label, {})

    # titles of all entries of curves
    dump_data = []
    titles = [str(c) for c in data_list[0]]
    titles = [t for t in titles if t[0] != "_"]
    titles.sort()
    dump_data.append(titles)
    for data in data_list:
        data1 = []
        for t in titles:
            d = data[t]
            if t == "ainvs":
                data1.append(format_ainvs(d))
            elif t in ["torsion_generators", "torsion_structure"]:
                data1.append([eval(g) for g in d])
            elif t == "x-coordinates_of_integral_points":
                data1.append(split_list(d))
            elif t == "gens":
                data1.append(parse_points(d))
            elif t in ["iso", "label", "lmfdb_iso", "lmfdb_label"]:
                data1.append(str(d))
            else:
                data1.append(d)
        dump_data.append(data1)
    response = make_response("\n".join(str(an) for an in dump_data))
    response.headers["Content-type"] = "text/plain"
    return response
Exemplo n.º 7
0
def hgm_search(**args):
    info = to_dict(args)
    bread = get_bread([("Search results", url_for('.search'))])
    C = base.getDBConnection()
    query = {}
    if 'jump_to' in info:
        return render_hgm_webpage({'label': info['jump_to']})

    family_search = False
    if info.get('Submit Family') or info.get('family'):
        family_search = True

    # generic, irreducible not in DB yet
    for param in ['A', 'B', 'hodge', 'a2', 'b2', 'a3', 'b3', 'a5', 'b5', 'a7', 'b7']:
        if info.get(param):
            info[param] = clean_input(info[param])
            if IF_RE.match(info[param]):
                query[param] = split_list(info[param])
                query[param].sort()
            else:
                name = param
                if field == 'hodge':
                    name = 'Hodge vector'
                info['err'] = 'Error parsing input for %s.  It needs to be a list of integers in square brackets, such as [2,3] or [1,1,1]' % name
                return search_input_error(info, bread)

    if info.get('t') and not family_search:
        info['t'] = clean_input(info['t'])
        try:
            tsage = QQ(str(info['t']))
            tlist = [int(tsage.numerator()), int(tsage.denominator())]
            query['t'] = tlist
        except:
            info['err'] = 'Error parsing input for t.  It needs to be a rational number, such as 2/3 or -3'

    # sign can only be 1, -1, +1
    if info.get('sign') and not family_search:
        sign = info['sign']
        sign = re.sub(r'\s','',sign)
        sign = clean_input(sign)
        if sign == '+1':
            sign = '1'
        if not (sign == '1' or sign == '-1'):
            info['err'] = 'Error parsing input %s for sign.  It needs to be 1 or -1' % sign
            return search_input_error(info, bread)
        query['sign'] = int(sign)


    for param in ['degree','weight','conductor']:
        # We don't look at conductor in family searches
        if info.get(param) and not (param=='conductor' and family_search):
            if param=='conductor':
                cond = info['conductor']
                try:
                    cond = re.sub(r'(\d)\s+(\d)', r'\1 * \2', cond) # implicit multiplication of numbers
                    cond = cond.replace(r'..', r'-') # all ranges use -
                    cond = re.sub(r'[a..zA..Z]', '', cond)
                    cond = clean_input(cond)
                    tmp = parse_range2(cond, 'cond', myZZ)
                except:
                    info['err'] = 'Error parsing input for conductor.  It needs to be an integer (e.g., 8), a range of integers (e.g. 10-100), or a list of such (e.g., 5,7,8,10-100).  Integers may be given in factored form (e.g. 2^5 3^2) %s' % cond
                    return search_input_error(info, bread)
            else: # not conductor
                info[param] = clean_input(info[param])
                ran = info[param]
                ran = ran.replace(r'..', r'-')
                if LIST_RE.match(ran):
                    tmp = parse_range2(ran, param)
                else:
                    names = {'weight': 'weight', 'degree': 'degree'}
                    info['err'] = 'Error parsing input for the %s.  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 2,3,8 or 3-5, 7, 8-11).' % names[param]
                    return search_input_error(info, bread)
            # 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]

    #print query
    count_default = 20
    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
    if info.get('paging'):
        try:
            paging = int(info['paging'])
            if paging == 0:
                start = 0
        except:
            pass

    # logger.debug(query)
    if family_search:
        res = C.hgm.families.find(query).sort([('label', pymongo.ASCENDING)])
    else:
        res = C.hgm.motives.find(query).sort([('cond', pymongo.ASCENDING), ('label', pymongo.ASCENDING)])
    nres = res.count()
    res = res.skip(start).limit(count)

    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    info['motives'] = res
    info['number'] = nres
    info['start'] = start
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres
    info['make_label'] = make_abt_label
    info['make_t_label'] = make_t_label
    info['ab_label'] = ab_label
    info['display_t'] = display_t
    info['family'] = family_search
    info['factorint'] = factorint

    if family_search:
        return render_template("hgm-search.html", info=info, title="Hypergeometric Family over $\Q$ Search Result", bread=bread, credit=HGM_credit)
    else:
        return render_template("hgm-search.html", info=info, title="Hypergeometric Motive over $\Q$ Search Result", bread=bread, credit=HGM_credit)