Skip to content

Commit 00d2259

Browse files
committed
Search based on hash
1 parent 98447b2 commit 00d2259

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

lmfdb/groups/abstract/main.py

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

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

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

194+
@search_parser
195+
def parse_hashes(inp, query, qfield, order_field):
196+
if inp.count("#") == 0:
197+
opts = [ZZ(opt) for opt in inp.split(",")]
198+
if len(opts) == 1:
199+
query[qfield] = opts[0]
200+
else:
201+
query[qfield] = {"$or": opts}
202+
elif inp.count("#") == 1:
203+
N, hsh = inp.split("#")
204+
N, hsh = ZZ(N), ZZ(hsh)
205+
if order_field not in query:
206+
query[order_field] = N
207+
elif query[order_field] != N:
208+
raise ValueError(f"You cannot specify order both in the {order_field} input and the {qfield} input")
209+
query[qfield] = hsh
210+
else:
211+
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")
212+
192213
#input string of complex character label and return rational character label
193214
def q_char(char):
194215
return char.rstrip(digits)
@@ -939,6 +960,16 @@ def group_jump(info):
939960
flash_error(f"Transitive group {jump} is not in the database")
940961
return redirect(url_for(".index"))
941962
return redirect(url_for(".by_label", label=label))
963+
#hash
964+
hre = abstract_group_hash_regex.fullmatch(jump)
965+
if hre:
966+
N, hsh = [ZZ(c) for c in hre.groups()]
967+
if N <= 2000 and (N < 512 or N.valuation(2) < 7):
968+
# Less useful here, since we mostly have group ids in this regime, but we include it for completeness
969+
possible_labels = list(db.gps_groups.search({"order":N, "hash": hsh}, "label"))
970+
if len(possible_labels) == 1:
971+
return redirect(url_for(".by_label", label=possible_labels[0]))
972+
return redirect(url_for(".index", hash=jump))
942973
# or as product of cyclic groups
943974
if CYCLIC_PRODUCT_RE.fullmatch(jump):
944975
invs = [n.strip() for n in jump.upper().replace("C", "").replace("X", "*").replace("^", "_").split("*")]
@@ -1193,6 +1224,7 @@ def group_parse(info, query):
11931224
parse_noop(info, query, "name")
11941225
parse_ints(info, query, "order_factorization_type")
11951226
parse_family(info, query, "family", qfield="label")
1227+
parse_hashes(info, query, "hash", order_field="order")
11961228

11971229
subgroup_columns = SearchColumns([
11981230
LinkCol("label", "group.subgroup_label", "Label", get_sub_url, th_class=" border-right", td_class=" border-right"),
@@ -2359,7 +2391,7 @@ def __init__(self):
23592391
knowl="group.find_input",
23602392
example="C16.D4",
23612393
)
2362-
name = SneakySelectBox(
2394+
order_factorization_type = SneakySelectBox(
23632395
name="order_factorization_type",
23642396
label="Order",
23652397
knowl="group.order_factorization_type",
@@ -2402,15 +2434,15 @@ def __init__(self):
24022434
example_span="4, or a range like 3..5",
24032435
)
24042436
number_autjugacy_classes = TextBox(
2405-
name="number_autjugacy_classes ",
2437+
name="number_autjugacy_classes",
24062438
label="Num. of aut. classes",
24072439
knowl="group.autjugacy_class",
24082440
example="3",
24092441
example_span="4, or a range like 3..5",
24102442
advanced=True
24112443
)
24122444
number_characteristic_subgroups = TextBox(
2413-
name="number_characteristic_subgroups ",
2445+
name="number_characteristic_subgroups",
24142446
label="Num. of char. subgroups",
24152447
knowl="group.characteristic_subgroup",
24162448
example="3",
@@ -2431,6 +2463,12 @@ def __init__(self):
24312463
knowl="group.families",
24322464
label="Family",
24332465
)
2466+
hsh = SneakyTextBox(
2467+
name="hash",
2468+
label="Hash",
2469+
knowl="group.hash",
2470+
example="5120#4714647875464396655",
2471+
)
24342472

24352473
count = CountBox()
24362474

@@ -2476,7 +2514,7 @@ def __init__(self):
24762514
[frattini_label, derived_length, rank, schur_multiplier],
24772515
[supersolvable, monomial, rational],
24782516
[number_characteristic_subgroups, number_autjugacy_classes, number_divisions],
2479-
[name],
2517+
[name, order_factorization_type, hsh],
24802518
]
24812519

24822520
sort_knowl = "group.sort_order"

0 commit comments

Comments
 (0)