Skip to content

Commit b6f9e1a

Browse files
authored
Merge pull request #6430 from roed314/grp_hash
Search based on hash
2 parents 944282a + 5c12b33 commit b6f9e1a

1 file changed

Lines changed: 43 additions & 5 deletions

File tree

lmfdb/groups/abstract/main.py

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
abstract_group_label_regex = re.compile(r"^(\d+)\.((\d+)|[a-z]+)$")
9797
# order_stats_regex = re.compile(r'^(\d+)(\^(\d+))?(,(\d+)\^(\d+))*')
9898

99+
abstract_group_hash_regex = re.compile(r"^(\d+)#(\d+)$")
100+
99101
def yesno(val):
100102
return "yes" if val else "no"
101103

@@ -190,6 +192,25 @@ def parse_family(inp, query, qfield):
190192
else:
191193
query[qfield] = {'$in':list(db.gps_special_names.search({'family':inp}, projection='label'))}
192194

195+
@search_parser
196+
def parse_hashes(inp, query, qfield, order_field):
197+
if inp.count("#") == 0:
198+
opts = [ZZ(opt) for opt in inp.split(",")]
199+
if len(opts) == 1:
200+
query[qfield] = opts[0]
201+
else:
202+
query[qfield] = {"$or": opts}
203+
elif inp.count("#") == 1:
204+
N, hsh = inp.split("#")
205+
N, hsh = ZZ(N), ZZ(hsh)
206+
if order_field not in query:
207+
query[order_field] = N
208+
elif query[order_field] != N:
209+
raise ValueError(f"You cannot specify order both in the {order_field} input and the {qfield} input")
210+
query[qfield] = hsh
211+
else:
212+
raise ValueError("To specify multiple hash values, all must have the same order; provide the order in the order input and then just give hashes separated by commas")
213+
193214
#input string of complex character label and return rational character label
194215
def q_char(char):
195216
return char.rstrip(digits)
@@ -940,6 +961,16 @@ def group_jump(info):
940961
flash_error(f"Transitive group {jump} is not in the database")
941962
return redirect(url_for(".index"))
942963
return redirect(url_for(".by_label", label=label))
964+
#hash
965+
hre = abstract_group_hash_regex.fullmatch(jump)
966+
if hre:
967+
N, hsh = [ZZ(c) for c in hre.groups()]
968+
if N <= 2000 and (N < 512 or N.valuation(2) < 7):
969+
# Less useful here, since we mostly have group ids in this regime, but we include it for completeness
970+
possible_labels = list(db.gps_groups.search({"order":N, "hash": hsh}, "label"))
971+
if len(possible_labels) == 1:
972+
return redirect(url_for(".by_label", label=possible_labels[0]))
973+
return redirect(url_for(".index", hash=jump))
943974
# or as product of cyclic groups
944975
if CYCLIC_PRODUCT_RE.fullmatch(jump):
945976
invs = [n.strip() for n in jump.upper().replace("C", "").replace("X", "*").replace("^", "_").split("*")]
@@ -1194,6 +1225,7 @@ def group_parse(info, query):
11941225
parse_noop(info, query, "name")
11951226
parse_ints(info, query, "order_factorization_type")
11961227
parse_family(info, query, "family", qfield="label")
1228+
parse_hashes(info, query, "hash", order_field="order")
11971229

11981230
subgroup_columns = SearchColumns([
11991231
LinkCol("label", "group.subgroup_label", "Label", get_sub_url, th_class=" border-right", td_class=" border-right"),
@@ -2054,7 +2086,7 @@ class GroupsSearchArray(SearchArray):
20542086
("irrQ_degree", r"$\Q$-irrep degree", ["irrQ_degree", "counter"])
20552087
]
20562088
jump_example = "8.3"
2057-
jump_egspan = "e.g. 8.3, GL(2,3), 8T34, C3:C4, C2*A5, C16.D4, or 12.4.2.b1.a1"
2089+
jump_egspan = "e.g. 8.3, GL(2,3), 8T34, C3:C4, C2*A5, C16.D4, 6#1, or 12.4.2.b1.a1"
20582090
jump_prompt = "Label or name"
20592091
jump_knowl = "group.find_input"
20602092

@@ -2360,7 +2392,7 @@ def __init__(self):
23602392
knowl="group.find_input",
23612393
example="C16.D4",
23622394
)
2363-
name = SneakySelectBox(
2395+
order_factorization_type = SneakySelectBox(
23642396
name="order_factorization_type",
23652397
label="Order",
23662398
knowl="group.order_factorization_type",
@@ -2403,15 +2435,15 @@ def __init__(self):
24032435
example_span="4, or a range like 3..5",
24042436
)
24052437
number_autjugacy_classes = TextBox(
2406-
name="number_autjugacy_classes ",
2438+
name="number_autjugacy_classes",
24072439
label="Num. of aut. classes",
24082440
knowl="group.autjugacy_class",
24092441
example="3",
24102442
example_span="4, or a range like 3..5",
24112443
advanced=True
24122444
)
24132445
number_characteristic_subgroups = TextBox(
2414-
name="number_characteristic_subgroups ",
2446+
name="number_characteristic_subgroups",
24152447
label="Num. of char. subgroups",
24162448
knowl="group.characteristic_subgroup",
24172449
example="3",
@@ -2432,6 +2464,12 @@ def __init__(self):
24322464
knowl="group.families",
24332465
label="Family",
24342466
)
2467+
hsh = SneakyTextBox(
2468+
name="hash",
2469+
label="Hash",
2470+
knowl="group.hash",
2471+
example="5120#4714647875464396655",
2472+
)
24352473

24362474
count = CountBox()
24372475

@@ -2477,7 +2515,7 @@ def __init__(self):
24772515
[frattini_label, derived_length, rank, schur_multiplier],
24782516
[supersolvable, monomial, rational],
24792517
[number_characteristic_subgroups, number_autjugacy_classes, number_divisions],
2480-
[name],
2518+
[name, order_factorization_type, hsh],
24812519
]
24822520

24832521
sort_knowl = "group.sort_order"

0 commit comments

Comments
 (0)