Example #1
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"

    gD = parse_range(info['table_dimension_range'])
    qD = parse_range(info['table_field_range'])
    av_stats = AbvarFqStats()
    qs = av_stats.qs
    gs = av_stats.gs

    info['table'] = {}
    if isinstance(qD, int):
        qmin = qmax = qD
    else:
        qmin = qD.get('$gte', min(qs) if qs else qD.get('$lte', 0))
        qmax = qD.get('$lte', max(qs) if qs else qD.get('$gte', 1000))
    if isinstance(gD, int):
        gmin = gmax = gD
    else:
        gmin = gD.get('$gte', min(gs) if gs else gD.get('$lte', 1))
        gmax = gD.get('$lte', max(gs) if gs else gD.get('$gte', 20))

    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 q in qs:
        if q < qmin or q > qmax:
            continue
        info['table'][q] = {}
        L = av_stats._counts[q]
        for g in xrange(gmin, gmax + 1):
            if g < len(L):
                info['table'][q][g] = L[g]
            else:
                info['table'][q][g] = 0

    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())
Example #2
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"

    gD = parse_range(info['table_dimension_range'])
    qD = parse_range(info['table_field_range'])
    av_stats=AbvarFqStats()
    qs = av_stats.qs
    gs = av_stats.gs

    info['table'] = {}
    if isinstance(qD, int):
        qmin = qmax = qD
    else:
        qmin = qD.get('$gte',min(qs) if qs else qD.get('$lte',0))
        qmax = qD.get('$lte',max(qs) if qs else qD.get('$gte',1000))
    if isinstance(gD, int):
        gmin = gmax = gD
    else:
        gmin = gD.get('$gte',min(gs) if gs else gD.get('$lte',1))
        gmax = gD.get('$lte',max(gs) if gs else gD.get('$gte',20))

    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 q in qs:
        if q < qmin or q > qmax:
            continue
        info['table'][q] = {}
        L = av_stats._counts[q]
        for g in xrange(gmin, gmax+1):
            if g < len(L):
                info['table'][q][g] = L[g]
            else:
                info['table'][q][g] = 0

    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())
Example #3
0
def ModularForm_GSp4_Q_Sp4Z_j():
    bread = [("Modular Forms", url_for('mf.modular_form_main_page')),
             ('Siegel modular forms', url_for('ModularForm_GSp4_Q_top_level')),
             ('$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z}))$',
              '/ModularForm/GSp/Q/Sp4Z_j')]
    error = False
    jrange = xrange(0, 21)
    krange = xrange(10, 21)
    if request.args.get('j'):
        try:
            jr = parse_range(request.args.get('j'))
            if type(jr) is int:
                jrange = xrange(jr, jr + 20 + 1)
            else:
                jrange = xrange(jr['$gte'], jr['$lte'])
        except:
            error = "Error parsing input for j.  It needs to be an integer (such as 25), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121)."
            flash(error, "error")
            return redirect(url_for(".ModularForm_GSp4_Q_Sp4Z_j"))

    if request.args.get('k'):
        try:
            kr = parse_range(request.args.get('k'))
            if type(kr) is int:
                if kr < 4:
                    kr = 4
                krange = xrange(kr, kr + 10 + 1)
            else:
                if kr['$gte'] < 4:
                    kr['$gte'] = 4
                krange = xrange(kr['$gte'], kr['$lte'])
        except:
            error = "Error parsing input for k.  It needs to be an integer (such as 25), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121)."
            flash(error, "error")
            return redirect(url_for(".ModularForm_GSp4_Q_Sp4Z_j"))
    jrange = [x for x in jrange if x % 2 == 0]
    try:
        dimtable = dimensions.dimension_table_Sp4Z_j(krange, jrange)
    except:
        error = 'Not all dimensions are implemented at the moment. Try again with a different range'
        dimtable = False
    return render_template('ModularForm_GSp4_Q_Sp4Zj.html',
                           title='$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z}))$',
                           bread=bread,
                           dimtable=dimtable,
                           jrange=jrange,
                           krange=krange,
                           error=error)
Example #4
0
def bianchi_modular_form_search(info, query):
    """Function to handle requests from the top page, either jump to one
    newform or do a search.
    """
    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 # will exclude NULL values
        elif info['include_cm'] == 'only':
            query['CM'] = {'$ne': 0} # will exclude NULL values
    if 'include_base_change' in info and info['include_base_change'] == 'off':
        query['bc'] = 0
    else:
        info['include_base_change'] = "on"
Example #5
0
def extract_limits_as_tuple(arg, field):
    fld = arg.get(field)
    try:
        if isinstance(fld, basestring):
            tmp = parse_range(fld, use_dollar_vars=False)
            if isinstance(tmp, dict):
                limits = (tmp['min'], tmp['max'])
            else:
                limits = (tmp, tmp)
        elif isinstance(fld, (tuple, list)):
            limits = (int(fld[0]), int(fld[1]))
        elif isinstance(fld, dict):
            limits = (fld['min'], fld['max'])
        elif not fld is None:
            limits = (fld, fld)
        else:
            limits = None
    except (TypeError, ValueError) as e:
        emf_logger.debug("Error in search parameters. {0} ".format(e))
        msg = safe_non_valid_input_error(arg.get(field), field)
        if field == 'label':
            msg += " Need a label which is a sequence of letters, for instance 'a' or 'ab' for input"
        else:
            msg += " Need either a positive integer or a range of positive integers as input."
        flash(msg, "error")
        return None
    return limits
Example #6
0
def bianchi_modular_form_search(info, query):
    """Function to handle requests from the top page, either jump to one
    newform or do a search.
    """
    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  # will exclude NULL values
        elif info['include_cm'] == 'only':
            query['CM'] = {'$ne': 0}  # will exclude NULL values
    if 'include_base_change' in info and info['include_base_change'] == 'off':
        query['bc'] = 0
    else:
        info['include_base_change'] = "on"
Example #7
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>"
Example #8
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>"
Example #9
0
def extract_limits_as_tuple(arg, field):
    fld = arg.get(field)
    try:
        if isinstance(fld,basestring):
            tmp = parse_range(fld, use_dollar_vars=False)
            if isinstance(tmp,dict):
                limits = (tmp['min'],tmp['max'])
            else:
                limits = (tmp,tmp)
        elif isinstance(fld,(tuple,list)):
            limits = (int(fld[0]),int(fld[1]))
        elif isinstance(fld,dict):
            limits = (fld['min'], fld['max'])
        elif not fld is None: 
            limits = (fld,fld)
        else:
            limits = None
    except (TypeError,ValueError) as e:
        emf_logger.debug("Error in search parameters. {0} ".format(e))
        msg = safe_non_valid_input_error(arg.get(field),field)
        if field == 'label':
            msg += " Need a label which is a sequence of letters, for instance 'a' or 'ab' for input"
        else:
            msg += " Need either a positive integer or a range of positive integers as input."
        flash(msg,"error")
        return None
    return limits
def ModularForm_GSp4_Q_Sp4Z_j():
    bread = [("Modular Forms", url_for('mf.modular_form_main_page')),
             ('Siegel modular forms', url_for('ModularForm_GSp4_Q_top_level')),
             ('$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z}))$', '/ModularForm/GSp/Q/Sp4Z_j')]
    error = False
    jrange = xrange(0, 21)
    krange = xrange(10, 21)
    if request.args.get('j'):
        try:
            jr = parse_range(request.args.get('j'))
            if type(jr) is int:
                jrange = xrange(jr, jr+20+1);
            else:
                jrange = xrange(jr['$gte'], jr['$lte'])
        except:
            error="Error parsing input for j.  It needs to be an integer (such as 25), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121)." 
            flash(error, "error")
            return redirect(url_for(".ModularForm_GSp4_Q_Sp4Z_j"))

    if request.args.get('k'):
        try:
            kr = parse_range(request.args.get('k'))
            if type(kr) is int:
                if kr<4:
                    kr=4
                krange = xrange(kr, kr+10+1);
            else:
                if kr['$gte']<4:
                    kr['$gte']=4
                krange = xrange(kr['$gte'], kr['$lte'])
        except:
            error="Error parsing input for k.  It needs to be an integer (such as 25), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121)." 
            flash(error, "error")
            return redirect(url_for(".ModularForm_GSp4_Q_Sp4Z_j"))
    jrange = [x for x in jrange if x%2==0]
    try:
        dimtable = dimensions.dimension_table_Sp4Z_j(krange, jrange)
    except:
        error='Not all dimensions are implemented at the moment. Try again with a different range'
        dimtable=False
    return render_template('ModularForm_GSp4_Q_Sp4Zj.html',
                           title='$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z}))$',
                           bread = bread,
                           dimtable = dimtable,
                           jrange=jrange,
                           krange=krange,
                           error=error)
Example #11
0
def ModularForm_GSp4_Q_Sp4Z_j():
    bread = [("Modular Forms", url_for('mf.modular_form_main_page')),
             ('Siegel modular forms', url_for('ModularForm_GSp4_Q_top_level')),
             ('$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z}))$', '/ModularForm/GSp/Q/Sp4Z_j')]
    error = False
    jrange = xrange(0, 21)
    krange = xrange(10, 21)
    if request.args.get('j'):
        jr = parse_range(request.args.get('j'))
        if type(jr) is int:
            jrange = xrange(jr, jr+20+1);
        else:
            jrange = xrange(jr['$gte'], jr['$lte'])
    if request.args.get('k'):
        kr = parse_range(request.args.get('k'))
        if type(kr) is int:
            if kr<4:
                kr=4
            krange = xrange(kr, kr+10+1);
        else:
            if kr['$gte']<4:
                kr['$gte']=4
            krange = xrange(kr['$gte'], kr['$lte'])
    jrange = [x for x in jrange if x%2==0]
    try:
        dimtable = dimensions.dimension_table_Sp4Z_j(krange, jrange)
    except:
        error='Not all dimensions are implemented at the moment. Try again with a different range'
        dimtable=False
    return render_template('ModularForm_GSp4_Q_Sp4Zj.html',
                           title='$M_{k,j}(\mathrm{Sp}(4, \mathbb{Z}))$',
                           bread = bread,
                           dimtable = dimtable,
                           jrange=jrange,
                           krange=krange,
                           error=error)
Example #12
0
def extract_limits_as_tuple(arg, field):
    fld = arg.get(field)
    if isinstance(fld,basestring):
        tmp = parse_range(fld, use_dollar_vars=False)
        if isinstance(tmp,dict):
            limits = (tmp['min'],tmp['max'])
        else:
            limits = (tmp,tmp)
    elif isinstance(fld,(tuple,list)):
        limits = (int(fld[0]),int(fld[1]))
    elif isinstance(fld,dict):
        limits = (fld['min'], fld['max'])
    elif not fld is None: 
        limits = (fld,fld)
    else:
        limits = None
    return limits
Example #13
0
def extract_limits_as_tuple(arg, field):
    fld = arg.get(field)
    if isinstance(fld, basestring):
        tmp = parse_range(fld, use_dollar_vars=False)
        if isinstance(tmp, dict):
            limits = (tmp['min'], tmp['max'])
        else:
            limits = (tmp, tmp)
    elif isinstance(fld, (tuple, list)):
        limits = (int(fld[0]), int(fld[1]))
    elif isinstance(fld, dict):
        limits = (fld['min'], fld['max'])
    elif not fld is None:
        limits = (fld, fld)
    else:
        limits = None
    return limits
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.
        label = info['label']
        dat = label.split("-")
        if len(dat)==2: # assume field & level, display space
            return render_bmf_space_webpage(dat[0], dat[1])
        else: # assume single newform label; will display an error if invalid
            return bianchi_modular_form_by_label(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['level_norm']  = v['level_norm']
        v_clean['level_number'] = v['level_label'].split(".")[1]
        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)

    res_clean.sort(key=lambda x: [int(x['level_norm']), int(x['level_number']), x['label_suffix']])
    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())
Example #15
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())
def _browse_web_modform_spaces_in_ranges(**kwds):
    r"""
    Renders the webpage for browsing modular forms of given level and/or weight ranges.
    """
    return render_elliptic_modular_form_navigation_wp(**kwds)
    emf_logger.debug("In browse_elliptic_modular_forms_ranges kwds: {0}".format(kwds))
    emf_logger.debug("args={0}".format(request.args))
    level = kwds.get('level',int(1))
    if level is None or isinstance(level,int):
        pass
    default = {}
    default['level'] = '1-12'
    default['weight'] = '2-36'
    default['character'] = 1
    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],use_dollar_vars=True)
        else:
            info[field] = parse_range(default[field],use_dollar_vars=True)
    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')
    # 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 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)
Example #17
0
File: raw.py Project: jwbober/lmfdb
def database_query(db_name, coll_name):
    if not is_safe(db_name) or not is_safe(coll_name):
        return "Nope."
    C = base.getDBConnection()
    if db_name not in C.database_names():
        return "No such database."
    db = getattr(C, db_name)
    if coll_name not in db.collection_names():
        return "No such collection."

    args = to_dict(request.args)
    info = dict(args)
    collection = getattr(db, coll_name)
    try:
        collection.ensure_index('metadata', background=True)
    except pymongo.errors.OperationFailure:
        pass
    metadata = collection.find_one({'metadata': 'metadata'})
    if metadata:
        del metadata['_id']
        info['metadata'] = json.dumps(metadata, sort_keys=True, indent=4)
    else:
        info['metadata'] = "No metadata."
    indices = set()
    for name, index in collection.index_information().items():
        key = index['key'][0][0]
        if key == '_id':
            continue
        indices.add(key)
    try:
        indices.remove('metadata')
    except ValueError:
        pass
    if args.get('_fields'):
        info['default_fields'] = args['_fields'].split(',')
    else:
        # TODO: pull from metadata
        info['default_fields'] = list(indices)
    try:
        limit = int(args.pop('_limit'))
    except (TypeError, KeyError):
        info['_limit'] = limit = 100
    if '_search' in args:
        query = {}
        for key, value in args.items():
            if key[0] == '_':
                continue
            try:
                query[key] = parse_range(value, int)
            except (TypeError, ValueError):
                try:
                    query[key] = parse_range(value, float)
                except (TypeError, ValueError):
                    query[key] = parse_range(value, str)
        res = collection.find(query).limit(limit)
    else:
        res = None
    # TODO: is there a better way to do [this url] + "&format=..."?
    non_format_args = to_dict(request.args)
    if '_format' in non_format_args:
        del non_format_args['_format']
    info['formats'] = [(format, url_for('database_query', db_name=db_name, coll_name=coll_name,
                        _format=format, **non_format_args)) for format in ('text', 'csv', 'json')]
    format = args.get('_format', 'html')
    if format in ('txt', 'text'):
        info['sep'] = ' '
    elif format == 'csv':
        info['sep'] = ','
    elif format == 'json':
        res = json_iter(res)
        info['default_fields'] = ['all']
        info['sep'] = ''
    else:
        title = "%s.%s" % (db_name, coll_name)
        return render_template("raw/query.html", db=db_name, coll=coll_name, info=info, indices=indices, res=res, title=title)
    # not html
    response = make_response(render_template(
        "raw/query_download.html", db=db_name, coll=coll_name, info=info, indices=indices, res=res))
    response.headers['Content-type'] = 'text/plain'
    return response
def _browse_web_modform_spaces_in_ranges(**kwds):
    r"""
    Renders the webpage for browsing modular forms of given level and/or weight ranges.
    """
    return render_elliptic_modular_form_navigation_wp(**kwds)
    emf_logger.debug(
        "In browse_elliptic_modular_forms_ranges kwds: {0}".format(kwds))
    emf_logger.debug("args={0}".format(request.args))
    level = kwds.get('level', int(1))
    if level is None or isinstance(level, int):
        pass
    default = {}
    default['level'] = '1-12'
    default['weight'] = '2-36'
    default['character'] = 1
    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], use_dollar_vars=True)
        else:
            info[field] = parse_range(default[field], use_dollar_vars=True)
    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')
    # 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 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)
Example #19
0
File: raw.py Project: riiduan/lmfdb
def database_query(db_name, coll_name):
    if not is_safe(db_name) or not is_safe(coll_name):
        return "Nope."
    C = base.getDBConnection()
    if db_name not in C.database_names():
        return "No such database."
    db = getattr(C, db_name)

    try:
        collection = getattr(db, coll_name)
    except Expecptio as e:
        return "No such collection. Error: %s" % e


# see issue #1170
#    if coll_name not in db.collection_names():
#        return "No such collection."

    args = to_dict(request.args)
    info = dict(args)
    collection = getattr(db, coll_name)
    # See issue #1169
    #    try:
    #        collection.ensure_index('metadata', background=True)
    #    except pymongo.errors.OperationFailure:
    #        pass
    metadata = collection.find_one({'metadata': 'metadata'})
    if metadata:
        del metadata['_id']
        info['metadata'] = json.dumps(metadata, sort_keys=True, indent=4)
    else:
        info['metadata'] = "No metadata."
    indices = set()
    for name, index in collection.index_information().items():
        key = index['key'][0][0]
        if key == '_id':
            continue
        indices.add(key)
    try:
        indices.remove('metadata')
    except ValueError:
        pass
    if args.get('_fields'):
        info['default_fields'] = args['_fields'].split(',')
    else:
        # TODO: pull from metadata
        info['default_fields'] = list(indices)
    try:
        limit = int(args.pop('_limit'))
    except (TypeError, KeyError):
        info['_limit'] = limit = 100
    if '_search' in args:
        query = {}
        for key, value in args.items():
            if key[0] == '_':
                continue
            try:
                query[key] = parse_range(value, int)
            except (TypeError, ValueError):
                try:
                    query[key] = parse_range(value, float)
                except (TypeError, ValueError):
                    query[key] = parse_range(value, str)
        res = collection.find(query).limit(limit)
    else:
        res = None
    # TODO: is there a better way to do [this url] + "&format=..."?
    non_format_args = to_dict(request.args)
    if '_format' in non_format_args:
        del non_format_args['_format']
    info['formats'] = [(format,
                        url_for('database_query',
                                db_name=db_name,
                                coll_name=coll_name,
                                _format=format,
                                **non_format_args))
                       for format in ('text', 'csv', 'json')]
    format = args.get('_format', 'html')
    if format in ('txt', 'text'):
        info['sep'] = ' '
    elif format == 'csv':
        info['sep'] = ','
    elif format == 'json':
        res = json_iter(res)
        info['default_fields'] = ['all']
        info['sep'] = ''
    else:
        title = "%s.%s" % (db_name, coll_name)
        return render_template("raw/query.html",
                               db=db_name,
                               coll=coll_name,
                               info=info,
                               indices=indices,
                               res=res,
                               title=title)
    # not html
    response = make_response(
        render_template("raw/query_download.html",
                        db=db_name,
                        coll=coll_name,
                        info=info,
                        indices=indices,
                        res=res))
    response.headers['Content-type'] = 'text/plain'
    return response