示例#1
0
文件: main.py 项目: JRSijsling/lmfdb
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 redirect(url_for(".render_artin_representation_webpage", label=label), 301)

    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)
示例#2
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 redirect(
            url_for(".render_artin_representation_webpage", label=label), 307)

    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)
示例#3
0
def random_representation():
    rep = random_object_from_collection(ArtinRepresentation.collection())
    num = random.randrange(0, len(rep['GaloisConjugates']))
    label = rep['Baselabel'] + "c" + str(num + 1)
    return redirect(
        url_for(".render_artin_representation_webpage", label=label), 307)
示例#4
0
文件: main.py 项目: JRSijsling/lmfdb
def random_representation():
    rep = random_object_from_collection(ArtinRepresentation.collection())
    num = random.randrange(0, len(rep['GaloisConjugates']))
    label = rep['Baselabel']+"c"+str(num+1)
    return redirect(url_for(".render_artin_representation_webpage", label=label), 301)