Esempio n. 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>"
            )
Esempio n. 2
0
def parse_projective_group(inp, query, qfield):
    inp = inp.lower()
    inp = inp.replace('_', '')
    if inp in ['v4', 'c2^2']:
        inp = 'd2'
    if inp == 's3':
        inp = 'd3'
    if inp == 'a5':
        query[qfield] = [60, 5]
    elif inp == 'a4':
        query[qfield] = [12, 3]
    elif inp == 's4':
        query[qfield] = [24, 12]
    elif Dn_RE.match(inp):
        n = int(inp.replace('d', '')) - 2
        if n >= 0 and n < len(dihedrals):
            query[qfield] = dihedrals[n]
        elif n >= 0:
            query[qfield] = [-1, -2]  # we don't have it
    else:
        try:
            mycode = complete_group_code(inp.upper())[0]
            query['Proj_nTj'] = [mycode[0], mycode[1]]
        except:
            raise ValueError(
                "Allowed values are A4, S4, A5, or Dn for an integer n>1, a GAP id, such as [4,1] or [12,5], a transitive group in nTj notation, such as 5T1, or a <a title = 'Galois group labels' knowl='nf.galois_group.name'>group label</a>."
            )