Beispiel #1
0
def parse_galgrp(inp, query, qfield, err_msg=None, list_ok=True):
    try:
        if list_ok:
            from lmfdb.galois_groups.transitive_group import complete_group_codes
            gcs = complete_group_codes(inp)
        else:
            from lmfdb.galois_groups.transitive_group import complete_group_code
            gcs = complete_group_code(inp.upper())

        galfield, nfield = qfield
        if nfield and nfield not in query:
            nvals = list(set([s[0] for s in gcs]))
            if len(nvals) == 1:
                query[nfield] = nvals[0]
            else:
                query[nfield] = {'$in': nvals}
        # if nfield was already in the query, we could try to intersect it with nvals
        cands = ['{}T{}'.format(s[0], s[1]) for s in gcs]
        if len(cands) == 1:
            query[galfield] = cands[0]
        else:
            query[galfield] = {'$in': cands}
    except NameError:
        if re.match(r'^[ACDS]\d+$', inp):
            raise SearchParsingError(
                "The requested group is not in the database")
        if err_msg:
            raise SearchParsingError(err_msg)
        else:
            raise SearchParsingError(
                "It needs to be a list made up of GAP id's, such as [4,1] or [12,5], transitive groups in nTj notation, such as 5T1, and <a title = 'Galois group labels' knowl='nf.galois_group.name'>group labels</a>"
            )
Beispiel #2
0
def parse_galgrp(inp, query, qfield):
    from lmfdb.galois_groups.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."
        )
Beispiel #3
0
def parse_galgrp(inp, query, qfield):
    from lmfdb.galois_groups.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.")
Beispiel #4
0
def parse_galgrp(inp, query, qfield):
    from lmfdb.galois_groups.transitive_group import complete_group_codes
    try:
        gcs = complete_group_codes(inp)
        groups = [str(n) + "T" + str(t) for n, t in gcs]
        _parse_subset(groups, query, qfield, mode=None, radical=None, product=None)
    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.")