Ejemplo n.º 1
0
def return_dimension(level=None, weight=None, chi=None, **kwds):
    if request.method == 'GET':
        info = to_dict(request.args)
    else:
        info = to_dict(request.form)
    level = my_get(info, 'level', level, int)
    weight = my_get(info, 'weight', weight, int)
    chi = my_get(info, 'chi', chi, int)
    if level is None or weight is None:
        return emf_error("Please supply level weight (and optional character)!"), 500
    ttype = my_get(kwds, 'ttype', info.get('ttype', 'new'), str)
    emf_logger.debug("level,weight,chi: {0},{1},{2}, type={3}".format(level, weight, chi, ttype))
    if chi == 0 or chi is None:
        x = level
    else:
        x = DirichletGroup(level).list()[chi]
    if ttype == 'new':
        return str(dimension_new_cusp_forms(x, weight))
    if ttype == 'cusp':
        return str(dimension_cusp_forms(x, weight))
    if ttype == 'modular':
        return str(dimension_modular_forms(x, weight))
    if ttype == 'eisenstein':
        return str(dimension_eis(x, weight))
    s = "Please use one of the available table types: 'new', 'cusp','modular', 'eisenstein' Got:{0}".format(
        ttype)
    return emf_error(s), 500
Ejemplo n.º 2
0
def character_search(**args):
    info = to_dict(args)
    for field in ["modulus", "conductor", "order"]:
        info[field] = info.get(field, "")
    query = {}
    if "natural" in args:
        label = info.get("natural", "")
        try:
            modulus = int(str(label).partition(".")[0])
            number = int(str(label).partition(".")[2])
        except ValueError:
            return "<span style='color:red;'>ERROR: bad query</span>"
        return redirect(url_character(type="Dirichlet", modulus=modulus, number=number))
    else:
        for field in ["modulus", "conductor", "order"]:
            if info.get(field):
                query[field] = parse_range(info[field])
        info["bread"] = [("Characters", "/Character"), ("search results", " ")]
        info["credit"] = "Sage"
        if len(query) != 0:
            from sage.modular.dirichlet import DirichletGroup

            info["contents"] = charactertable(query)
            info["title"] = "Dirichlet Characters"
            return render_template("character_search.html", **info)
        else:
            return "<span style='color:red;'>ERROR: bad query</span>"
def render_web_modform_space(level=None, weight=None, character=None, label=None, **kwds):
    r"""
    Render the webpage for a elliptic modular forms space.
    """
    emf_logger.debug("In render_elliptic_modular_form_space kwds: {0}".format(kwds))
    emf_logger.debug(
        "Input: level={0},weight={1},character={2},label={3}".format(level, weight, character, label))
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info = set_info_for_modular_form_space(**info)
    emf_logger.debug("keys={0}".format(info.keys()))
    if 'download' in kwds and 'error' not in kwds:
        return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'])
    if 'dimension_newspace' in kwds and kwds['dimension_newspace'] == 1:
        # if there is only one orbit we list it
        emf_logger.debug("Dimension of newforms is one!")
        info['label'] = 'a'
        return redirect(url_for('emf.render_elliptic_modular_forms', **info))
    info['title'] = "Newforms of weight %s for \(\Gamma_{0}(%s)\) with character \(\chi_{%s}(%s, \cdot)\)" % (weight, level, level, character)
    bread = [(EMF_TOP, url_for('emf.render_elliptic_modular_forms'))]
    bread.append(("Level %s" % level, url_for('emf.render_elliptic_modular_forms', level=level)))
    bread.append(
        ("Weight %s" % weight, url_for('emf.render_elliptic_modular_forms', level=level, weight=weight)))
    bread.append(
        ("Character \(\chi_{%s}(%s, \cdot)\)" % (level, character), url_for('emf.render_elliptic_modular_forms', level=level, weight=weight, character=character)))
    # emf_logger.debug("friends={0}".format(friends))
    info['bread'] = bread
    emf_logger.debug("info={0}".format(info))
    if info.has_key('space'):
        emf_logger.debug("space={0}".format(info['space']))        
        emf_logger.debug("dimension={0}".format(info['space'].dimension))    
    return render_template("emf_web_modform_space.html", **info)
Ejemplo n.º 4
0
def rational_elliptic_curves(err_args=None):
    if err_args is None:
        if len(request.args) != 0:
            return elliptic_curve_search(to_dict(request.args))
        else:
            err_args = {}
            for field in ['conductor', 'jinv', 'torsion', 'rank', 'sha', 'optimal', 'torsion_structure', 'msg']:
                err_args[field] = ''
            err_args['count'] = '100'
    counts = get_stats().counts()

    conductor_list_endpoints = [1, 100, 1000, 10000, 100000, counts['max_N'] + 1]
    conductor_list = ["%s-%s" % (start, end - 1) for start, end in zip(conductor_list_endpoints[:-1],
                                                                       conductor_list_endpoints[1:])]
    rank_list = range(counts['max_rank'] + 1)
    torsion_list = range(1,11) + [12, 16]
    info = {
        'rank_list': rank_list,
        'torsion_list': torsion_list,
        'conductor_list': conductor_list,
        'counts': counts,
        'stats_url': url_for(".statistics")
    }
    credit = 'John Cremona and Andrew Sutherland'
    t = 'Elliptic curves over $\Q$'
    bread = [('Elliptic Curves', url_for("ecnf.index")), ('$\Q$', ' ')]
    return render_template("ec-index.html", info=info, credit=credit, title=t, bread=bread, learnmore=learnmore_list_remove('Completeness'), **err_args)
Ejemplo n.º 5
0
def abelian_varieties_by_gq(g, q):
    D = to_dict(request.args)
    if 'g' not in D: D['g'] = g
    if 'q' not in D: D['q'] = q
    D['bread'] = get_bread((str(g), url_for(".abelian_varieties_by_g", g=g)),
                           (str(q), url_for(".abelian_varieties_by_gq", g=g, q=q)))
    return abelian_variety_search(D)
Ejemplo n.º 6
0
def number_field_render_webpage():
    args = to_dict(request.args)
    sig_list = sum([[[d - 2 * r2, r2] for r2 in range(
        1 + (d // 2))] for d in range(1, 7)], []) + sum([[[d, 0]] for d in range(7, 11)], [])
    sig_list = sig_list[:10]
    if len(args) == 0:
        init_nf_count()
        discriminant_list_endpoints = [-10000, -1000, -100, 0, 100, 1000, 10000]
        discriminant_list = ["%s..%s" % (start, end - 1) for start, end in zip(
            discriminant_list_endpoints[:-1], discriminant_list_endpoints[1:])]
        info = {
            'degree_list': range(1, max_deg + 1),
            'signature_list': sig_list,
            'class_number_list': range(1, 6) + ['6..10'],
            'count': '20',
            'nfields': comma(nfields),
            'maxdeg': max_deg,
            'discriminant_list': discriminant_list
        }
        t = 'Global Number Fields'
        bread = [('Global Number Fields', url_for(".number_field_render_webpage"))]
        info['learnmore'] = [(Completename, url_for(".render_discriminants_page")), ('How data was computed', url_for(".how_computed_page")), ('Global number field labels', url_for(".render_labels_page")), ('Galois group labels', url_for(".render_groups_page")), ('Quadratic imaginary class groups', url_for(".render_class_group_data"))]
        return render_template("number_field_all.html", info=info, credit=NF_credit, title=t, bread=bread, learnmore=info.pop('learnmore'))
    else:
        return number_field_search(args)
Ejemplo n.º 7
0
def review_recent(days):
    if len(request.args) > 0:
        try:
            info = to_dict(request.args)
            beta = None
            ID = info.get('review')
            if ID:
                beta = False
            else:
                ID = info.get('beta')
                if ID:
                    beta = True
            if beta is not None:
                k = Knowl(ID)
                k.review(who=current_user.get_id(), set_beta=beta)
                return jsonify({"success": 1})
            raise ValueError
        except Exception:
            return jsonify({"success": 0})
    knowls = knowldb.needs_review(days)
    for k in knowls:
        k.rendered = render_knowl(k.id, footer="0", raw=True, k=k)
        k.reviewed_content = json.dumps(k.reviewed_content)
        k.content = json.dumps(k.content)
    b = get_bread([("Reviewing Recent", url_for('.review_recent', days=days))])
    return render_template("knowl-review-recent.html",
                           title="Reviewing %s days of knowls" % days,
                           knowls=knowls,
                           bread=b)
Ejemplo n.º 8
0
def render_characterNavigation():
    """
    FIXME: replace query by ?browse=<key>&start=<int>&end=<int>
    """
    args = to_dict(request.args)
    info = {}
    info['bread'] = [ ('Characters',url_for(".render_characterNavigation")),
    ('Dirichlet', url_for(".render_Dirichletwebpage")) ]

    info['learnmore'] = learn()

    if 'modbrowse' in args:
        arg = args['modbrowse']
        arg = arg.split('-')
        modulus_start = int(arg[0])
        modulus_end = int(arg[1])
        info['title'] = 'Dirichlet Characters of Moduli ' + str(modulus_start) + '-' + str(modulus_end)
        info['credit'] = 'Sage'
        h, c, rows, cols = ListCharacters.get_character_modulus(modulus_start, modulus_end)
        info['contents'] = c
        info['headers'] = h
        info['rows'] = rows
        info['cols'] = cols
        return render_template("ModulusList.html", **info)

    elif 'condbrowse' in args:
        arg = args['condbrowse']
        arg = arg.split('-')
        conductor_start = int(arg[0])
        conductor_end = int(arg[1])
        info['conductor_start'] = conductor_start
        info['conductor_end'] = conductor_end
        info['title'] = 'Dirichlet Characters of Conductors ' + str(conductor_start) + \
            '-' + str(conductor_end)
        info['credit'] = "Sage"
        info['contents'] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
        # info['contents'] = c
        # info['header'] = h
        # info['rows'] = rows
        # info['cols'] = cols
        return render_template("ConductorList.html", **info)

    elif 'ordbrowse' in args:
        arg = args['ordbrowse']
        arg = arg.split('-')
        order_start = int(arg[0])
        order_end = int(arg[1])
        info['order_start'] = order_start
        info['order_end'] = order_end
        info['title'] = 'Dirichlet Characters of Orders ' + str(order_start) + '-' + str(order_end)
        info['credit'] = 'Sage'
        info['contents'] = ListCharacters.get_character_order(order_start, order_end + 1)
        return render_template("OrderList.html", **info)

    elif args != {}:
        return character_search(**args)

    else:
       info['title'] = 'Dirichlet Characters'
       return render_template('CharacterNavigate.html', **info)
def render_web_modform_space_gamma1(level=None, weight=None, character=None, label=None, **kwds):
    r"""
    Render the webpage for the space of elliptic modular forms on gamma1 as a table of spaces of spaces on gamma0 with associated characters.
    """
    emf_logger.debug("In render_elliptic_modular_form_space kwds: {0}".format(kwds))
    emf_logger.debug(
        "Input: level={0},weight={1},character={2},label={3}".format(level, weight, character, label))
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    title = "Newforms of weight {0} for \(\Gamma_1({1})\)".format(weight, level)
    bread = [(EMF_TOP, url_for('emf.render_elliptic_modular_forms'))]
    bread.append(("Level %s" % level, url_for("emf.render_elliptic_modular_forms", level=level)))
    bread.append(
        ("Weight %s" % weight, url_for("emf.render_elliptic_modular_forms", level=level, weight=weight)))
    info['grouptype'] = 1
    info['show_all_characters'] = 1
    table = set_info_for_gamma1(level,weight)
    if table is None:
        pass #info['error'] = 'The database does not currently contain any spaces matching these parameters!'
    else:
        info['table'] = table 
    info['bread'] = bread
    info['title'] = title
    info['showGaloisOrbits']=1
    emf_logger.debug("info={0}".format(info))
    return render_template("emf_render_web_modform_space_gamma1.html", **info)
Ejemplo n.º 10
0
def character_search(**args):
    info = to_dict(args)
    for field in ['modulus', 'conductor', 'order']:
        info[field] = info.get(field, '')
    query = {}
    if 'natural' in args:
        label = info.get('natural', '')
        try:
            modulus = int(str(label).partition('.')[0])
            number = int(str(label).partition('.')[2])
        except ValueError:
            return "<span style='color:red;'>ERROR: bad query</span>"
        return redirect(url_for('characters.render_Dirichletwebpage',modulus=modulus, number=number))
    else:
        for field in ['modulus', 'conductor', 'order']:
            if info.get(field):
                query[field] = parse_range(info[field])
        info['bread'] = [('Characters', url_for(".render_characterNavigation")),
                         ('Dirichlet', url_for(".render_Dirichletwebpage")),
                         ('search results', ' ') ]
        info['credit'] = 'Sage'
        if (len(query) != 0):
            from sage.modular.dirichlet import DirichletGroup
            info['contents'] = charactertable(query)
            info['title'] = 'Dirichlet Characters'
            return render_template("character_search.html", **info)
        else:
            return "<span style='color:red;'>ERROR: bad query</span>"
Ejemplo n.º 11
0
def getLfunctionPlot(request, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9):
    pythonL = generateLfunctionFromUrl(
        arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, to_dict(request.args))
    if not pythonL:
        return ""
    plotrange = 30
    if hasattr(pythonL, 'plotpoints'):
        F = p2sage(pythonL.plotpoints)
        plotrange = min(plotrange, F[-1][0]) #  F[-1][0] is the highest t-coordinated that we have a value for L
    else:
     # obsolete, because lfunc_data comes from DB?
        L = pythonL.sageLfunction
        if not hasattr(L, "hardy_z_function"):
            return None
        plotStep = .1
        if pythonL._Ltype not in ["riemann", "maass", "ellipticmodularform", "ellipticcurve"]:
            plotrange = 12
        F = [(i, L.hardy_z_function(i).real()) for i in srange(-1*plotrange, plotrange, plotStep)]
    interpolation = spline(F)
    F_interp = [(i, interpolation(i)) for i in srange(-1*plotrange, plotrange, 0.05)]
    p = line(F_interp)
#    p = line(F)    # temporary hack while the correct interpolation is being implemented

    styleLfunctionPlot(p, 10)
    fn = tempfile.mktemp(suffix=".png")
    p.save(filename=fn)
    data = file(fn).read()
    os.remove(fn)
    return data
Ejemplo n.º 12
0
def artin_representation_search(**args):
    info = to_dict(args)
    if 'natural' in info:
        label = info['natural']
        # test if it is ok
        try:
            label = parse_artin_label(label)
        except ValueError as err:
            flash(Markup("Error: %s" % (err)), "error")
            bread = get_bread([('Search results','')])
            return search_input_error({'err':''}, bread)
        return render_artin_representation_webpage(label)

    title = 'Artin representation search results'
    bread = [('Artin representation', url_for(".index")), ('Search results', ' ')]
    sign_code = 0
    query = {'Hide': 0}
    try:
        parse_primes(info,query,"unramified",name="Unramified primes",
                     qfield="BadPrimes",mode="complement",to_string=True)
        parse_primes(info,query,"ramified",name="Ramified primes",
                     qfield="BadPrimes",mode="append",to_string=True)
        parse_restricted(info,query,"root_number",qfield="GaloisConjugates.Sign",
                         allowed=[1,-1],process=int)
        parse_restricted(info,query,"frobenius_schur_indicator",qfield="Indicator",
                         allowed=[1,0,-1],process=int)
        parse_galgrp(info,query,"group",name="Group",qfield="Galois_nt",use_bson=False)
        parse_ints(info,query,'dimension',qfield='Dim')
        parse_ints(info,query,'conductor',qfield='Conductor_key', parse_singleton=make_cond_key)
        #parse_paired_fields(info,query,field1='conductor',qfield1='Conductor_key',parse1=parse_ints,kwds1={'parse_singleton':make_cond_key},
                                       #field2='dimension',qfield2='Dim', parse2=parse_ints)
    except ValueError:
        return search_input_error(info, bread)

    count = parse_count(info,10)
    start = parse_start(info)

    data = ArtinRepresentation.collection().find(query).sort([("Dim", ASC), ("Conductor_key", ASC)])
    nres = data.count()
    data = data.skip(start).limit(count)

    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0
    if nres == 1:
        report = 'unique match'
    else:
        if nres > count or start != 0:
            report = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres)
        else:
            report = 'displaying all %s matches' % nres
    if nres == 0:
        report = 'no matches'


    initfunc = ArtinRepresentation

    return render_template("artin-representation-search.html", req=info, data=data, title=title, bread=bread, query=query, start=start, report=report, nres=nres, initfunc=initfunc, sign_code=sign_code)
Ejemplo n.º 13
0
def abelian_variety_browse(**args):
    info = to_dict(args)
    if not('table_dimension_range' in info) or (info['table_dimension_range']==''):
        info['table_dimension_range'] = "1-6"
    if not('table_field_range' in info)  or (info['table_field_range']==''):
        info['table_field_range'] = "2-27"

    table_params = {}
    av_stats=AbvarFqStats()

    # Handle dimension range
    gs = av_stats.gs
    try:
        if ',' in info['table_dimension_range']:
            flash(Markup("Error: You cannot use commas in the table ranges."), "error")
            raise ValueError
        parse_ints(info,table_params,'table_dimension_range',qfield='g')
    except (ValueError, AttributeError, TypeError):
        gmin, gmax = 1, 6
    else:
        if isinstance(table_params['g'], int):
            gmin = gmax = table_params['g']
        else:
            gmin = table_params['g'].get('$gte',min(gs) if gs else table_params['g'].get('$lte',1))
            gmax = table_params['g'].get('$lte',max(gs) if gs else table_params['g'].get('$gte',20))

    # Handle field range
    qs = av_stats.qs
    try:
        if ',' in info['table_field_range']:
            flash(Markup("Error: You cannot use commas in the table ranges."), "error")
            raise ValueError
        parse_ints(info,table_params,'table_field_range',qfield='q')
    except (ValueError, AttributeError, TypeError):
        qmin, qmax = 2, 27
    else:
        if isinstance(table_params['q'], int):
            qmin = qmax = table_params['q']
        else:
            qmin = table_params['q'].get('$gte',min(qs) if qs else table_params['q'].get('$lte',0))
            qmax = table_params['q'].get('$lte',max(qs) if qs else table_params['q'].get('$gte',1000))
    info['table'] = defaultdict(lambda: defaultdict(int))
    if gmin == gmax:
        info['table_dimension_range'] = "{0}".format(gmin)
    else:
        info['table_dimension_range'] = "{0}-{1}".format(gmin, gmax)
    if qmin == qmax:
        info['table_field_range'] = "{0}".format(qmin)
    else:
        info['table_field_range'] = "{0}-{1}".format(qmin, qmax)

    for (g,q), cnt in av_stats._counts.items():
        if qmin <= q <= qmax and gmin <= g <= gmax:
            info['table'][q][g] = cnt

    info['col_heads'] = [q for q in qs if q >= qmin and q <= qmax]
    info['row_heads'] = [g for g in gs if g >= gmin and g <= gmax]

    return render_template("abvarfq-index.html", title="Isogeny Classes of Abelian Varieties over Finite Fields", info=info, credit=abvarfq_credit, bread=get_bread(), learnmore=learnmore_list())
Ejemplo n.º 14
0
def get_args_upload():
    r"""
    Extract parameters for upload data.
    Note: we need a "post" here
    """
    info = dict()
    if request.method == 'GET':
        info = to_dict(request.args)
        # print "req:get=", request.args
    else:
        info = to_dict(request.form)
        # print "req:post=", request.form
    # fix formatting of certain standard parameters
    info['files'] = request.files['file']
    tmp = get_format_for_file_to_db(info)
    info['format'] = tmp
    return info
Ejemplo n.º 15
0
def get_args(request, level=0, weight=0, character=-1, label='', keys=[]):
    r"""
    Use default input of the same type as desired output.
    """
    if request.method == 'GET':
        dd = to_dict(request.args)
    else:
        dd = to_dict(request.form)
    info = dict()
    info['level'] = my_get(dd, 'level', level, int)
    info['weight'] = my_get(dd, 'weight', weight, int)
    info['character'] = my_get(dd, 'character', character, int)
    info['label'] = my_get(dd, 'label', label, str)
    for key in keys:
        if key in dd:
            info[key] = my_get(dd, key, '', str)
    return info
Ejemplo n.º 16
0
def render_family_page(family, args, bread):
    sams = family.samples()
    forms = [ (k, [(f.name(), f.degree_of_field()) for f in sams if k == f.weight()]) for k in Set(f.weight() for f in sams)]
    info = { 'family': family, 'forms': forms, 'args': to_dict(args) }
    if family.computes_dimensions():
        build_dimension_table (info, family, args)
    bread.append(('$'+family.latex_name+'$', ''))
    return render_template("ModularForm_GSp4_Q_family.html", title='Siegel modular forms $'+family.latex_name+'$', bread=bread, info=info)
Ejemplo n.º 17
0
def modlmf_search(**args):
    C = getDBConnection()
    info = to_dict(args)  # what has been entered in the search boxes

    if 'download' in info:
        return download_search(info)

    if 'label' in info and info.get('label'):
        return modlmf_by_label(info.get('label'), C)
    query = {}
    try:
        for field, name in (('characteristic','Field characteristic'),('deg','Field degree'),('level', 'Level'),
                            ('conductor','Conductor'), ('weight_grading', 'Weight grading')):
            parse_ints(info, query, field, name)
    except ValueError as err:
        info['err'] = str(err)
        return search_input_error(info)

# miss search by character, search up to twists and gamma0, gamma1

    count = parse_count(info,50)
    start = parse_start(info)

    info['query'] = dict(query)
    res = C.mod_l_eigenvalues.modlmf.find(query).sort([('characteristic', ASC), ('deg', ASC), ('level', ASC), ('weight_grading', ASC)]).skip(start).limit(count)
    nres = res.count()

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

    info['number'] = nres
    info['start'] = int(start)
    info['more'] = int(start + count < nres)
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres == 0:
            info['report'] = 'no matches'
        else:
            if nres > count or start != 0:
                info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres)
            else:
                info['report'] = 'displaying all %s matches' % nres

    res_clean = []
    for v in res:
        v_clean = {}
        for m in ['label','characteristic','deg','level','weight_grading']:
            v_clean[m]=v[m]
        res_clean.append(v_clean)

    info['modlmfs'] = res_clean
    t = 'Mod &#x2113; Modular Forms Search Results'
    bread=[('Modular Forms', "/ModularForm"),('mod &#x2113;', url_for(".modlmf_render_webpage")),('Search Results', ' ')]
    properties = []
    return render_template("modlmf-search.html", info=info, title=t, properties=properties, bread=bread, learnmore=learnmore_list())
Ejemplo n.º 18
0
def artin_representation_search(**args):
    req = to_dict(args)
    title = 'Artin representations search results'
    bread = [('Artin representations', url_for(".index")), ('Search results', ' ')]
    query = {}
    if req.get("ramified", "") != "":
        tmp = req["ramified"].split(",")
        query["BadPrimes"] = {"$all": [str(x) for x in tmp]}
    if req.get("unramified", "") != "":
        tmp = req["unramified"].split(",")
        a = query.get("BadPrimes", {})
        a.update({"$not": {"$in": [str(x) for x in tmp]}})
        query["BadPrimes"] = a

    if req.get("root_number", "") != "":
        try:
            assert req["root_number"] in ["1", "-1"]
        except:
            raise AssertionError("The root number can only be 1 or -1")
        query["Sign"] = int(req["root_number"])

    if req.get("frobenius_schur_indicator", "") != "":
        try:
            assert req["frobenius_schur_indicator"] in ["1", "-1", "0"]
        except:
            raise AssertionError("The Frobenius-Schur indicator can only be 0, 1 or -1")
        query["Indicator"] = int(req["frobenius_schur_indicator"])

    tmp_conductor = []
    if req.get("conductor", "") != "":
        from utils import len_val_fn
        tmp_conductor = parse_compound(req["conductor"], fn=len_val_fn)
    # examples of tmp_conductor: [],
    # [{"len":2,"val":"44"},{"len":3,"val":"444"},{"$gte":{"len":2,"val":"44"},
    # "$lte":{"len":5,"val";"44444"}}]
    tmp_dimension = []
    if req.get("dimension", "") != "":
        tmp_dimension = parse_compound(req["dimension"], fn=int)
    # examples of tmp_dimension: [], [17], [5,7,{"$gte":4, "$lte":10}]
    tmp_both = [{"Conductor_plus": c, "Dim": d} for c in tmp_conductor for d in tmp_dimension]
    if len(tmp_conductor) == 0:
        tmp_both += [{"Dim": d} for d in tmp_dimension]
    if len(tmp_dimension) == 0:
        tmp_both += [{"Conductor_plus": c} for c in tmp_conductor]
    if len(tmp_both) == 1:
        query.update(tmp_both[0])
    elif len(tmp_both) >= 2:
        query["$or"] = tmp_both

    count = int(req.get('count', 20))

    for i in range(10):
        print query
    from pymongo import ASCENDING
    ArtinRepresentation.collection().ensure_index([("Dim", ASCENDING), ("Conductor_plus", ASCENDING)])
    data = [ArtinRepresentation(data=x) for x in ArtinRepresentation.collection(
    ).find(query).sort([("Dim", ASCENDING), ("Conductor_plus", ASCENDING)]).limit(count)]
    return render_template("artin-representation-search.html", req=req, data=data, data_count=len(data), title=title, bread=bread, query=query)
Ejemplo n.º 19
0
def draw_table(nrows=None, ncols=None, **kwds):
    if request.method == 'GET':
        info = to_dict(request.args)
    else:
        info = to_dict(request.form)
    ncols = my_get(info, 'ncols', ncols, int)
    nrows = my_get(info, 'nrows', nrows, int)
    if nrows is None or ncols is None:
        return emf_error("Please supply level weight (and optional character)!"), 500
    ttype = my_get(info, 'ttype', 'new', str)
    ttype = my_get(kwds, 'ttype', info.get('ttype'), str)
    info = to_dict(kwds)
    ttype = my_get(kwds, 'ttype', 'new', str)
    info['title'] = 'Title of table'
    info['ttype'] = ttype
    info['nrows'] = nrows
    info['ncols'] = ncols
    return render_template("emf_table2.html", **info)
Ejemplo n.º 20
0
def render_characterNavigation():
    """
    FIXME: replace query by ?browse=<key>&start=<int>&end=<int>
    """
    args = to_dict(request.args)
    info = {}
    info["bread"] = [("Characters", "/Character")]

    if "modbrowse" in args:
        arg = args["modbrowse"]
        arg = arg.split("-")
        modulus_start = int(arg[0])
        modulus_end = int(arg[1])
        info["title"] = "Dirichlet Characters of Moduli " + str(modulus_start) + "-" + str(modulus_end)
        info["credit"] = "Sage"
        h, c, rows, cols = ListCharacters.get_character_modulus(modulus_start, modulus_end)
        info["contents"] = c
        info["headers"] = h
        info["rows"] = rows
        info["cols"] = cols
        return render_template("ModulusList.html", **info)

    elif "condbrowse" in args:
        arg = args["condbrowse"]
        arg = arg.split("-")
        conductor_start = int(arg[0])
        conductor_end = int(arg[1])
        info["conductor_start"] = conductor_start
        info["conductor_end"] = conductor_end
        info["title"] = "Dirichlet Characters of Conductors " + str(conductor_start) + "-" + str(conductor_end)
        info["credit"] = "Sage"
        info["contents"] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
        # info['contents'] = c
        # info['header'] = h
        # info['rows'] = rows
        # info['cols'] = cols
        return render_template("ConductorList.html", **info)

    elif "ordbrowse" in args:
        arg = args["ordbrowse"]
        arg = arg.split("-")
        order_start = int(arg[0])
        order_end = int(arg[1])
        info["order_start"] = order_start
        info["order_end"] = order_end
        info["title"] = "Dirichlet Characters of Orders " + str(order_start) + "-" + str(order_end)
        info["credit"] = "Sage"
        info["contents"] = ListCharacters.get_character_order(order_start, order_end + 1)
        return render_template("OrderList.html", **info)

    elif args != {}:
        return character_search(**args)

    else:
        return render_template("CharacterNavigate.html", **info)
Ejemplo n.º 21
0
def by_conductor(cond):
    data = {}
    if len(request.args) > 0:
        # if changed conductor or discriminat, fall back to a general search
        if 'cond' in request.args and request.args['cond'] != str(cond):
            return redirect (url_for(".index", **request.args), 301)
        data = to_dict(request.args)
    data['cond'] = cond
    data['bread'] = (('Genus 2 Curves', url_for(".index")), ('$\Q$', url_for(".index_Q")), ('%s' % cond, '.'))
    data['title'] = 'Genus 2 Curve search results for conductor %s' % cond
    return genus2_curve_search(data=data, **request.args)
Ejemplo n.º 22
0
Archivo: main.py Proyecto: LMFDB/lmfdb
def by_url_belyi_search_group(group):
    info = to_dict(request.args)
    info['title'] = 'Belyi maps with group %s' % group
    info['bread'] = [('Belyi Maps', url_for(".index")), ('%s' % group, url_for(".by_url_belyi_search_group", group=group))]
    if len(request.args) > 0:
        # if the group changed, fall back to a general search
        if 'group' in request.args and request.args['group'] != str(group):
            return redirect (url_for(".index", **request.args), 307)
        info['title'] += ' search results'
        info['bread'].append(('search results',''))
    info['group'] = group
    return belyi_search(info)
Ejemplo n.º 23
0
def by_conductor(conductor):
    info = to_dict(request.args)
    info['bread'] = [('Elliptic Curves', url_for("ecnf.index")), ('$\Q$', url_for(".rational_elliptic_curves")), ('%s' % conductor, url_for(".by_conductor", conductor=conductor))]
    info['title'] = 'Elliptic Curves over $\Q$ of Conductor %s' % conductor
    if len(request.args) > 0:
        # if conductor changed, fall back to a general search
        if 'conductor' in request.args and request.args['conductor'] != str(conductor):
            return redirect (url_for(".rational_elliptic_curves", **request.args), 307)
        info['title'] += ' Search Results'
        info['bread'].append(('Search Results',''))
    info['conductor'] = conductor
    return elliptic_curve_search(info)
Ejemplo n.º 24
0
def get_args(request, level=0, weight=0, character=-1, group=2, label='', keys=[]):
    r"""
    Use default input of the same type as desired output.
    """
    if request.method == 'GET':
        dd = to_dict(request.args)
    else:
        dd = to_dict(request.form)
    emf_logger.debug("REQUEST:{0}".format(dd))
    info = dict()
    info['level'] = my_get(dd, 'level', level, int)
    info['weight'] = my_get(dd, 'weight', weight, int)
    info['character'] = my_get(dd, 'character', character, int)
    emf_logger.debug("group={0}".format(group))
    info['group'] = my_get(dd, 'group', group, int)
    emf_logger.debug("info[group]={0}".format(info['group']))
    info['label'] = my_get(dd, 'label', label, str)
    for key in keys:
        if key in dd:
            info[key] = my_get(dd, key, '', str)
    return info
Ejemplo n.º 25
0
Archivo: main.py Proyecto: koffie/lmfdb
def by_conductor(cond):
    data = to_dict(request.args)
    data['title'] = 'Genus 2 Curves of Conductor %s' % cond
    data['bread'] = [('Genus 2 Curves', url_for(".index")), ('$\Q$', url_for(".index_Q")), ('%s' % cond, url_for(".by_conductor", cond=cond))]
    if len(request.args) > 0:
        # if conductor changed, fall back to a general search
        if 'cond' in request.args and request.args['cond'] != str(cond):
            return redirect (url_for(".index", **request.args), 307)
        data['title'] += ' Search Results'
        data['bread'].append(('Search Results',''))
    data['cond'] = cond
    return genus2_curve_search(data)
Ejemplo n.º 26
0
Archivo: main.py Proyecto: LMFDB/lmfdb
def by_url_belyi_search_group_triple(group, abc):
    info = to_dict(request.args)
    info['title'] = 'Belyi maps with group %s and orders %s' % (group, abc)
    info['bread'] = [('Belyi Maps', url_for(".index")), ('%s' % group, url_for(".by_url_belyi_search_group", group=group)), ('%s' % abc, url_for(".by_url_belyi_search_group_triple", group=group, abc=abc)) ]
    if len(request.args) > 0:
        # if group or abc changed, fall back to a general search
        if 'group' in request.args and (request.args['group'] != str(group) or request.args['abc_list'] != str(abc)):
            return redirect(url_for(".index", **request.args), 307)
        info['title'] += ' search results'
        info['bread'].append(('search results',''))
    info['group'] = group
    info['abc_list'] = abc
    return belyi_search(info)
Ejemplo n.º 27
0
def abelian_varieties():
    args = request.args
    if args:
        info = to_dict(args)
        #information has been entered, but not requesting to change the parameters of the table
        if not('table_field_range' in info) and not('table_dimension_range' in info):
            return abelian_variety_search(**args)
        #information has been entered, requesting to change the parameters of the table
        else:
            return abelian_variety_browse(**args)
    # no information was entered
    else:
        return abelian_variety_browse(**args)
Ejemplo n.º 28
0
    def __call__(self, info):
        info = to_dict(info) # I'm not sure why this is required...
        for key, func in self.shortcuts.items():
            if info.get(key,'').strip():
                return func(info)
        query = {}
        template_kwds = {}
        for key in self.kwds:
            template_kwds[key] = info.get(key, self.kwds[key]())

        try:
            errpage = self.f(info, query)
        except ValueError as err:
            # Errors raised in parsing
            info['err'] = str(err)
            err_title = query.pop('__err_title__', self.err_title)
            return render_template(self.template, info=info, title=err_title, **template_kwds)
        if errpage is not None:
            return errpage
        if 'result_count' in info:
            nres = self.table.count(query)
            return jsonify({"nres":str(nres)})
        sort = query.pop('__sort__', None)
        table = query.pop('__table__', self.table)
        proj = query.pop('__projection__', self.projection)
        # We want to pop __title__ even if overridden by info.
        title = query.pop('__title__', self.title)
        title = info.get('title', title)
        template = query.pop('__template__', self.template)
        count = parse_count(info, self.per_page)
        start = parse_start(info)
        try:
            res = table.search(query, proj, limit=count, offset=start, sort=sort, info=info)
        except QueryCanceledError as err:
            ctx = ctx_proc_userdata()
            flash_error('The search query took longer than expected! Please help us improve by reporting this error  <a href="%s" target=_blank>here</a>.' % ctx['feedbackpage'])
            info['err'] = str(err)
            info['query'] = dict(query)
            return render_template(self.template, info=info, title=self.err_title, **template_kwds)
        else:
            if self.cleaners:
                for v in res:
                    for name, func in self.cleaners.items():
                        v[name] = func(v)
            if self.postprocess is not None:
                res = self.postprocess(res, info, query)
            for key, func in self.longcuts.items():
                if info.get(key,'').strip():
                    return func(res, info, query)
            info['results'] = res
            return render_template(template, info=info, title=title, **template_kwds)
Ejemplo n.º 29
0
def get_args_mwf(**kwds):
    get_params = ['level', 'weight', 'character', 'id', 'db', 'search',
                  'search_all', 'eigenvalue', 'browse',
                  'ev_skip', 'ev_range', 'maass_id', 'skip', 'limit',
                  'level_range', 'weight_range', 'ev_range', 'download']
    defaults = {'level': 0, 'weight': -1, 'character': 0, 'skip': 0, 'limit': 2000,
                'maass_id': None, 'search': None,
                'eigenvalue': None, 'browse': None}
    if request.method == 'GET':
        req = to_dict(request.args)
        #print "req:get=", request.args
    else:
        req = to_dict(request.form)
        #print "req:post=", request.form
    res = {}
    if kwds.get('parameters', []) != []:
        get_params.extend(kwds['parameters'])
    for key in get_params:
        if key in kwds or key in req or key in defaults:
            res[key] = req.get(key, kwds.get(key, defaults.get(key, None)))
            mwf_logger.debug("res[{0}]={1}:{2}:{3}".format(key,
                                                           kwds.get(key, None), req.get(key, None), res[key]))
    return res
Ejemplo n.º 30
0
def half_integral_weight_form_search(**args):
    C = getDBConnection()
    C.halfintegralmf.forms.ensure_index([('level', 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_hiwf_webpage(**args)
    query = {}
    for field in ['character', 'weight', 'level']:
        if info.get(field):
            if field == 'weight':
                query[field] = int(info[field])      
            elif field == 'character':
                query[field] = parse_field_string(info[field])
            elif field == 'label':
                query[field] = info[field]
            elif field == 'level':
                query[field] = int(info[field])
    
    info['query'] = dict(query)
    res = C.halfintegralmf.forms.find(query).sort([('level', pymongo.ASCENDING), ('label', pymongo.ASCENDING)])
    nres = res.count()
    count = 100
	
    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['level'] = v['level']
        v_clean['label'] = v['label']
        v_clean['weight'] = v['weight']
        v_clean['ch_lab']= v['character'].replace('.','/')
        v_clean['char']= "\chi_{"+v['character'].split(".")[0]+"}("+v['character'].split(".")[1]+",\cdot)"
	v_clean['dimension'] = v['dim']
        res_clean.append(v_clean)

    info['forms'] = res_clean

    t = 'Half Integral Weight Cusp Forms search results'
    bread = [('Half Integral Weight Cusp Forms', url_for(".half_integral_weight_form_render_webpage")),('Search results', ' ')]
    properties = []
    return render_template("half_integral_weight_form_search.html", info=info, title=t, properties=properties, bread=bread)
Ejemplo n.º 31
0
Archivo: main.py Proyecto: qfizik/lmfdb
def show_ecnf1(nf):
    if LABEL_RE.fullmatch(nf):
        nf, cond_label, iso_label, number = split_full_label(nf)
        return redirect(
            url_for(".show_ecnf",
                    nf=nf,
                    conductor_label=cond_label,
                    class_label=iso_label,
                    number=number), 301)
    if CLASS_LABEL_RE.fullmatch(nf):
        nf, cond_label, iso_label = split_class_label(nf)
        return redirect(
            url_for(".show_ecnf_isoclass",
                    nf=nf,
                    conductor_label=cond_label,
                    class_label=iso_label), 301)
    if not FIELD_RE.fullmatch(nf):
        return abort(404)
    try:
        nf_label, nf_pretty = get_nf_info(nf)
    except ValueError:
        return abort(404)
    if nf_label == '1.1.1.1':
        return redirect(url_for("ec.rational_elliptic_curves", **request.args),
                        301)
    info = to_dict(request.args, search_array=ECNFSearchArray())
    info['title'] = 'Elliptic curves over %s' % nf_pretty
    info['bread'] = [('Elliptic curves', url_for(".index")),
                     (nf_pretty, url_for(".show_ecnf1", nf=nf))]
    if len(request.args) > 0:
        # if requested field differs from nf, redirect to general search
        if 'field' in request.args and request.args['field'] != nf_label:
            return redirect(url_for(".index", **request.args), 307)
        info['title'] += ' Search results'
        info['bread'].append(('Search results', ''))
    info['field'] = nf_label
    return elliptic_curve_search(info)
Ejemplo n.º 32
0
def lattice_render_webpage():
    info = to_dict(request.args, search_array=LatSearchArray())
    if not request.args:
        maxs = lattice_summary_data()
        dim_list = list(range(1, 11, 1))
        max_class_number = 20
        class_number_list = list(range(1, max_class_number + 1, 1))
        det_list_endpoints = [1, 5000, 10000, 20000, 25000, 30000]
        det_list = [
            "%s-%s" % (start, end - 1) for start, end in zip(
                det_list_endpoints[:-1], det_list_endpoints[1:])
        ]
        name_list = [
            "A2", "Z2", "D3", "D3*", "3.1942.3884.56.1", "A5", "E8", "A14",
            "Leech"
        ]
        info.update({
            'dim_list': dim_list,
            'class_number_list': class_number_list,
            'det_list': det_list,
            'name_list': name_list
        })
        credit = lattice_credit
        t = 'Integral Lattices'
        bread = [('Lattice', url_for(".lattice_render_webpage"))]
        info['summary'] = lattice_summary()
        info['max_cn'] = maxs[0]
        info['max_dim'] = maxs[1]
        info['max_det'] = maxs[2]
        return render_template("lattice-index.html",
                               info=info,
                               credit=credit,
                               title=t,
                               learnmore=learnmore_list(),
                               bread=bread)
    else:
        return lattice_search(info)
Ejemplo n.º 33
0
def by_url_isogeny_class_discriminant(cond, alpha, disc):
    data = to_dict(request.args, search_array=G2CSearchArray())
    clabel = str(cond) + "." + alpha
    # if the isogeny class is not present in the database, return a 404 (otherwise title and bread crumbs refer to a non-existent isogeny class)
    if not db.g2c_curves.exists({"class": clabel}):
        return abort(404,
                     f"Genus 2 isogeny class {clabel} not found in database.")
    data[
        "title"] = f"Genus 2 curves in isogeny class {clabel} of discriminant {disc}"
    data["bread"] = get_bread([(f"{cond}", url_for(".by_conductor",
                                                   cond=cond)),
                               (
                                   f"{alpha}",
                                   url_for(".by_url_isogeny_class_label",
                                           cond=cond,
                                           alpha=alpha),
                               ),
                               (f"{disc}",
                                url_for(
                                    ".by_url_isogeny_class_discriminant",
                                    cond=cond,
                                    alpha=alpha,
                                    disc=disc,
                                ))])
    if len(request.args) > 0:
        # if conductor or discriminant changed, fall back to a general search
        if ("cond" in request.args and request.args["cond"] != str(cond)) or (
                "abs_disc" in request.args
                and request.args["abs_disc"] != str(disc)):
            return redirect(url_for(".index", **request.args), 307)
        data["title"] += " Search results"
        data["bread"].append(("Search results", ""))
    data["cond"] = cond
    data["class"] = clabel
    data["abs_disc"] = disc
    return genus2_curve_search(data)
Ejemplo n.º 34
0
def show_ecnf1(nf):
    if "-" in nf:
        try:
            nf, cond_label, iso_label, number = split_full_label(nf.strip())
        except ValueError:
            return redirect(url_for("ecnf.index"))
        return redirect(url_for(".show_ecnf", nf=nf, conductor_label=cond_label, class_label=iso_label, number=number), 301)
    try:
        nf_label, nf_pretty = get_nf_info(nf)
    except ValueError:
        return redirect(url_for(".index"))
    if nf_label == '1.1.1.1':
        return redirect(url_for("ec.rational_elliptic_curves", **request.args), 301)
    info = to_dict(request.args)
    info['title'] = 'Elliptic Curves over %s' % nf_pretty
    info['bread'] = [('Elliptic Curves', url_for(".index")), (nf_pretty, url_for(".show_ecnf1", nf=nf))]
    if len(request.args) > 0:
        # if requested field differs from nf, redirect to general search
        if 'field' in request.args and request.args['field'] != nf_label:
            return redirect (url_for(".index", **request.args), 307)
        info['title'] += ' Search Results'
        info['bread'].append(('Search Results',''))
    info['field'] = nf_label
    return elliptic_curve_search(info)
Ejemplo n.º 35
0
def show_ecnf_conductor(nf, conductor_label):
    conductor_label = unquote(conductor_label)
    if re.match(OLD_COND_RE, conductor_label):
        conductor_label = '.'.join(conductor_label[1:-1].split(','))
        return redirect(url_for('.show_ecnf_conductor',nf=nf,conductor_label=conductor_label),301)
    try:
        nf_label, nf_pretty = get_nf_info(nf)
        conductor_norm = conductor_label_norm(conductor_label)
    except ValueError:
        return search_input_error()
    info = to_dict(request.args)
    info['title'] = 'Elliptic Curves over %s of conductor %s' % (nf_pretty, conductor_label)
    info['bread'] = [('Elliptic Curves', url_for(".index")), (nf_pretty, url_for(".show_ecnf1", nf=nf)), (conductor_label, url_for(".show_ecnf_conductor",nf=nf,conductor_label=conductor_label))]
    if len(request.args) > 0:
        # if requested field or conductor norm differs from nf or conductor_lable, redirect to general search
        if ('field' in request.args and request.args['field'] != nf_label) or \
           ('conductor_norm' in request.args and request.args['conductor_norm'] != conductor_norm):
            return redirect (url_for(".index", **request.args), 307)
        info['title'] += ' search results'
        info['bread'].append(('search results',''))
    info['field'] = nf_label
    info['conductor_label'] = conductor_label
    info['conductor_norm'] = conductor_norm
    return elliptic_curve_search(info)
Ejemplo n.º 36
0
def rational_elliptic_curves(err_args=None):
    info = to_dict(request.args, search_array=ECSearchArray())
    if err_args is None:
        if request.args:
            return elliptic_curve_search(info)
        else:
            err_args = {}
            for field in ['conductor', 'jinv', 'torsion', 'rank', 'sha', 'optimal', 'torsion_structure', 'msg']:
                err_args[field] = ''
            err_args['count'] = '50'
    counts = get_stats().counts()

    conductor_list_endpoints = [1, 100, 1000, 10000, 100000, counts['max_N'] + 1]
    conductor_list = ["%s-%s" % (start, end - 1) for start, end in zip(conductor_list_endpoints[:-1],
                                                                       conductor_list_endpoints[1:])]
    rank_list = list(range(counts['max_rank'] + 1))
    torsion_list = list(range(1, 11)) + [12, 16]
    info['rank_list'] = rank_list
    info['torsion_list'] = torsion_list
    info['conductor_list'] = conductor_list
    info['counts'] = counts
    info['stats_url'] = url_for(".statistics")
    t = r'Elliptic Curves over $\Q$'
    bread = [('Elliptic Curves', url_for("ecnf.index")), (r'$\Q$', ' ')]
    if err_args.get("err_msg"):
        # this comes from elliptic_curve_jump_error
        flash_error(err_args.pop("err_msg"), err_args.pop("label"))
        return redirect(url_for(".rational_elliptic_curves"))
    return render_template("ec-index.html",
                           info=info,
                           credit=ec_credit(),
                           title=t,
                           bread=bread,
                           learnmore=learnmore_list(),
                           calling_function="ec.rational_elliptic_curves",
                           **err_args)
Ejemplo n.º 37
0
def number_field_render_webpage():
    args = to_dict(request.args)
    sig_list = sum([[[d - 2 * r2, r2] for r2 in range(1 + (d // 2))]
                    for d in range(1, 7)], []) + sum(
                        [[[d, 0]] for d in range(7, 11)], [])
    sig_list = sig_list[:10]
    if not args:
        init_nf_count()
        discriminant_list_endpoints = [
            -10000, -1000, -100, 0, 100, 1000, 10000
        ]
        discriminant_list = [
            "%s..%s" % (start, end - 1)
            for start, end in zip(discriminant_list_endpoints[:-1],
                                  discriminant_list_endpoints[1:])
        ]
        info = {
            'degree_list': list(range(1, max_deg + 1)),
            'signature_list': sig_list,
            'class_number_list': list(range(1, 6)) + ['6..10'],
            'count': '50',
            'nfields': comma(nfields),
            'maxdeg': max_deg,
            'discriminant_list': discriminant_list
        }
        t = 'Global number fields'
        bread = [('Global Number Fields',
                  url_for(".number_field_render_webpage"))]
        return render_template("nf-index.html",
                               info=info,
                               credit=NF_credit,
                               title=t,
                               bread=bread,
                               learnmore=learnmore_list())
    else:
        return number_field_search(args)
Ejemplo n.º 38
0
def by_url_isogeny_class_discriminant(cond, alpha, disc):
    data = {}
    if len(request.args) > 0:
        # if changed conductor or discriminat, fall back to a general search
        if ('cond' in request.args and request.args['cond'] != str(cond)) or \
           ('abs_disc' in request.args and request.args['abs_disc'] != str(disc)):
            return redirect(url_for(".index", **request.args), 301)
        data = to_dict(request.args)
    class_label = str(cond) + "." + alpha
    data['cond'] = cond
    data['class'] = class_label
    data['abs_disc'] = disc
    data['bread'] = (('Genus 2 Curves', url_for(".index")),
                     ('$\Q$', url_for(".index_Q")), ('%s' % cond,
                                                     url_for(".by_conductor",
                                                             cond=cond)),
                     ('%s' % alpha,
                      url_for(".by_url_isogeny_class_label",
                              cond=cond,
                              alpha=alpha)), ('%s' % disc, '.'))
    data[
        'title'] = 'Genus 2 Curve search results for isogeny class %s and discriminant %s' % (
            class_label, disc)
    return genus2_curve_search(data=data, **request.args)
Ejemplo n.º 39
0
def show_ecnf_conductor(nf, conductor_label):
    if not FIELD_RE.fullmatch(nf):
        return abort(404)
    conductor_label = unquote(conductor_label)
    conductor_label = convert_IQF_label(nf,conductor_label)
    try:
        nf_label, nf_pretty = get_nf_info(nf)
        conductor_norm = conductor_label_norm(conductor_label)
    except ValueError:
        return abort(404)
    info = to_dict(request.args, search_array=ECNFSearchArray())
    info['title'] = 'Elliptic curves over %s of conductor %s' % (nf_pretty, conductor_label)
    info['bread'] = [('Elliptic curves', url_for(".index")), (nf_pretty, url_for(".show_ecnf1", nf=nf)), (conductor_label, url_for(".show_ecnf_conductor",nf=nf,conductor_label=conductor_label))]
    if len(request.args) > 0:
        # if requested field or conductor norm differs from nf or conductor_lable, redirect to general search
        if ('field' in request.args and request.args['field'] != nf_label) or \
           ('conductor_norm' in request.args and request.args['conductor_norm'] != conductor_norm):
            return redirect (url_for(".index", **request.args), 307)
        info['title'] += ' Search results'
        info['bread'].append(('Search results',''))
    info['field'] = nf_label
    info['conductor_label'] = conductor_label
    info['conductor_norm'] = conductor_norm
    return elliptic_curve_search(info)
Ejemplo n.º 40
0
def abelian_varieties_by_g(g):
    D = to_dict(request.args, search_array=AbvarSearchArray())
    if "g" not in D:
        D["g"] = g
    D["bread"] = get_bread((str(g), url_for(".abelian_varieties_by_g", g=g)))
    return abelian_variety_search(D)
Ejemplo n.º 41
0
def galois_group_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_group_webpage({'label': info['jump_to']})

    for param in ['n', 't']:
        if info.get(param):
            info[param] = clean_input(info[param])
            ran = info[param]
            ran = ran.replace('..', '-')
            if LIST_RE.match(ran):
                tmp = parse_range2(ran, param)
            else:
                names = {'n': 'degree', 't': 't'}
                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]
    for param in ['cyc', 'solv', 'prim', 'parity']:
        if info.get(param):
            info[param] = str(info[param])
            if info[param] == str(1):
                query[param] = 1
            elif info[param] == str(-1):
                query[param] = -1 if param == 'parity' else 0

    # Determine if we have any composite degrees
    info['show_subs'] = True
    if info.get('n'):
        info[
            'show_subs'] = False  # now only show subs if a composite n is allowed
        nparam = info.get('n')
        nparam.replace('..', '-')
        nlist = nparam.split(',')
        found = False
        for nl in nlist:
            if '-' in nl:
                inx = nl.index('-')
                ll, hh = nl[:inx], nl[inx + 1:]
                hh = int(hh)
                jj = int(ll)
                while jj <= hh and not found:
                    if not (ZZ(jj).is_prime() or ZZ(jj) == 1):
                        found = True
                    jj += 1
                if found:
                    break
            else:
                jj = ZZ(nl)
                if not (ZZ(jj).is_prime() or ZZ(jj) == 1):
                    found = True
                    break
        if found:
            info['show_subs'] = True

    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

    res = C.transitivegroups.groups.find(query).sort([('n', pymongo.ASCENDING),
                                                      ('t', 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['groups'] = res
    info['group_display'] = group_display_shortC(C)
    info['report'] = "found %s groups" % nres
    info['yesno'] = yesno
    info['wgg'] = WebGaloisGroup.from_data
    info['start'] = start
    info['number'] = nres
    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

    return render_template("gg-search.html",
                           info=info,
                           title="Galois Group Search Result",
                           bread=bread,
                           credit=GG_credit)
Ejemplo n.º 42
0
def bmf_field_dim_table(**args):
    argsdict = to_dict(args)
    argsdict.update(to_dict(request.args))
    gl_or_sl = argsdict['gl_or_sl']

    field_label = argsdict['field_label']
    field_label = nf_string_to_label(field_label)

    start = 0
    if 'start' in argsdict:
        start = int(argsdict['start'])

    info = {}
    info['gl_or_sl'] = gl_or_sl
    # level_flag controls whether to list all levels ('all'), only
    # those with positive cuspidal dimension ('cusp'), or only those
    # with positive new dimension ('new').  Default is 'cusp'.
    level_flag = argsdict.get('level_flag', 'cusp')
    info['level_flag'] = level_flag
    count = 50
    if 'count' in argsdict:
        count = int(argsdict['count'])

    pretty_field_label = field_pretty(field_label)
    bread = [('Bianchi Modular Forms', url_for(".index")),
             (pretty_field_label, ' ')]
    properties = []
    if gl_or_sl == 'gl2_dims':
        info['group'] = 'GL(2)'
        info['bgroup'] = '\GL(2,\mathcal{O}_K)'
    else:
        info['group'] = 'SL(2)'
        info['bgroup'] = '\SL(2,\mathcal{O}_K)'
    t = ' '.join([
        'Dimensions of spaces of {} Bianchi modular forms over'.format(
            info['group']), pretty_field_label
    ])
    query = {}
    query['field_label'] = field_label
    query[gl_or_sl] = {'$exists': True}
    if level_flag != 'all':
        # find which weights are present (TODO: get this from a stats collection)
        wts = list(
            sum((Set(d.keys()) for d in db_dims().distinct(gl_or_sl)), Set()))
    if level_flag == 'cusp':
        # restrict the query to only return levels where at least one
        # cuspidal dimension is positive:
        query.update({
            '$or': [{
                gl_or_sl + '.{}.cuspidal_dim'.format(w): {
                    '$gt': 0
                }
            } for w in wts]
        })
    if level_flag == 'new':
        # restrict the query to only return levels where at least one
        # new dimension is positive:
        query.update({
            '$or': [{
                gl_or_sl + '.{}.new_dim'.format(w): {
                    '$gt': 0
                }
            } for w in wts]
        })
    data = db_dims().find(query)
    data = data.sort([('level_norm', ASCENDING)])
    info['number'] = nres = data.count()
    if nres > count or start != 0:
        info['report'] = 'Displaying items %s-%s of %s levels,' % (
            start + 1, min(nres, start + count), nres)
    else:
        info['report'] = 'Displaying all %s levels,' % nres

    data = list(data.skip(start).limit(count))
    info['field'] = field_label
    info['field_pretty'] = pretty_field_label
    nf = WebNumberField(field_label)
    info['base_galois_group'] = nf.galois_string()
    info['field_degree'] = nf.degree()
    info['field_disc'] = str(nf.disc())
    info['field_poly'] = teXify_pol(str(nf.poly()))
    weights = set()
    for dat in data:
        weights = weights.union(set(dat[gl_or_sl].keys()))
    weights = list([int(w) for w in weights])
    weights.sort()
    info['weights'] = weights
    info['nweights'] = len(weights)
    info['count'] = count
    info['start'] = start
    info['more'] = int(start + count < nres)

    dims = {}
    for dat in data:
        dims[dat['level_label']] = d = {}
        for w in weights:
            sw = str(w)
            if sw in dat[gl_or_sl]:
                d[w] = {
                    'd': dat[gl_or_sl][sw]['cuspidal_dim'],
                    'n': dat[gl_or_sl][sw]['new_dim']
                }
            else:
                d[w] = {'d': '?', 'n': '?'}
    info['nlevels'] = len(data)
    dimtable = [{
        'level_label':
        dat['level_label'],
        'level_norm':
        dat['level_norm'],
        'level_space':
        url_for(".render_bmf_space_webpage",
                field_label=field_label,
                level_label=dat['level_label'])
        if gl_or_sl == 'gl2_dims' else "",
        'dims':
        dims[dat['level_label']]
    } for dat in data]
    print("Length of dimtable = {}".format(len(dimtable)))
    info['dimtable'] = dimtable
    return render_template("bmf-field_dim_table.html",
                           info=info,
                           title=t,
                           properties=properties,
                           bread=bread)
Ejemplo n.º 43
0
def render_elliptic_modular_form_navigation_wp(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    from lmfdb.modular_forms.elliptic_modular_forms import WebModFormSpace
    dimension_table_name = WebModFormSpace._dimension_table_name

    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', None, int)
    weight = my_get(info, 'weight', None, int)
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    if ('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if isinstance(weight, int) and weight > 0:
        is_set['weight'] = True
        weight = int(weight)
    else:
        weight = None
        info.pop('weight', None)
    if isinstance(level, int) and level > 0:
        is_set['level'] = True
        level = int(level)
    else:
        level = None
        info.pop('level', None)
    ## This is the list of weights we initially put on the form
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page'))]
    bread.append((EMF_TOP, url_for('.render_elliptic_modular_forms')))
    if is_set['weight']:
        limits_weight = (weight, weight)
    elif limits_weight is None:
        limits_weight = (2, 12)  # default values
    if is_set['level']:
        limits_level = (level, level)
    elif limits_level is None:
        limits_level = (1, 24)  # default values
    try:
        group = info.get('group', 0)  # default group is gamma_0
        group = int(group)
    except ValueError:
        group = 0
    if group not in [0, 1]:
        group = 0
    if group == 0:
        info['grouptype'] = 0
        info['groupother'] = 1
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    emf_logger.debug("level:{0},level_range={1}".format(level, limits_level))
    emf_logger.debug("weight:{0},weight_range={1}".format(
        weight, limits_weight))
    # Special case: if the range reduces to a singleton for both level
    # and weight then we return a single page rather than a table:
    if limits_weight[0] == limits_weight[1] and limits_level[
            0] == limits_level[1]:
        return redirect(url_for("emf.render_elliptic_modular_forms",
                                level=limits_level[0],
                                weight=limits_weight[0],
                                group=group),
                        code=301)
    info['show_switch'] = True
    emf_logger.debug("dimension table name={0}".format(dimension_table_name))
    db_dim = getDBConnection()['modularforms2'][dimension_table_name]
    s = {
        'level': {
            "$lt": int(limits_level[1] + 1),
            "$gt": int(limits_level[0] - 1)
        },
        'weight': {
            "$lt": int(limits_weight[1] + 1),
            "$gt": int(limits_weight[0] - 1)
        }
    }
    if group == 0:
        s['cchi'] = int(1)
    else:
        s['gamma1_label'] = {"$exists": True}
    g = db_dim.find(s).sort([('level', int(1)), ('weight', int(1))])
    table = {}
    info['table'] = {}
    level_range = range(limits_level[0], limits_level[1] + 1)
    # we don't have weight 1 in database
    if limits_weight[0] == 1:
        limits_weight = (2, limits_weight[1])
    weight_range = range(limits_weight[0], limits_weight[1] + 1)
    if group == 0:
        weight_range = filter(is_even, weight_range)
    if len(weight_range) > 1:
        info['weight_range'] = "{0}-{1}".format(limits_weight[0],
                                                limits_weight[1])
    if len(level_range) > 1:
        info['level_range'] = "{0}-{1}".format(limits_level[0],
                                               limits_level[1])
    for n in level_range:
        info['table'][n] = {}
        for k in weight_range:
            info['table'][n][k] = {'dim_new': int(0), 'in_db': -1}
    for r in db_dim.find(s):
        N = r['level']
        k = r['weight']
        if group != 0 or k % 2 == 0:
            #emf_logger.debug("Found:k={0},N={1}".format(k,N))
            dim = r['d_newf']  # dimension of newforms
            info['table'][N][k]['dim_new'] = dim
            if group == 0:
                indb = r['in_wdb']  # 1 if it is in the webmodforms db else 0
            else:
                indb = r.get('one_in_wdb',
                             0)  # 1 if it is in the webmodforms db else 0
                if dim == 0:
                    indb = 1
            info['table'][N][k]['in_db'] = indb
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html",
                           info=info,
                           title=title,
                           bread=bread)
Ejemplo n.º 44
0
def render_sample_page(family, sam, args, bread):
    info = {
        'args': to_dict(args),
        'sam': sam,
        'latex': latex,
        'type': sam.type(),
        'name': sam.name(),
        'full_name': sam.full_name(),
        'weight': sam.weight(),
        'fdeg': sam.degree_of_field(),
        'is_eigenform': sam.is_eigenform(),
        'field_poly': sam.field_poly()
    }
    if sam.is_integral() != None:
        info['is_integral'] = sam.is_integral()
    if 'Sp4Z' in sam.collection():
        info['space_url'] = url_for('.Sp4Z_j_space', k=info['weight'], j=0)
    if 'Sp4Z_2' in sam.collection():
        info['space_url'] = url_for('.Sp4Z_j_space', k=info['weight'], j=2)
    info['space'] = '$' + family.latex_name.replace(
        'k', '{' + str(sam.weight()) + '}') + '$'
    if 'space_url' in info:
        bread.append((info['space'], info['space_url']))
    info['space_href'] = '<a href="%s">%s</d>' % (
        info['space_url'],
        info['space']) if 'space_url' in info else info['space']
    if info['field_poly'].disc() < 10**10:
        label = poly_to_field_label(info['field_poly'])
        if label:
            info['field_label'] = label
            info['field_url'] = url_for('number_fields.by_label', label=label)
            info['field_href'] = '<a href="%s">%s</a>' % (info['field_url'],
                                                          field_pretty(label))

    bread.append((info['name'], ''))
    title = 'Siegel modular forms sample ' + info['full_name']
    properties = [('Space', info['space_href']), ('Name', info['name']),
                  ('Type', '<br>'.join(info['type'].split(','))),
                  ('Weight', str(info['weight'])),
                  ('Hecke eigenform', str(info['is_eigenform'])),
                  ('Field degree', str(info['fdeg']))]
    try:
        evs_to_show = parse_ints_to_list_flash(args.get('ev_index'),
                                               'list of $l$')
        fcs_to_show = parse_ints_to_list_flash(args.get('fc_det'),
                                               'list of $\\det(F)$')
    except ValueError:
        evs_to_show = []
        fcs_to_show = []
    info['evs_to_show'] = sorted([
        n for n in
        (evs_to_show if len(evs_to_show) else sam.available_eigenvalues()[:10])
    ])
    info['fcs_to_show'] = sorted([
        n for n in (fcs_to_show if len(fcs_to_show) else sam.
                    available_Fourier_coefficients()[1:6])
    ])
    info['evs_avail'] = [n for n in sam.available_eigenvalues()]
    info['fcs_avail'] = [n for n in sam.available_Fourier_coefficients()]

    # Do not attempt to constuct a modulus ideal unless the field has a reasonably small discriminant
    # otherwise sage may not even be able to factor the discriminant
    info['field'] = sam.field()
    if info['field_poly'].disc() < 10**80:
        null_ideal = sam.field().ring_of_integers().ideal(0)
        info['modulus'] = null_ideal
        modulus = args.get('modulus', '').strip()
        m = 0
        if modulus:
            try:
                O = sam.field().ring_of_integers()
                m = O.ideal([O(str(b)) for b in modulus.split(',')])
            except Exception:
                info['error'] = True
                flash_error(
                    "Unable to construct modulus ideal from specified generators %s.",
                    modulus)
            if m == 1:
                info['error'] = True
                flash_error(
                    "The ideal %s is the unit ideal, please specify a different modulus.",
                    '(' + modulus + ')')
                m = 0
        info['modulus'] = m

        # Hack to reduce polynomials and to handle non integral stuff
        def redc(c):
            return m.reduce(c * c.denominator()) / m.reduce(c.denominator())

        def redp(f):
            c = f.dict()
            return f.parent()(dict((e, redc(c[e])) for e in c))

        def safe_reduce(f):
            if not m:
                return latex(f)
            try:
                if f in sam.field():
                    return latex(redc(f))
                else:
                    return latex(redp(f))
            except ZeroDivisionError:
                return '\\textrm{Unable to reduce} \\bmod\\mathfrak{m}'

        info['reduce'] = safe_reduce
    else:
        info['reduce'] = latex

    # check that explicit formula is not ridiculously big
    if sam.explicit_formula():
        info['explicit_formula_bytes'] = len(sam.explicit_formula())
        if len(sam.explicit_formula()) < 100000:
            info['explicit_formula'] = sam.explicit_formula()

    return render_template("ModularForm_GSp4_Q_sample.html",
                           title=title,
                           bread=bread,
                           properties2=properties,
                           info=info)
Ejemplo n.º 45
0
def dirichlet_table():
    args = to_dict(request.args)
    mod = args.get('modulus', 1)
    return redirect(url_for('characters.render_Dirichletwebpage', modulus=mod))
Ejemplo n.º 46
0
def render_DirichletNavigation():
    args = to_dict(request.args)

    info = {'args': args}
    info['bread'] = [('Characters', url_for(".render_characterNavigation")),
                     ('Dirichlet', url_for(".render_Dirichletwebpage"))]

    info['learnmore'] = learn()

    if 'modbrowse' in args:
        arg = args['modbrowse']
        arg = arg.split('-')
        modulus_start = int(arg[0])
        modulus_end = int(arg[1])
        info['title'] = 'Dirichlet Characters of Modulus ' + str(
            modulus_start) + '-' + str(modulus_end)
        info['credit'] = 'Sage'
        h, c, rows, cols = ListCharacters.get_character_modulus(
            modulus_start, modulus_end)
        info['contents'] = c
        info['headers'] = h
        info['rows'] = rows
        info['cols'] = cols
        return render_template("ModulusList.html", **info)

    elif 'condbrowse' in args:
        arg = args['condbrowse']
        arg = arg.split('-')
        conductor_start = int(arg[0])
        conductor_end = int(arg[1])
        info['conductor_start'] = conductor_start
        info['conductor_end'] = conductor_end
        info['title'] = 'Dirichlet Characters of Conductor ' + str(
            conductor_start) + '-' + str(conductor_end)
        info['credit'] = "Sage"
        info['contents'] = ListCharacters.get_character_conductor(
            conductor_start, conductor_end + 1)
        return render_template("ConductorList.html", **info)

    elif 'ordbrowse' in args:
        arg = args['ordbrowse']
        arg = arg.split('-')
        order_start = int(arg[0])
        order_end = int(arg[1])
        info['order_start'] = order_start
        info['order_end'] = order_end
        info['title'] = 'Dirichlet Characters of Orders ' + str(
            order_start) + '-' + str(order_end)
        info['credit'] = 'SageMath'
        info['contents'] = ListCharacters.get_character_order(
            order_start, order_end + 1)
        return render_template("OrderList.html", **info)

    elif 'label' in args:
        label = args['label'].replace(' ', '')
        if re.match(r'^[1-9][0-9]*\.[1-9][0-9]*$', label):
            slabel = label.split('.')
            m, n = int(slabel[0]), int(slabel[1])
            if m == n == 1 or n < m and gcd(m, n) == 1:
                return redirect(
                    url_for(".render_Dirichletwebpage",
                            modulus=slabel[0],
                            number=slabel[1]))
        if re.match(r'^[1-9][0-9]*\.[a-z]+$', label):
            slabel = label.split('.')
            return redirect(
                url_for(".render_Dirichletwebpage",
                        modulus=int(slabel[0]),
                        number=slabel[1]))
        if re.match(r'^[1-9][0-9]*$', label):
            return redirect(url_for(".render_Dirichletwebpage", modulus=label),
                            301)

        flash_error(
            "%s is not a valid label for a Dirichlet character.  It should be of the form <span style='color:black'>q.n</span>, where q and n are coprime positive integers with n < q, or q=n=1.",
            label)
        return render_template('CharacterNavigate.html', **info)

    if args:
        # if user clicked refine search, reset start to 0
        if args.get('refine'):
            args['start'] = '0'
        try:
            search = ListCharacters.CharacterSearch(args)
        except ValueError as err:
            info['err'] = str(err)
            return render_template(
                "CharacterNavigate.html" if "search" in args else
                "character_search_results.html", **info)
        info['info'] = search.results()
        info['title'] = 'Dirichlet Character Search Results'
        info['bread'] = [('Characters',
                          url_for(".render_characterNavigation")),
                         ('Dirichlet', url_for(".render_Dirichletwebpage")),
                         ('Search Results', '')]
        info['credit'] = 'SageMath'
        return render_template("character_search_results.html", **info)
    else:
        info['title'] = 'Dirichlet Characters'
        return render_template('CharacterNavigate.html', **info)
Ejemplo n.º 47
0
def galois_group_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_group_webpage({'label': info['jump_to']})

    def includes_composite(s):
        s = s.replace(' ', '').replace('..', '-')
        for interval in s.split(','):
            if '-' in interval[1:]:
                ix = interval.index('-', 1)
                a, b = int(interval[:ix]), int(interval[ix + 1:])
                if b == a:
                    if a != 1 and not a.is_prime():
                        return True
                if b > a and b > 3:
                    return True
            else:
                a = ZZ(interval)
                if a != 1 and not a.is_prime():
                    return True

    try:
        parse_ints(info, query, 'n', 'degree')
        parse_ints(info, query, 't')
        for param in ('cyc', 'solv', 'prim', 'parity'):
            parse_bool(info,
                       query,
                       param,
                       minus_one_to_zero=(param != 'parity'))
        degree_str = prep_ranges(info.get('n'))
        info['show_subs'] = degree_str is None or (
            LIST_RE.match(degree_str) and includes_composite(degree_str))
    except ValueError as err:
        info['err'] = str(err)
        return search_input_error(info, bread)

    count = parse_count(info, 50)
    start = parse_start(info)

    res = C.transitivegroups.groups.find(query).sort([('n', pymongo.ASCENDING),
                                                      ('t', 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['groups'] = res
    info['group_display'] = group_display_prettyC(C)
    info['report'] = "found %s groups" % nres
    info['yesno'] = yesno
    info['wgg'] = WebGaloisGroup.from_data
    info['start'] = start
    info['number'] = nres
    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

    return render_template("gg-search.html",
                           info=info,
                           title="Galois Group Search Result",
                           bread=bread,
                           credit=GG_credit)
Ejemplo n.º 48
0
def bmf_field_dim_table(**args):
    argsdict = to_dict(args)
    argsdict.update(to_dict(request.args))
    gl_or_sl = argsdict['gl_or_sl']

    field_label=argsdict['field_label']
    field_label = nf_string_to_label(field_label)

    start = 0
    if 'start' in argsdict:
        start = int(argsdict['start'])

    info={}
    info['gl_or_sl'] = gl_or_sl
    # level_flag controls whether to list all levels ('all'), only
    # those with positive cuspidal dimension ('cusp'), or only those
    # with positive new dimension ('new').  Default is 'cusp'.
    level_flag = argsdict.get('level_flag', 'cusp')
    info['level_flag'] = level_flag
    count = 50
    if 'count' in argsdict:
        count = int(argsdict['count'])

    pretty_field_label = field_pretty(field_label)
    bread = [('Bianchi Modular Forms', url_for(".index")), (
        pretty_field_label, ' ')]
    properties = []
    if gl_or_sl=='gl2_dims':
        info['group'] = 'GL(2)'
        info['bgroup'] = '\GL(2,\mathcal{O}_K)'
    else:
        info['group'] = 'SL(2)'
        info['bgroup'] = '\SL(2,\mathcal{O}_K)'
    t = ' '.join(['Dimensions of Spaces of {} Bianchi Modular Forms over'.format(info['group']), pretty_field_label])
    query = {}
    query['field_label'] = field_label
    query[gl_or_sl] = {'$exists': True}
    data = db_dims().find(query)
    data = data.sort([('level_norm', ASCENDING)])
    info['number'] = nres = data.count()
    if nres > count or start != 0:
        info['report'] = 'Displaying items %s-%s of %s levels,' % (start + 1, min(nres, start + count), nres)
    else:
        info['report'] = 'Displaying all %s levels,' % nres

    # convert data to a list and eliminate levels where all
    # new/cuspidal dimensions are 0.  (This could be done at the
    # search stage, but that requires adding new fields to each
    # record.)
    def filter(dat, flag):
        dat1 = dat[gl_or_sl]
        return any([int(dat1[w][flag])>0 for w in dat1])
    flag = 'cuspidal_dim' if level_flag=='cusp' else 'new_dim'
    data = [dat for dat in data if level_flag == 'all' or filter(dat, flag)]

    data = data[start:start+count]
    info['field'] = field_label
    info['field_pretty'] = pretty_field_label
    nf = WebNumberField(field_label)
    info['base_galois_group'] = nf.galois_string()
    info['field_degree'] = nf.degree()
    info['field_disc'] = str(nf.disc())
    info['field_poly'] = teXify_pol(str(nf.poly()))
    weights = set()
    for dat in data:
        weights = weights.union(set(dat[gl_or_sl].keys()))
    weights = list([int(w) for w in weights])
    weights.sort()
    info['weights'] = weights
    info['nweights'] = len(weights)
    info['count'] = count
    info['start'] = start
    info['more'] = int(start + count < nres)

    data.sort(key = lambda x: [int(y) for y in x['level_label'].split(".")])
    dims = {}
    for dat in data:
        dims[dat['level_label']] = d = {}
        for w in weights:
            sw = str(w)
            if sw in dat[gl_or_sl]:
                d[w] = {'d': dat[gl_or_sl][sw]['cuspidal_dim'],
                        'n': dat[gl_or_sl][sw]['new_dim']}
            else:
                d[w] = {'d': '?', 'n': '?'}
    info['nlevels'] = len(data)
    dimtable = [{'level_label': dat['level_label'],
                 'level_norm': dat['level_norm'],
                 'level_space': url_for(".render_bmf_space_webpage", field_label=field_label, level_label=dat['level_label']) if gl_or_sl=='gl2_dims' else "",
                  'dims': dims[dat['level_label']]} for dat in data]
    info['dimtable'] = dimtable
    return render_template("bmf-field_dim_table.html", info=info, title=t, properties=properties, bread=bread)
Ejemplo n.º 49
0
def browse_elliptic_modular_forms_ranges(**kwds):
    r"""
    Renders the webpage for browsing modular forms of given level and/or weight ranges.
    """
    emf_logger.debug("In browse_elliptic_modular_forms_ranges kwds: {0}".format(kwds))
    emf_logger.debug("args={0}".format(request.args))
    default = {}
    default['level'] = '1-12'
    default['weight'] = '2-36'
    default['character'] = 0
    info = dict()
    args = to_dict(request.args)
    emf_logger.debug("args={0}".format(args))
    for field in ['level', 'weight', 'character']:
        if args.get(field):
            info[field] = parse_range(args[field])
        else:
            info[field] = parse_range(default[field])
    if info['weight'] == 1:
        return render_template("not_available.html")
    elif (type(info['weight']) == dict) and info['weight'].get('min') == 1:
        info['weight']['min'] = 2
    emf_logger.debug("Input: info={0}".format(info))
    bread = [(MF_TOP, url_for('mf.modular_form_main_page'))]
    bread.append((EMF_TOP, url_for('emf.render_elliptic_modular_forms')))
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if limits_weight[0] == limits_weight[1] and limits_level[0] == limits_level[1]:
        return render_elliptic_modular_form_space_list_chars(limits_level[0], limits_weight[0])
    if limits_level[0] > N_max_db:
        emf_logger.debug("limits_level={0} > N_max_db={1}".format(limits_level, N_max_db))
        return render_template("not_available.html")
    if limits_weight[0] > k_max_db:
        emf_logger.debug("limits_weight={0} > k_max_db={1}".format(limits_weight, k_max_db))
        return render_template("not_available.html")
    if info['character'] == 0:
        info['grouptype'] = 0
        info['groupother'] = 1
        dimtbl = DimensionTable(0)
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
        dimtbl = DimensionTable(1)
        if info['character'] == -1:
            info['show_all_characters'] = 1
    disp = ClassicalMFDisplay('modularforms')
    disp.set_table_browsing(limit=[limits_weight, limits_level],
                            keys=['Weight', 'Level'], character=info['character'], dimension_table=dimtbl, title='Dimension of newforms')
    tbl = disp._table
    if tbl is None:
        return render_template("not_available.html")
    else:
        info['browse_table'] = tbl
    if limits_level[0] == limits_level[1]:
        drawdomain = False
        level = limits_level[0]
        if info['grouptype'] == 0 and level <= N_max_Gamma0_fdraw:
            drawdomain = True
        elif level <= N_max_Gamma1_fdraw:
            drawdomain = True
        info['geometric'] = get_geometric_data(level, info['grouptype'])
        if drawdomain:
            info['fd_plot_url'] = url_for('emf.render_plot', level=level, grouptype=info['grouptype'])
        title = "Newforms for \(\Gamma_{0}({1})\)".format(info['grouptype'], level)
        level = int(level)
        # info['list_spaces']=ajax_more(make_table_of_spaces_fixed_level,*largs,text='more')
        bread.append(("Level %s" % level, url_for("emf.render_elliptic_modular_forms", level=level)))
        info['browse_type'] = " of level %s " % level
        info['title'] = title
        info['bread'] = bread
        info['level'] = level
        return render_template("emf_browse_fixed_level.html", **info)
    title = "Newforms for \(\Gamma_{0}(N)\)".format(info['grouptype'])
    info['browse_type'] = ""
    info['title'] = title
    info['bread'] = bread
    # info['level']=level
    return render_template("emf_navigation.html", info=info, title=title, bread=bread)
Ejemplo n.º 50
0
def _series_index(query,
                  sort=None,
                  subsection=None,
                  conference=True,
                  past=False,
                  keywords="",
                  visible_counter=0):
    search_array = SeriesSearchArray(conference=conference, past=past)
    info = to_dict(read_search_cookie(search_array), search_array=search_array)
    info.update(request.args)
    if keywords:
        info["keywords"] = keywords
    query = dict(query)
    if conference:
        # Be permissive on end-date since we don't want to miss ongoing conferences, and we could have time zone differences.
        # Ignore the possibility that the user/conference is in Kiribati.
        recent = datetime.now().date() - timedelta(days=1)
        query["end_date"] = {"$lt" if past else "$gte": recent}
    query["visibility"] = 2  # only show public talks
    query[
        "display"] = True  # don't show talks created by users who have not been endorsed
    kw_query = query.copy()
    parse_substring(info, kw_query, "keywords", series_keyword_columns())
    org_query, more = {}, {}
    # we will be selecting talks satsifying the query and recording whether they satisfy the "more" query
    seminars_parser(info, more, org_query)
    results = list(
        seminars_search(kw_query,
                        organizer_dict=all_organizers(org_query),
                        more=more))
    if info.get("keywords", ""):
        parse_substring(info, org_query, "keywords",
                        organizers_keyword_columns())
        results += list(
            seminars_search(query,
                            organizer_dict=all_organizers(org_query),
                            more=more))
        unique = {s.shortname: s for s in results}
        results = [unique[key] for key in unique]
    series = series_sorted(results, conference=conference, reverse=past)
    counters = _get_counters(series)
    row_attributes = _get_row_attributes(series, visible_counter)
    response = make_response(
        render_template("browse_series.html",
                        title="Browse " + ("past " if past else "") +
                        ("conferences" if conference else "seminar series"),
                        section="Browse",
                        subsection=subsection,
                        info=info,
                        series_row_attributes=zip(series, row_attributes),
                        is_conference=conference,
                        past=past,
                        **counters))
    if request.cookies.get("topics", ""):
        # TODO: when we move cookie data to server with ajax calls, this will need to get updated again
        # For now we set the max_age to 30 years
        response.set_cookie("topics_dict",
                            topic_dag.port_cookie(),
                            max_age=60 * 60 * 24 * 365 * 30)
        response.set_cookie("topics", "", max_age=0)
    return response
Ejemplo n.º 51
0
def _talks_index(
    query={},
    sort=None,
    subsection=None,
    past=False,
    keywords="",
    limit=None,  # this is an upper bound on desired number of talks, we might filter some extra out
    limitbuffer=1000,  # the number of extra talks that we give ourselves to try to get the limit right
    asblock=False,  # the number of talks returned is based on star time blocks
    getcounters=True,  # doesn't limit the SQL search to get the full counters
    visible_counter=0,
    fully_filtered=True,
):
    # Eventually want some kind of cutoff on which talks are included.
    search_array = TalkSearchArray(past=past)
    info = to_dict(read_search_cookie(search_array), search_array=search_array)
    info.update(request.args)
    if keywords:
        info["keywords"] = keywords
    keywords = info.get("keywords", "")
    query = dict(query)
    parse_substring(info, query, "keywords", [
        "title", "abstract", "speaker", "speaker_affiliation", "seminar_id",
        "comments", "speaker_homepage", "paper_link"
    ])
    more = {
    }  # we will be selecting talks satsifying the query and recording whether they satisfy the "more" query
    # Note that talks_parser ignores the "time" field at the moment; see below for workaround
    talks_parser(info, more)
    if topdomain() == "mathseminars.org":
        query["topics"] = {"$contains": "math"}
    query["display"] = True
    query["hidden"] = {"$or": [False, {"$exists": False}]}
    query["audience"] = {"$lte": DEFAULT_AUDIENCE}
    now = datetime.now(pytz.UTC)
    if past:
        query["end_time"] = {"$lt": now}
        query["seminar_ctr"] = {"$gt": 0}  # don't show rescheduled talks
        if sort is None:
            sort = [("start_time", -1), "seminar_id"]
    else:
        query["end_time"] = {"$gte": now}
        if sort is None:
            sort = ["start_time", "seminar_id"]

    def dosearch(limit=limit, limitbuffer=limitbuffer):
        if limit and not getcounters:
            # we fetch extra talks to account for filtering
            talks = talks_search(query,
                                 sort=sort,
                                 seminar_dict=all_seminars(),
                                 more=more,
                                 limit=limit + limitbuffer)
        else:
            talks = talks_search(query,
                                 sort=sort,
                                 seminar_dict=all_seminars(),
                                 more=more)
        # Filtering on display and hidden isn't sufficient since the seminar could be private
        talks = [talk for talk in talks if talk.searchable()]
        return talks

    def truncateasblock(talks, retry=True):
        if not talks:
            return talks
        last_time = None
        # find enough talks such that the next talk has a different starting time
        for i, t in enumerate(talks):
            if last_time is None:
                last_time = t.start_time
                continue
            if t.start_time != last_time:
                if i > limit:
                    return talks[:i - 1]
                else:
                    last_time = t.start_time
        else:
            if retry and limit and not getcounters:
                # redo the search without limits
                talks = dosearch(limit=None)
                return truncateasblock(talks, retry=False)
            return talks

    def truncate(talks):
        if asblock and limit:
            return truncateasblock(talks)
        elif limit:
            return talks[:limit]
        else:
            return talks

    talks = dosearch()
    if getcounters:
        counters = _get_counters(talks)
    else:
        counters = _get_counters([])

    if getcounters and fully_filtered:
        # the initial query was not limited as getcounters = True
        # we will first filter after figuring out the more attribute
        # and then truncate
        pass
    else:
        # we are not going to filter or the query was already limited, so we can truncate
        talks = truncate(talks)
    # While we may be able to write a query specifying inequalities on the timestamp in the user's timezone, it's not easily supported by talks_search.  So we filter afterward
    timerange = info.get("timerange", "").strip()
    if timerange:
        tz = current_user.tz
        try:
            timerange = process_user_input(timerange,
                                           col="search",
                                           typ="daytimes")
        except ValueError:
            try:
                onetime = process_user_input(timerange,
                                             col="search",
                                             typ="daytime")
            except ValueError:
                flash_error("Invalid time range input: %s", timerange)
            else:
                for talk in talks:
                    if talk.more:
                        talkstart = adapt_datetime(talk.start_time, tz)
                        t = date_and_daytime_to_time(talkstart.date(), onetime,
                                                     tz)
                        talk.more = (t == talkstart)
        else:
            for talk in talks:
                if talk.more:
                    talkstart = adapt_datetime(talk.start_time, tz)
                    talkend = adapt_datetime(talk.end_time, tz)
                    t0, t1 = date_and_daytimes_to_times(
                        talkstart.date(), timerange, tz)
                    talk.more = (t0 <= talkstart) and (talkend <= t1)

    # get last_time before potential filtering
    last_time = int(talks[-1].start_time.timestamp()) if talks else None
    if fully_filtered:  # first filter then truncate
        row_attributes, talks = _get_row_attributes(talks, visible_counter,
                                                    fully_filtered)
        if getcounters:  # we have not yet truncated the results
            if limit and len(talks) > limit:
                talks = truncate(talks)
                row_attributes = row_attributes[:len(talks)]
                last_time = int(
                    talks[-1].start_time.timestamp()) if talks else None
    else:
        row_attributes = _get_row_attributes(talks, visible_counter)

    response = make_response(
        render_template("browse_talks.html",
                        title="Browse past talks" if past else "Browse talks",
                        section="Browse",
                        info=info,
                        subsection=subsection,
                        talk_row_attributes=zip(talks, row_attributes),
                        past=past,
                        last_time=last_time,
                        extraargs=urlencode({'keywords': keywords}),
                        **counters))
    if request.cookies.get("topics", ""):
        # TODO: when we move cookie data to server with ajax calls, this will need to get updated again
        # For now we set the max_age to 30 years
        response.set_cookie("topics_dict",
                            topic_dag.port_cookie(),
                            max_age=60 * 60 * 24 * 365 * 30)
        response.set_cookie("topics", "", max_age=0)

    # disable cache
    response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
    response.headers['Pragma'] = 'no-cache'
    return response
Ejemplo n.º 52
0
def lattice_search(**args):
    info = to_dict(args)  # what has been entered in the search boxes

    if 'download' in info:
        return download_search(info)

    if 'label' in info and info.get('label'):
        return lattice_by_label_or_name(info.get('label'))

    query = {}
    try:
        for field, name in (('dim','Dimension'),('det','Determinant'),('level',None),
                            ('minimum','Minimal vector length'), ('class_number',None), ('aut','Group order')):
            parse_ints(info, query, field, name)
        # Check if length of gram is triangular
        gram = info.get('gram')
        if gram and not (9 + 8*ZZ(gram.count(','))).is_square():
            flash(Markup("Error: <span style='color:black'>%s</span> is not a valid input for Gram matrix.  It must be a list of integer vectors of triangular length, such as [1,2,3]." % (gram)),"error")
            raise ValueError
        parse_list(info, query, 'gram', process=vect_to_sym)
    except ValueError as err:
        info['err'] = str(err)
        return search_input_error(info)

    count = parse_count(info,50)
    start = parse_start(info)

    info['query'] = dict(query)
    res = lattice_db().find(query).sort([('dim', ASC), ('det', ASC), ('level', ASC), ('class_number', ASC), ('label', ASC), ('minimum', ASC), ('aut', ASC)]).skip(start).limit(count)
    nres = res.count()

    # here we are checking for isometric lattices if the user enters a valid gram matrix but not one stored in the database_names, this may become slow in the future: at the moment we compare against list of stored matrices with same dimension and determinant (just compare with respect to dimension is slow)

    if nres==0 and info.get('gram'):
        A=query['gram'];
        n=len(A[0])
        d=matrix(A).determinant()
        result=[B for B in lattice_db().find({'dim': int(n), 'det' : int(d)}) if isom(A, B['gram'])]
        if len(result)>0:
            result=result[0]['gram']
            query_gram={ 'gram' : result }
            query.update(query_gram)
            res = lattice_db().find(query)
            nres = res.count()

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

    info['number'] = nres
    info['start'] = int(start)
    info['more'] = int(start + count < nres)
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres == 0:
            info['report'] = 'no matches'
        else:
            if nres > count or start != 0:
                info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres)
            else:
                info['report'] = 'displaying all %s matches' % nres

    res_clean = []
    for v in res:
        v_clean = {}
        v_clean['label']=v['label']
        v_clean['dim']=v['dim']
        v_clean['det']=v['det']
        v_clean['level']=v['level']
        v_clean['class_number']=v['class_number']
        v_clean['min']=v['minimum']
        v_clean['aut']=v['aut']

        res_clean.append(v_clean)

    info['lattices'] = res_clean

    t = 'Integral Lattices Search Results'
    bread = [('Lattices', url_for(".lattice_render_webpage")),('Search Results', ' ')]
    properties = []
    return render_template("lattice-search.html", info=info, title=t, properties=properties, bread=bread, learnmore=learnmore_list())
Ejemplo n.º 53
0
def higher_genus_w_automorphisms_search(**args):
    info = to_dict(args)
    bread = get_bread([("Search results", '')])
    C = base.getDBConnection()
    query = {}
    if 'jump_to' in info:
        labs = info['jump_to']
        if label_is_one_passport(labs):
            return render_passport({'passport_label': labs})
        elif label_is_one_family(labs):
            return render_family({'label': labs})
        else:
            flash_error(
                "The label %s is not a legitimate label for this data.", labs)
            return redirect(url_for(".index"))

    #allow for ; in signature
    if info.get('signature'):
        info['signature'] = info['signature'].replace(';', ',')

    try:
        parse_gap_id(info, query, 'group', 'Group')
        parse_ints(info, query, 'genus', name='Genus')
        parse_bracketed_posints(info,
                                query,
                                'signature',
                                split=False,
                                name='Signature',
                                keepbrackets=True)
        if query.get('signature'):
            query['signature'] = info['signature'] = str(
                sort_sign(ast.literal_eval(query['signature']))).replace(
                    ' ', '')
        parse_ints(info, query, 'dim', name='Dimension of the family')
        if 'inc_hyper' in info:
            if info['inc_hyper'] == 'exclude':
                query['hyperelliptic'] = False
            elif info['inc_hyper'] == 'only':
                query['hyperelliptic'] = True
        if 'inc_cyc_trig' in info:
            if info['inc_cyc_trig'] == 'exclude':
                query['cyclic_trigonal'] = False
            elif info['inc_cyc_trig'] == 'only':
                query['cyclic_trigonal'] = True
        if 'inc_full' in info:
            if info['inc_full'] == 'exclude':
                query['full_auto'] = {'$exists': True}
            elif info['inc_full'] == 'only':
                query['full_auto'] = {'$exists': False}

        query['cc.1'] = 1

    except ValueError:
        return search_input_error(info, bread)
    count = parse_count(info)
    start = parse_start(info)

    if 'groupsize' in info and info['groupsize'] != '':
        err, result = add_group_order_range(query, info['groupsize'], C)
        if err != None:
            flash_error(
                'Parse error on group order field. <font face="Courier New"><br />Given: '
                + err + '<br />-------' + result + '</font>')
    """
    res = C.curve_automorphisms.passports.find(query).sort([(
         'genus', pymongo.ASCENDING), ('dim', pymongo.ASCENDING),
        ('cc'[0],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


    L = [ ]
    for field in res:
        field['signature'] = ast.literal_eval(field['signature'])    
        L.append(field)

    code = ""
    download_code = 'download' in info
    first_download_entry = True
    for field in L:
        field['signature'] = ast.literal_eval(field['signature'])    
        if download_code:
            if first_download_entry:
                code += '\n'.join(hgcwa_code(label=field['passport_label'], download_type='magma').split('\n')[1:])
            else:
                code += hgcwa_code(label=field['passport_label'], download_type='magma').split('result_record:=[];')[1]
            first_download_entry = False

    
    

    if 'download' in info:
        response = make_response(code)
        response.headers['Content-type'] = 'text/plain'
        return response
    """

    res = C.curve_automorphisms.passports.find(query).sort([
        ('genus', pymongo.ASCENDING), ('dim', pymongo.ASCENDING),
        ('cc'[0], 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

    L = []
    for field in res:
        field['signature'] = ast.literal_eval(field['signature'])
        L.append(field)

    if 'download_magma' in info:
        code = "// MAGMA CODE FOR SEACH RESULTS\n\n"
        first_download_entry = True
        for field in L:
            #print field
            if first_download_entry:
                code += ('\n'.join(
                    hgcwa_code(label=field['passport_label'],
                               download_type='magma').split('\n')[1:]
                )).replace(
                    ", and generate data which is the same for all entries",
                    "")
            else:
                code += hgcwa_code(
                    label=field['passport_label'],
                    download_type='magma').split('result_record:=[];')[1]
            first_download_entry = False
        response = make_response(code)
        response.headers['Content-type'] = 'text/plain'
        return response
    elif 'download_gap' in info:
        code = "# GAP CODE FOR SEARCH RESULTS\n\n"
        first_download_entry = True
        for field in L:
            print field['group']
            if first_download_entry:
                code += ('\n'.join(
                    hgcwa_code(label=field['passport_label'],
                               download_type='gap').split('\n')
                    [1:])).replace(
                        "# Generate data which is the same for all entries.\n",
                        "")
            else:
                code += hgcwa_code(
                    label=field['passport_label'],
                    download_type='gap').split('result_record:=[];')[1]
            first_download_entry = False
        response = make_response(code)
        response.headers['Content-type'] = 'text/plain'
        return response

    info['fields'] = L
    info['number'] = nres
    info['group_display'] = sg_pretty
    info['show_downloads'] = len(L) > 0

    info['sign_display'] = sign_display
    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

    return render_template(
        "hgcwa-search.html",
        info=info,
        title=
        "Families of Higher Genus Curves with Automorphisms Search Result",
        credit=credit,
        bread=bread)
Ejemplo n.º 54
0
def set_info_for_web_newform(level=None,
                             weight=None,
                             character=None,
                             label=None,
                             **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info['label'] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(
            level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, 'prec', default_prec, int)
    bprec = my_get(info, 'bprec', default_display_bprec, int)
    emf_logger.debug("PREC: {0}".format(prec))
    emf_logger.debug("BITPREC: {0}".format(bprec))
    try:
        WNF = WebNewForm_cached(level=level,
                                weight=weight,
                                character=character,
                                label=label)
        emf_logger.critical("defined webnewform for rendering!")
        # if info.has_key('download') and info.has_key('tempfile'):
        #     WNF._save_to_file(info['tempfile'])
        #     info['filename']=str(weight)+'-'+str(level)+'-'+str(character)+'-'+label+'.sobj'
        #     return info
    except IndexError as e:
        WNF = None
        info['error'] = e.message
    url1 = url_for("emf.render_elliptic_modular_forms")
    url2 = url_for("emf.render_elliptic_modular_forms", level=level)
    url3 = url_for("emf.render_elliptic_modular_forms",
                   level=level,
                   weight=weight)
    url4 = url_for("emf.render_elliptic_modular_forms",
                   level=level,
                   weight=weight,
                   character=character)
    bread = [(EMF_TOP, url1)]
    bread.append(("of level %s" % level, url2))
    bread.append(("weight %s" % weight, url3))
    if int(character) == 0:
        bread.append(("trivial character", url4))
    else:
        bread.append(("\( %s \)" % (WNF.character.latex_name), url4))
    info['bread'] = bread

    properties2 = list()
    friends = list()
    space_url = url_for('emf.render_elliptic_modular_forms',
                        level=level,
                        weight=weight,
                        character=character)
    friends.append(
        ('\( S_{%s}(%s, %s)\)' %
         (WNF.weight, WNF.level, WNF.character.latex_name), space_url))
    if WNF.coefficient_field_label(check=True):
        friends.append(('Number field ' + WNF.coefficient_field_label(),
                        WNF.coefficient_field_url()))
    friends.append(
        ('Number field ' + WNF.base_field_label(), WNF.base_field_url()))
    friends = uniq(friends)
    friends.append(("Dirichlet character \(" + WNF.character.latex_name + "\)",
                    WNF.character.url()))

    if WNF.dimension == 0:
        info['error'] = "This space is empty!"


#    emf_logger.debug("WNF={0}".format(WNF))

#info['name'] = name
    info['title'] = 'Modular Form ' + WNF.hecke_orbit_label

    if 'error' in info:
        return info
    # info['name']=WNF._name
    ## Until we have figured out how to do the embeddings correctly we don't display the Satake
    ## parameters for non-trivial characters....

    cdeg = WNF.coefficient_field.absolute_degree()
    bdeg = WNF.base_ring.absolute_degree()
    if WNF.coefficient_field.absolute_degree() == 1:
        rdeg = 1
    else:
        rdeg = WNF.coefficient_field.relative_degree()
    if cdeg == 1:
        info['satake'] = WNF.satake
    info['qexp'] = WNF.q_expansion_latex(prec=10, name='a')
    info['qexp_display'] = url_for(".get_qexp_latex",
                                   level=level,
                                   weight=weight,
                                   character=character,
                                   label=label)

    # info['qexp'] = WNF.q_expansion_latex(prec=prec)
    #c_pol_st = str(WNF.absolute_polynomial)
    #b_pol_st = str(WNF.polynomial(type='base_ring',format='str'))
    #b_pol_ltx = str(WNF.polynomial(type='base_ring',format='latex'))
    #print "c=",c_pol_ltx
    #print "b=",b_pol_ltx
    if cdeg > 1:  ## Field is QQ
        if bdeg > 1 and rdeg > 1:
            p1 = WNF.coefficient_field.relative_polynomial()
            c_pol_ltx = latex(p1)
            lgc = p1.variables()[0]
            c_pol_ltx = c_pol_ltx.replace(lgc, 'a')
            z = p1.base_ring().gens()[0]
            p2 = z.minpoly()
            b_pol_ltx = latex(p2)
            b_pol_ltx = b_pol_ltx.replace(latex(p2.variables()[0]), latex(z))
            info['polynomial_st'] = 'where \({0}=0\) and \({1}=0\).'.format(
                c_pol_ltx, b_pol_ltx)
        else:
            c_pol_ltx = latex(WNF.coefficient_field.relative_polynomial())
            lgc = str(
                latex(WNF.coefficient_field.relative_polynomial().variables()
                      [0]))
            c_pol_ltx = c_pol_ltx.replace(lgc, 'a')
            info['polynomial_st'] = 'where \({0}=0\)'.format(c_pol_ltx)
    else:
        info['polynomial_st'] = ''
    info['degree'] = int(cdeg)
    if cdeg == 1:
        info['is_rational'] = 1
    else:
        info['is_rational'] = 0
    # info['q_exp_embeddings'] = WNF.print_q_expansion_embeddings()
    # if(int(info['degree'])>1 and WNF.dimension()>1):
    #    s = 'One can embed it into \( \mathbb{C} \) as:'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # elif(int(info['degree'])>1):
    #    s = 'There are '+str(info['degree'])+' embeddings into \( \mathbb{C} \):'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # else:
    #    info['embeddings'] = ''
    emf_logger.debug("PREC2: {0}".format(prec))
    info['embeddings'] = WNF._embeddings[
        'values']  #q_expansion_embeddings(prec, bprec,format='latex')
    info['embeddings_len'] = len(info['embeddings'])
    properties2 = []
    if (ZZ(level)).is_squarefree():
        info['twist_info'] = WNF.twist_info
        if isinstance(info['twist_info'],
                      list) and len(info['twist_info']) > 0:
            info['is_minimal'] = info['twist_info'][0]
            if (info['twist_info'][0]):
                s = '- Is minimal<br>'
            else:
                s = '- Is a twist of lower level<br>'
            properties2 = [('Twist info', s)]
    else:
        info['twist_info'] = 'Twist info currently not available.'
        properties2 = [('Twist info', 'not available')]
    args = list()
    for x in range(5, 200, 10):
        args.append({'digits': x})
    alev = None
    CM = WNF._cm_values
    if CM is not None:
        if CM.has_key('tau') and len(CM['tau']) != 0:
            info['CM_values'] = CM
    info['is_cm'] = WNF.is_cm
    if WNF.is_cm is None:
        s = '- Unknown (insufficient data)<br>'
    elif WNF.is_cm is True:
        s = '- Is a CM-form<br>'
    else:
        s = '- Is not a CM-form<br>'
    properties2.append(('CM info', s))
    alev = WNF.atkin_lehner_eigenvalues()
    info['atkinlehner'] = None
    if isinstance(alev, dict) and len(alev.keys()) > 0 and level != 1:
        s1 = " Atkin-Lehner eigenvalues "
        s2 = ""
        for Q in alev.keys():
            s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
        properties2.append((s1, s2))
        emf_logger.debug("properties={0}".format(properties2))
        # alev = WNF.atkin_lehner_eigenvalues_for_all_cusps()
        # if isinstance(alev,dict) and len(alev.keys())>0:
        #     emf_logger.debug("alev={0}".format(alev))
        #     info['atkinlehner'] = list()
        #     for Q in alev.keys():
        #         s = "\(" + latex(c) + "\)"
        #         Q = alev[c][0]
        #         ev = alev[c][1]
        #         info['atkinlehner'].append([Q, c, ev])
    if (level == 1):
        poly = WNF.explicit_formulas.get('as_polynomial_in_E4_and_E6', '')
        if poly <> '':
            d, monom, coeffs = poly
            emf_logger.critical("poly={0}".format(poly))

            info['explicit_formulas'] = '\('
            for i in range(d):
                c = QQ(coeffs[i])
                s = ""
                if d > 1 and i > 0 and c > 0:
                    s = "+"
                if c < 0:
                    s = "-"
                if c.denominator() > 1:
                    cc = "\\frac{{ {0} }}{{ {1} }}".format(
                        abs(c.numerator()), c.denominator())
                else:
                    cc = str(abs(c))
                s += "{0} \cdot ".format(cc)
                a = monom[i][0]
                b = monom[i][1]
                if a == 0 and b <> 0:
                    s += "E_6^{{ {0} }}".format(b)
                elif b == 0 and a <> 0:
                    s += "E_4^{{ {0} }}".format(a)
                else:
                    s += "E_4^{{ {0} }}E_6^{{ {1} }}".format(a, b)
                info['explicit_formulas'] += s
            info['explicit_formulas'] += " \)"
    cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + \
        '&label=' + str(label)
    if len(WNF.parent.hecke_orbits) > 1:
        for label_other in WNF.parent.hecke_orbits.keys():
            if (label_other != label):
                s = 'Modular form '
                if character:
                    s = s + str(level) + '.' + str(weight) + '.' + str(
                        character) + str(label_other)
                else:
                    s = s + str(level) + '.' + str(weight) + str(label_other)
                url = url_for('emf.render_elliptic_modular_forms',
                              level=level,
                              weight=weight,
                              character=character,
                              label=label_other)
                friends.append((s, url))

    s = 'L-Function '
    if character:
        s = s + str(level) + '.' + str(weight) + '.' + str(character) + str(
            label)
    else:
        s = s + str(level) + '.' + str(weight) + str(label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = '/L' + url_for('emf.render_elliptic_modular_forms',
                         level=level,
                         weight=weight,
                         character=character,
                         label=label)
    if WNF.coefficient_field_degree > 1:
        for h in range(WNF.coefficient_field_degree):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight == 2 and WNF.coefficient_field_degree == 1:
        llabel = str(level) + '.' + label
        s = 'Elliptic curve isogeny class ' + llabel
        url = '/EllipticCurve/Q/' + llabel
        friends.append((s, url))
    info['properties2'] = properties2
    info['friends'] = friends
    info['max_cn'] = WNF.max_cn()
    return info
Ejemplo n.º 55
0
def bianchi_modular_form_search(**args):
    """Function to handle requests from the top page, either jump to one
    newform or do a search.
    """
    info = to_dict(args)  # what has been entered in the search boxes
    if 'label' in info:
        # The Label button has been pressed.
        return bianchi_modular_form_by_label(info['label'])

    query = {}
    for field in ['field_label', 'weight', 'level_norm', 'dimension']:
        if info.get(field):
            if field == 'weight':
                query['weight'] = info[field]
            elif field == 'field_label':
                parse_nf_string(info, query, field, 'base number field', field)
            elif field == 'label':
                query[field] = info[field]
            elif field == 'dimension':
                query['dimension'] = int(info[field])
            elif field == 'level_norm':
                query[field] = parse_range(info[field])
            else:
                query[field] = info[field]

    if not 'sfe' in info:
        info['sfe'] = "any"
    elif info['sfe'] != "any":
        query['sfe'] = int(info['sfe'])
    if 'include_cm' in info:
        if info['include_cm'] == 'exclude':
            query['CM'] = 0
        elif info['include_cm'] == 'only':
            query['CM'] = {'$nin': [0, '?']}
    if 'include_base_change' in info and info['include_base_change'] == 'off':
        query['bc'] = 0
    else:
        info['include_base_change'] = "on"

    start = 0
    if 'start' in request.args:
        start = int(request.args['start'])
    count = 50
    if 'count' in request.args:
        count = int(request.args['count'])

    info['query'] = dict(query)
    res = db_forms().find(query).sort([('level_norm', ASCENDING),
                                       ('label', ASCENDING)
                                       ]).skip(start).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'
    elif nres == 2:
        info['report'] = 'displaying both matches'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying items %s-%s of %s matches' % (
                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['level_label'] = v['level_label']
        v_clean['label_suffix'] = v['label_suffix']
        v_clean['label'] = v['label']
        v_clean['level_ideal'] = teXify_pol(v['level_ideal'])
        v_clean['dimension'] = v['dimension']
        v_clean['sfe'] = "+1" if v['sfe'] == 1 else "-1"
        v_clean['url'] = url_for('.render_bmf_webpage',
                                 field_label=v['field_label'],
                                 level_label=v['level_label'],
                                 label_suffix=v['label_suffix'])
        v_clean['bc'] = bc_info(v['bc'])
        v_clean['cm'] = cm_info(v['CM'])
        res_clean.append(v_clean)

    info['forms'] = res_clean
    info['count'] = count
    info['start'] = start
    info['more'] = int(start + count < nres)

    t = 'Bianchi modular form search results'

    bread = [('Bianchi Modular Forms', url_for(".index")),
             ('Search results', ' ')]
    properties = []
    return render_template("bmf-search_results.html",
                           info=info,
                           title=t,
                           properties=properties,
                           bread=bread,
                           learnmore=learnmore_list())
Ejemplo n.º 56
0
def index():
    #    if 'jump' in request.args:
    #        return show_ecnf1(request.args['label'])
    info = to_dict(request.args,
                   search_array=ECNFSearchArray(),
                   stats=ECNF_stats())
    if request.args:
        return elliptic_curve_search(info)
    bread = get_bread()

    # the dict data will hold additional information to be displayed on
    # the main browse and search page

    # info['fields'] holds data for a sample of number fields of different
    # signatures for a general browse:

    info['fields'] = []
    # Rationals
    # info['fields'].append(['the rational field', (('1.1.1.1', [url_for('ec.rational_elliptic_curves'), '$\Q$']),)]) # Removed due to ambiguity

    # Real quadratics (sample)
    rqfs = [
        '2.2.{}.1'.format(d) for d in [8, 12, 5, 24, 28, 40, 44, 13, 56, 60]
    ]
    info['fields'].append([
        'By <a href="{}">real quadratic field</a>'.format(
            url_for('.statistics_by_signature', d=2, r=2)),
        ((nf, [url_for('.show_ecnf1', nf=nf),
               field_pretty(nf)]) for nf in rqfs)
    ])

    # Imaginary quadratics (sample)
    iqfs = [
        '2.0.{}.1'.format(d)
        for d in [4, 8, 3, 7, 11, 19, 43, 67, 163, 23, 31]
    ]
    info['fields'].append([
        'By <a href="{}">imaginary quadratic field</a>'.format(
            url_for('.statistics_by_signature', d=2, r=0)),
        ((nf, [url_for('.show_ecnf1', nf=nf),
               field_pretty(nf)]) for nf in iqfs)
    ])

    # Cubics (sample)
    cubics = ['3.1.23.1'] + [
        '3.3.{}.1'.format(d) for d in [49, 81, 148, 169, 229, 257, 316]
    ]
    info['fields'].append([
        'By <a href="{}">cubic field</a>'.format(
            url_for('.statistics_by_degree', d=3)),
        ((nf, [url_for('.show_ecnf1', nf=nf),
               field_pretty(nf)]) for nf in cubics)
    ])

    # Quartics (sample)
    quartics = [
        '4.4.{}.1'.format(d)
        for d in [725, 1125, 1600, 1957, 2000, 2048, 2225, 2304]
    ]
    info['fields'].append([
        'By <a href="{}">totally real quartic field</a>'.format(
            url_for('.statistics_by_degree', d=4)),
        ((nf, [url_for('.show_ecnf1', nf=nf),
               field_pretty(nf)]) for nf in quartics)
    ])

    # Quintics (sample)
    quintics = [
        '5.5.{}.1'.format(d)
        for d in [14641, 24217, 36497, 38569, 65657, 70601, 81509]
    ]
    info['fields'].append([
        'By <a href="{}">totally real quintic field</a>'.format(
            url_for('.statistics_by_degree', d=5)),
        ((nf, [url_for('.show_ecnf1', nf=nf),
               field_pretty(nf)]) for nf in quintics)
    ])

    # Sextics (sample)
    sextics = [
        '6.6.{}.1'.format(d)
        for d in [300125, 371293, 434581, 453789, 485125, 592661, 703493]
    ]
    info['fields'].append([
        'By <a href="{}">totally real sextic field</a>'.format(
            url_for('.statistics_by_degree', d=6)),
        ((nf, [url_for('.show_ecnf1', nf=nf),
               field_pretty(nf)]) for nf in sextics)
    ])

    return render_template("ecnf-index.html",
                           title="Elliptic curves over number fields",
                           info=info,
                           bread=bread,
                           learnmore=learnmore_list())
Ejemplo n.º 57
0
def elliptic_curve_search(**args):
    info = to_dict(args)
    query = {}
    bread = [('Elliptic Curves', url_for(".rational_elliptic_curves")),
             ('Search Results', '.')]
    if 'jump' in args:
        label = info.get('label', '').replace(" ", "")
        m = lmfdb_label_regex.match(label)
        if m:
            try:
                return by_ec_label(label)
            except ValueError:
                return elliptic_curve_jump_error(label,
                                                 info,
                                                 wellformed_label=True)
        elif label.startswith("Cremona:"):
            label = label[8:]
            m = cremona_label_regex.match(label)
            if m:
                try:
                    return by_ec_label(label)
                except ValueError:
                    return elliptic_curve_jump_error(label,
                                                     info,
                                                     wellformed_label=True)
        elif cremona_label_regex.match(label):
            return elliptic_curve_jump_error(label, info, cremona_label=True)
        elif label:
            # Try to parse a string like [1,0,3,2,4]
            lab = re.sub(r'\s', '', label)
            lab = re.sub(r'^\[', '', lab)
            lab = re.sub(r']$', '', lab)
            try:
                labvec = lab.split(',')
                labvec = [QQ(str(z)) for z in labvec]  # Rationals allowed
                E = EllipticCurve(labvec)
                ainvs = [str(c) for c in E.minimal_model().ainvs()]
                C = lmfdb.base.getDBConnection()
                data = C.elliptic_curves.curves.find_one({'ainvs': ainvs})
                if data is None:
                    return elliptic_curve_jump_error(label, info)
                return by_ec_label(data['lmfdb_label'])
            except (ValueError, ArithmeticError):
                return elliptic_curve_jump_error(label, info)
        else:
            query['label'] = ''

    if info.get('jinv'):
        j = clean_input(info['jinv'])
        j = j.replace('+', '')
        if not QQ_RE.match(j):
            info[
                'err'] = 'Error parsing input for the j-invariant.  It needs to be a rational number.'
            return search_input_error(info, bread)
        query['jinv'] = j

    for field in ['conductor', 'torsion', 'rank', 'sha_an']:
        if info.get(field):
            info[field] = clean_input(info[field])
            ran = info[field]
            ran = ran.replace('..', '-').replace(' ', '')
            if not LIST_RE.match(ran):
                names = {
                    'conductor': 'conductor',
                    'torsion': 'torsion order',
                    'rank': 'rank',
                    'sha_an': 'analytic order of &#1064;'
                }
                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[
                        field]
                return search_input_error(info, bread)
            # 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
            if field == 'sha_an':  # database sha_an values are not all exact!
                query[tmp[0]] = {'$gt': tmp[1] - 0.1, '$lt': tmp[1] + 0.1}
            else:
                query[tmp[0]] = tmp[1]

    if 'optimal' in info and info['optimal'] == 'on':
        # fails on 990h3
        query['number'] = 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'] = [
            str(a) for a in parse_list(info['torsion_structure'])
        ]

    if info.get('surj_primes'):
        info['surj_primes'] = clean_input(info['surj_primes'])
        format_ok = LIST_POSINT_RE.match(info['surj_primes'])
        if format_ok:
            surj_primes = [int(p) for p in info['surj_primes'].split(',')]
            format_ok = all([ZZ(p).is_prime(proof=False) for p in surj_primes])
        if format_ok:
            query['non-surjective_primes'] = {"$nin": surj_primes}
        else:
            info[
                'err'] = 'Error parsing input for surjective primes.  It needs to be a prime (such as 5), or a comma-separated list of primes (such as 2,3,11).'
            return search_input_error(info, bread)

    if info.get('nonsurj_primes'):
        info['nonsurj_primes'] = clean_input(info['nonsurj_primes'])
        format_ok = LIST_POSINT_RE.match(info['nonsurj_primes'])
        if format_ok:
            nonsurj_primes = [
                int(p) for p in info['nonsurj_primes'].split(',')
            ]
            format_ok = all(
                [ZZ(p).is_prime(proof=False) for p in nonsurj_primes])
        if format_ok:
            if info['surj_quantifier'] == 'exactly':
                nonsurj_primes.sort()
                query['non-surjective_primes'] = nonsurj_primes
            else:
                if 'non-surjective_primes' in query:
                    query['non-surjective_primes'] = {
                        "$nin": surj_primes,
                        "$all": nonsurj_primes
                    }
                else:
                    query['non-surjective_primes'] = {"$all": nonsurj_primes}
        else:
            info[
                'err'] = 'Error parsing input for nonsurjective primes.  It needs to be a prime (such as 5), or a comma-separated list of primes (such as 2,3,11).'
            return search_input_error(info, bread)

    info['query'] = query

    count_default = 100
    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 = lmfdb.base.getDBConnection().elliptic_curves.curves.find(query)
    nres = cursor.count()
    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0
    res = cursor.sort([('conductor', ASCENDING), ('lmfdb_iso', ASCENDING),
                       ('lmfdb_number', ASCENDING)]).skip(start).limit(count)
    info['curves'] = res
    info['format_ainvs'] = format_ainvs
    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
    credit = 'John Cremona'
    if 'non-surjective_primes' in query:
        credit += 'and Andrew Sutherland'
    t = 'Elliptic Curves'
    return render_template("search_results.html",
                           info=info,
                           credit=credit,
                           bread=bread,
                           title=t)
Ejemplo n.º 58
0
def _talks_index(query={}, sort=None, subsection=None, past=False):
    # Eventually want some kind of cutoff on which talks are included.
    search_array = TalkSearchArray(past=past)
    info = to_dict(read_search_cookie(search_array), search_array=search_array)
    info.update(request.args)
    query = dict(query)
    parse_substring(info, query, "keywords",
                    ["title",
                     "abstract",
                     "speaker",
                     "speaker_affiliation",
                     "seminar_id",
                     "comments",
                     "speaker_homepage",
                     "paper_link"])
    more = {} # we will be selecting talks satsifying the query and recording whether they satisfy the "more" query
    # Note that talks_parser ignores the "time" field at the moment; see below for workaround
    talks_parser(info, more)
    if topdomain() == "mathseminars.org":
        query["topics"] = {"$contains": "math"}
    query["hidden"] = {"$or": [False, {"$exists": False}]}
    if past:
        query["end_time"] = {"$lt": datetime.now()}
        if sort is None:
            sort = [("start_time", -1), "seminar_id"]
    else:
        query["end_time"] = {"$gte": datetime.now()}
        if sort is None:
            sort = ["start_time", "seminar_id"]
    talks = list(talks_search(query, sort=sort, seminar_dict=all_seminars(), more=more))
    # Filtering on display and hidden isn't sufficient since the seminar could be private
    talks = [talk for talk in talks if talk.searchable()]
    # While we may be able to write a query specifying inequalities on the timestamp in the user's timezone, it's not easily supported by talks_search.  So we filter afterward
    timerange = info.get("timerange", "").strip()
    if timerange:
        tz = current_user.tz
        try:
            timerange = process_user_input(timerange, col="search", typ="daytimes")
        except ValueError:
            try:
                onetime = process_user_input(timerange, col="search", typ="daytime")
            except ValueError:
                flash_error("Invalid time range input: %s", timerange)
            else:
                for talk in talks:
                    if talk.more:
                        talkstart = adapt_datetime(talk.start_time, tz)
                        t = date_and_daytime_to_time(talkstart.date(), onetime, tz)
                        talk.more = (t == talkstart)
        else:
            for talk in talks:
                if talk.more:
                    talkstart = adapt_datetime(talk.start_time, tz)
                    talkend = adapt_datetime(talk.end_time, tz)
                    t0, t1 = date_and_daytimes_to_times(talkstart.date(), timerange, tz)
                    talk.more = (t0 <= talkstart) and (talkend <= t1)
    counters = _get_counters(talks)
    row_attributes = _get_row_attributes(talks)
    response = make_response(render_template(
        "browse_talks.html",
        title="Browse talks",
        section="Browse",
        info=info,
        subsection=subsection,
        talk_row_attributes=zip(talks, row_attributes),
        past=past,
        **counters
    ))
    if request.cookies.get("topics", ""):
        # TODO: when we move cookie data to server with ajax calls, this will need to get updated again
        # For now we set the max_age to 30 years
        response.set_cookie("topics_dict", topic_dag.port_cookie(), max_age=60*60*24*365*30)
        response.set_cookie("topics", "", max_age=0)
    return response
Ejemplo n.º 59
0
def half_integral_weight_form_search(**args):
    C = getDBConnection()
    C.halfintegralmf.forms.ensure_index([('level', 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_hiwf_webpage(**args)
    query = {}
    try:
        parse_ints(info, query, 'weight')
        parse_ints(info, query, 'level')
        if info.get('character', '').strip():
            if re.match('^\d+.\d+$', info['character'].strip()):
                query['character'] = info['character'].strip()
            else:
                flash_error(
                    "%s is not a valid Dirichlet character label, it should be of the form q.n",
                    info['character'])
    except:
        return redirect(url_for(".half_integral_weight_form_render_webpage"))

    info['query'] = dict(query)
    res = C.halfintegralmf.forms.find(query).sort([
        ('level', pymongo.ASCENDING), ('label', pymongo.ASCENDING)
    ])
    nres = res.count()
    count = 100

    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['level'] = v['level']
        v_clean['label'] = v['label']
        v_clean['weight'] = v['weight']
        v_clean['ch_lab'] = v['character'].replace('.', '/')
        v_clean['char'] = "\chi_{" + v['character'].split(
            ".")[0] + "}(" + v['character'].split(".")[1] + ",\cdot)"
        v_clean['dimension'] = v['dim']
        res_clean.append(v_clean)

    info['forms'] = res_clean

    t = 'Half Integral Weight Cusp Forms search results'
    bread = [('Half Integral Weight Cusp Forms',
              url_for(".half_integral_weight_form_render_webpage")),
             ('Search Results', ' ')]
    properties = []
    return render_template("half_integral_weight_form_search.html",
                           info=info,
                           title=t,
                           properties=properties,
                           bread=bread)
Ejemplo n.º 60
0
def render_elliptic_modular_form_navigation_wp1(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', 0, int)
    weight = my_get(info, 'weight', 0, int)
    group = my_get(info, 'group', 1, int)
    if group == int(0):
        pass
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    if ('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if isinstance(weight, int) and weight > 0:
        is_set['weight'] = True
        weight = int(weight)
    else:
        weight = None
        info.pop('weight', None)
    if isinstance(level, int) and level > 0:
        is_set['level'] = True
        level = int(level)
    else:
        level = None
        info.pop('level', None)
    ## This is the list of weights we initially put on the form
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page')),
             (title, url_for('.render_elliptic_modular_forms'))]

    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    # Special case: if the range reduces to a singleton for both level
    # and weight then we return a single page rather than a table:
    if limits_weight[0] == limits_weight[1] and limits_level[
            0] == limits_level[1]:
        return render_elliptic_modular_form_space_list_chars(
            limits_level[0], limits_weight[0])
    if is_set['weight']:
        limits_weight = (weight, weight)
    elif limits_weight is None:
        limits_weight = (2, 12)  # default values
    if is_set['level']:
        limits_level = (level, level)
    elif limits_level is None:
        limits_level = (1, 24)  # default values
    try:
        group = info.get('group', 0)  # default group is gamma_0
        group = int(group)
    except ValueError:
        group = 0
    if group not in [0, 1]:
        group = 0
    if group == 0:
        info['grouptype'] = 0
        info['groupother'] = 1
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
    emf_logger.debug("level:{0},level_range={1}".format(level, limits_level))
    emf_logger.debug("weight:{0},weight_range={1}".format(
        weight, limits_weight))

    if limits_weight[0] == limits_weight[1] and limits_level[
            0] == limits_level[1]:
        return redirect(url_for("emf.render_elliptic_modular_forms",
                                level=limits_level[0],
                                weight=limits_weight[0],
                                group=group),
                        code=301)
    info['show_switch'] = True
    db = getDBConnection()['modularforms2']['webmodformspace_dimension']
    table = {}
    q = db.find_one({'group': 'gamma{0}'.format(group)})
    if q:
        table = q.get('data', {})
    if table != {}:
        table = json.loads(table)
    info['table'] = {}
    level_range = range(limits_level[0], limits_level[1] + 1)
    # we don't have weight 1 in database
    if limits_weight[0] == 1:
        limits_weight = (2, limits_weight[1])
    weight_range = range(limits_weight[0], limits_weight[1] + 1)
    #print "levels=",level_range
    #print "weights=",weight_range
    if len(weight_range) > 1:
        info['weight_range'] = "{0}-{1}".format(limits_weight[0],
                                                limits_weight[1])
    if len(level_range) > 1:
        info['level_range'] = "{0}-{1}".format(limits_level[0],
                                               limits_level[1])
    if group == 0:
        weight_range = filter(is_even, weight_range)
        for n in level_range:
            info['table'][n] = {}
            sn = unicode(n)
            for k in weight_range:
                info['table'][n][k] = {}
                sk = unicode(k)
                if table.has_key(sn):
                    if table[sn].has_key(sk):
                        info['table'][n][k] = table[sn][
                            sk]  #.get(str(n),{}).get(str(k),"n/a")
    else:
        emf_logger.debug("Set table for Gamma1")
        for n in level_range:
            info['table'][n] = {}
            for k in weight_range:
                info['table'][n][k] = table.get(str(n),
                                                {}).get(str(k), {}).get(
                                                    str(-1), "n/a")
    #print "table=\n",table
    #print "info=\n",info
    #info['table']=table
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html",
                           info=info,
                           title=title,
                           bread=bread)