Example #1
0
def parse_galgrp(inp, query, qfield):
    from lmfdb.transitive_group import complete_group_codes
    try:
        gcs = complete_group_codes(inp)
        nfield, tfield = qfield
        if nfield in query:
            gcs = [t for n,t in gcs if n == query[nfield]]
            if len(gcs) == 0:
                raise ValueError("Degree inconsistent with Galois group.")
            elif len(gcs) == 1:
                query[tfield] = gcs[0]
            else:
                query[tfield] = {'$in': gcs}
        else:
            gcsdict = defaultdict(list)
            for n,t in gcs:
                gcsdict[n].append(t)
            if len(gcsdict) == 1:
                query[nfield] = n # left over from the loop
                if len(gcs) == 1:
                    query[tfield] = t # left over from the loop
                else:
                    query[tfield] = {'$in': gcsdict[n]}
            else:
                options = []
                for n, T in gcsdict.iteritems():
                    if len(T) == 1:
                        options.append({nfield: n, tfield: T[0]})
                    else:
                        options.append({nfield: n, tfield: {'$in': T}})
                collapse_ors(['$or', options], query)
    except NameError:
        raise ValueError("It needs to be a <a title = 'Galois group labels' knowl='nf.galois_group.name'>group label</a>, such as C5 or 5T1, or a comma separated list of such labels.")
Example #2
0
def parse_galgrp(inp, query, qfield):
    from lmfdb.transitive_group import complete_group_codes
    try:
        gcs = complete_group_codes(inp)
        nfield, tfield = qfield
        if nfield in query:
            gcs = [t for n, t in gcs if n == query[nfield]]
            if len(gcs) == 0:
                raise ValueError("Degree inconsistent with Galois group.")
            elif len(gcs) == 1:
                query[tfield] = gcs[0]
            else:
                query[tfield] = {'$in': gcs}
        else:
            gcsdict = defaultdict(list)
            for n, t in gcs:
                gcsdict[n].append(t)
            if len(gcsdict) == 1:
                query[nfield] = n  # left over from the loop
                if len(gcs) == 1:
                    query[tfield] = t  # left over from the loop
                else:
                    query[tfield] = {'$in': gcsdict[n]}
            else:
                options = []
                for n, T in gcsdict.iteritems():
                    if len(T) == 1:
                        options.append({nfield: n, tfield: T[0]})
                    else:
                        options.append({nfield: n, tfield: {'$in': T}})
                collapse_ors(['$or', options], query)
    except NameError:
        raise ValueError(
            "It needs to be a <a title = 'Galois group labels' knowl='nf.galois_group.name'>group label</a>, such as C5 or 5T1, or a comma separated list of such labels."
        )
Example #3
0
def parse_galgrp(inp, query, qfield, use_bson=True):
    from lmfdb.transitive_group import complete_group_codes
    from lmfdb.transitive_group import make_galois_pair as _make_galois_pair
    make_galois_pair = _make_galois_pair if use_bson else lambda x,y: [x,y]
    try:
        gcs = complete_group_codes(inp)
        if len(gcs) == 1:
            query[qfield] = make_galois_pair(gcs[0][0], gcs[0][1])
        elif len(gcs) > 1:
            query[qfield] = {'$in': [make_galois_pair(x[0], x[1]) for x in gcs]}
    except NameError:
        raise ValueError("It needs to be a <a title = 'Galois group labels' knowl='nf.galois_group.name'>group label</a>, such as C5 or 5T1, or a comma separated list of such labels.")
Example #4
0
def parse_galgrp(inp, query, qfield, use_bson=True):
    from lmfdb.transitive_group import complete_group_codes
    from lmfdb.transitive_group import make_galois_pair as _make_galois_pair
    try:
        gcs = complete_group_codes(inp)
        if isinstance(
                qfield, tuple
        ):  # temporary until everything is switched over to new Galois formatting.
            nfield, tfield = qfield
            if nfield in query:
                gcs = [t for n, t in gcs if n == query[nfield]]
                if len(gcs) == 0:
                    raise ValueError("Degree inconsistent with Galois group.")
                elif len(gcs) == 1:
                    query[tfield] = gcs[0]
                else:
                    query[tfield] = {'$in': gcs}
            else:
                gcsdict = defaultdict(list)
                for n, t in gcs:
                    gcsdict[n].append(t)
                if len(gcsdict) == 1:
                    query[nfield] = n  # left over from the loop
                    if len(gcs) == 1:
                        query[tfield] = t  # left over from the loop
                    else:
                        query[tfield] = {'$in': gcsdict[n]}
                else:
                    options = []
                    for n, T in gcsdict.iteritems():
                        if len(T) == 1:
                            options.append({nfield: n, tfield: T[0]})
                        else:
                            options.append({nfield: n, tfield: {'$in': T}})
                    collapse_ors(['$or', options], query)
        else:
            make_galois_pair = _make_galois_pair if use_bson else lambda x, y: [
                x, y
            ]
            if len(gcs) == 1:
                query[qfield] = make_galois_pair(gcs[0][0], gcs[0][1])
            elif len(gcs) > 1:
                query[qfield] = {
                    '$in': [make_galois_pair(x[0], x[1]) for x in gcs]
                }
    except NameError:
        raise ValueError(
            "It needs to be a <a title = 'Galois group labels' knowl='nf.galois_group.name'>group label</a>, such as C5 or 5T1, or a comma separated list of such labels."
        )
Example #5
0
def parse_galgrp(inp, query, qfield, use_bson=True):
    from lmfdb.transitive_group import complete_group_codes
    from lmfdb.transitive_group import make_galois_pair as _make_galois_pair
    try:
        gcs = complete_group_codes(inp)
        if isinstance(qfield, tuple): # temporary until everything is switched over to new Galois formatting.
            nfield, tfield = qfield
            if nfield in query:
                gcs = [t for n,t in gcs if n == query[nfield]]
                if len(gcs) == 0:
                    raise ValueError("Degree inconsistent with Galois group.")
                elif len(gcs) == 1:
                    query[tfield] = gcs[0]
                else:
                    query[tfield] = {'$in': gcs}
            else:
                gcsdict = defaultdict(list)
                for n,t in gcs:
                    gcsdict[n].append(t)
                if len(gcsdict) == 1:
                    query[nfield] = n # left over from the loop
                    if len(gcs) == 1:
                        query[tfield] = t # left over from the loop
                    else:
                        query[tfield] = {'$in': gcsdict[n]}
                else:
                    options = []
                    for n, T in gcsdict.iteritems():
                        if len(T) == 1:
                            options.append({nfield: n, tfield: T[0]})
                        else:
                            options.append({nfield: n, tfield: {'$in': T}})
                    collapse_ors(['$or', options], query)
        else:
            make_galois_pair = _make_galois_pair if use_bson else lambda x,y: [x,y]
            if len(gcs) == 1:
                query[qfield] = make_galois_pair(gcs[0][0], gcs[0][1])
            elif len(gcs) > 1:
                query[qfield] = {'$in': [make_galois_pair(x[0], x[1]) for x in gcs]}
    except NameError:
        raise ValueError("It needs to be a <a title = 'Galois group labels' knowl='nf.galois_group.name'>group label</a>, such as C5 or 5T1, or a comma separated list of such labels.")
Example #6
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"])
    if req.get("group", "") != "":
        try:
            gcs = complete_group_codes(req['group'])
            if len(gcs) == 1:
                query['Galois_nt'] = gcs[0]
# list(gcs[0])
            if len(gcs) > 1:
                query['Galois_nt'] = {'$in': [x for x in gcs]}
        except NameError as code:
            errinfo = 'Error parsing input for Galois group: unknown group label %s.  It needs to be a <a title = "Galois group labels" knowl="nf.galois_group.name">group label</a>, such as C5 or 5T1, or comma separated list of labels.' % code
            # info['err'] = 'Error parsing input for Galois group: unknown group label %s.  It needs to be a <a title = "Galois group labels" knowl="nf.galois_group.name">group label</a>, such as C5 or 5T1, or comma separated list of labels.' % code
            raise AssertionError(errinfo)
            #return search_input_error(info, bread)

    tmp_conductor = []
    if req.get("conductor", "") != "":
        from lmfdb.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)