Skip to content

Commit

Permalink
Fix bug, add multiquadratic
Browse files Browse the repository at this point in the history
  • Loading branch information
roed314 committed Nov 16, 2024
1 parent a09e40f commit bb2c2a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
8 changes: 8 additions & 0 deletions lmfdb/galois_groups/transitive_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,11 @@ def get_aliases():
46: "46T3",
47: "47T2",
}

multiquad = {
2: "2T1",
4: "4T2",
8: "8T3",
16: "16T4",
32: "32T39",
}
14 changes: 10 additions & 4 deletions lmfdb/number_fields/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
group_phrase, galois_group_data, transitive_group_display_knowl,
group_cclasses_knowl_guts, group_pretty_and_nTj, knowl_cache,
group_character_table_knowl_guts, group_alias_table,
dihedral_gal, dihedral_ngal)
dihedral_gal, dihedral_ngal, multiquad)
from lmfdb.number_fields import nf_page, nf_logger
from lmfdb.number_fields.web_number_field import (
field_pretty, WebNumberField, nf_knowl_guts, factor_base_factor,
Expand Down Expand Up @@ -904,10 +904,15 @@ def number_field_search(info, query):
query["gal_is_cyclic"] = True
elif fi == "ab":
query["gal_is_abelian"] = True
elif fi in ["dih_ngal", "dih_gal"]:
opts = dihedral_gal if fi == "dih_gal" else dihedral_ngal
elif fi in ["dih_ngal", "dih_gal", "multi_quad"]:
if fi == "dih_ngal":
opts = dihedral_ngal
elif fi == "dih_gal":
opts = dihedral_gal
else:
opts = multiquad
if "degree" in info:
opts = {n: opts[n] for n in integer_options(info["degree"], contained_in=list(opts))}
opts = {n: opts[n] for n in integer_options(info["degree"], contained_in=list(opts), lower_bound=1, upper_bound=47) if n in opts}
if "galois_label" in query:
# Added by parse_galgrp, so we intersect with opts
if isinstance(query["galois_label"], dict):
Expand Down Expand Up @@ -1213,6 +1218,7 @@ def __init__(self):
("", ""),
("cyc", "cyclic"),
("ab", "abelian"),
("multi_quad", "multi-quadratic"),
("dih_ngal", "dihedral non-Galois"),
("dih_gal", "dihedral Galois"),
("gal", "Galois"),
Expand Down
20 changes: 14 additions & 6 deletions lmfdb/utils/search_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,20 +380,28 @@ def parse_range2rat(arg, key, process):

# We parse into a list of singletons and pairs, like [[-5,-2], 10, 11, [16,100]]
# If split0, we split ranges [-a,b] that cross 0 into [-a, -1], [1, b]
def parse_range3(arg, split0=False):
def parse_range3(arg, split0=False, lower_bound=None, upper_bound=None):
if isinstance(arg, str):
arg = arg.replace(" ", "")
if "," in arg:
return sum([parse_range3(a, split0) for a in arg.split(",")], [])
return sum([parse_range3(a, split0, lower_bound, upper_bound) for a in arg.split(",")], [])
elif "-" in arg[1:]:
ix = arg.index("-", 1)
start, end = arg[:ix], arg[ix + 1:]
if start:
low = ZZ(str(start))
if lower_bound is not None:
low = max(low, lower_bound)
elif lower_bound is not None:
low = lower_bound
else:
raise SearchParsingError("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).")
if end:
high = ZZ(str(end))
if upper_bound is not None:
high = min(high, upper_bound)
elif upper_bound is not None:
high = upper_bound
else:
raise SearchParsingError("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).")
if low == high:
Expand All @@ -413,15 +421,15 @@ def parse_range3(arg, split0=False):
else:
return [ZZ(str(arg))]

def integer_options(arg, max_opts=None, contained_in=None):
def integer_options(arg, max_opts=None, contained_in=None, lower_bound=None, upper_bound=None):
if not LIST_RE.match(arg) and MULT_PARSE.fullmatch(arg):
# Make input work using some arithmetic expressions
try:
ast_expression = ast.parse(arg.replace("^", "**"), mode="eval")
arg = str(int(PowMulNodeVisitor().visit(ast_expression).body))
except (TypeError, ValueError, SyntaxError):
raise SearchParsingError("Unable to evaluate expression.")
intervals = parse_range3(arg)
intervals = parse_range3(arg, lower_bound=lower_bound, upper_bound=upper_bound)
check = max_opts is not None and contained_in is None
if check and len(intervals) > max_opts:
raise ValueError("Too many options.")
Expand Down Expand Up @@ -698,12 +706,12 @@ def parse_not_element_of(inp, query, qfield, parse_singleton=int):
# Parses signed ints as an int and a sign the fields these are stored are passed in as qfield = (sign_field, abs_field)
# see SearchParser.__call__ for actual arguments when calling
@search_parser(clean_info=True, prep_ranges=True)
def parse_signed_ints(inp, query, qfield, parse_one=None):
def parse_signed_ints(inp, query, qfield, parse_one=None, lower_bound=None, upper_bound=None):
if parse_one is None:
def parse_one(x): return (int(x.sign()), int(x.abs())) if x != 0 else (1, 0)
sign_field, abs_field = qfield
if SIGNED_LIST_RE.match(inp):
parsed = parse_range3(inp, split0=True)
parsed = parse_range3(inp, split0=True, lower_bound=lower_bound, upper_bound=upper_bound)
# if there is only one part, we don't need an $or
if len(parsed) == 1:
parsed = parsed[0]
Expand Down

0 comments on commit bb2c2a1

Please sign in to comment.