Allow group names in abstract-group label search boxes - #7173
Conversation
Group-label search boxes in the abstract groups section (center, commutator, central quotient, abelianization, aut/outer group, Frattini; subgroup/ambient/quotient; character group/image) now accept group names such as C6, S4, D8, Q8, C2^3, C2xC4, SL(2,7), GL(2,3), 8T3 and TeX-ish variants, resolved to labels by a new name_to_label helper reusing the jump-box resolution paths (stored names, cyclic products, special family names, transitive labels). Unknown or ambiguous names give a search input error naming the offending entry. Verified with sage -python parser-level checks (name queries identical to label queries) and flask test client via pytest (new tests test_search_by_name, test_search_by_name_subgroups, test_search_by_bad_name plus sibling label tests: 14 passed); pyflakes clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both parsers added by the previous commit tokenized their input with
inp.split(","), so a family name whose parameters contain a comma, such
as SL(2,7) or GL(2,3), was chopped into SL(2 and 7) and never reached
name_to_label -- exactly the names the search boxes advertise.
split_group_search_terms now splits only at commas outside (), [] and {},
and raises SearchParsingError for unbalanced delimiters or empty entries
so that they give the section's normal search input error rather than a
complaint about a truncated name. Both parse_group_label_or_order_or_name
and parse_group_label_or_name use it. (split_top_level_commas in
search_wrapper.py is deliberately lenient for jump boxes, so it is not
reused here.)
parse_group_label_or_order_or_name also dropped prep_plus=True, which
deletes every + in the input; that was harmless for labels and orders,
but it mangles the stored name SO+(4,2) (= 72.40) now that names are
accepted. A leading unary + is instead stripped from each entry, so +8
and +8.3 keep working while an internal + is preserved.
Tested with sage -python -m pytest lmfdb/groups/: the three affected
tests (test_search_by_name_with_commas, test_search_by_name_with_plus,
test_search_by_bad_name) fail on 6bcfa82 and pass here; pyflakes clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
It looks like this currently errors if you put "bird" as a group name in any of the search boxes. It does say
But it throws an error on the page instead of showing the search page again with the error message at the top. |
Reported on LMFDB#7173: entering an unrecognized group name such as "bird" in one of the group label search boxes gave a traceback page rather than the search page with the error message at the top. Wrapper.make_query re-raised every parsing error when app.debug is set, so this happened for any invalid search input in any section (e.g. order=bird on main does the same); the new name errors just made it visible. A SearchParsingError describes a problem with the user's input rather than a bug, so redisplay the search page for it in debug mode too. Other exceptions raised while parsing are still re-raised, so developers keep getting a traceback for actual bugs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks, good catch. The message was right but the presentation was wrong, and the cause turned out to be more general than this PR.
except Exception as err:
# Errors raised in parsing; these should mostly be SearchParsingErrors
if is_debug_mode():
raiseSo if the site is started with Since a
at the top in both modes. The commit adds One thing worth flagging: that commit touches shared code and so changes debug-mode behavior for every section, not just groups. I think it is the right call, since bad input is not a bug and should not look like one, but I am happy to pull it out into its own PR if you would rather keep this one confined to the group name search. |
|
LGTM now! |
Closes #6397.
Search boxes in the abstract groups section that take group labels (center, commutator, central quotient, abelianization, automorphism group, outer automorphism group, Frattini subgroup; subgroup/ambient/quotient in the subgroup search; group/image in the complex character search) now also accept group names, e.g.
C6,S4,D8,Q8,C2^3,C2xC4,SL(2,7),GL(2,3),8T3, and light TeX variants likeC_2^3orC_2\times C_4.Names are resolved to labels by a new
name_to_labelhelper that reuses the jump box's resolution paths (stored names, cyclic products via primary invariants, special family names, transitive labels), so a name works in a search box iff it works in the jump box.Comma-separated lists may mix labels, names, and (where previously allowed) orders. Only top-level commas split the list, so a family name whose parameters contain a comma stays in one piece, and unbalanced delimiters or empty entries give the section's search-input error. A
+inside a name such asSO+(4,2)is preserved, while a leading unary+on an order or label is still accepted. Unknown or ambiguous names produce a search-input error naming the offending entry.Adds tests pairing each name search with the existing sibling label test so the two stay in sync.
Composes with the multi-label Find box work in #7170: that change is an additive block at the top of
group_jump, placed before name resolution.Ported from roed-math#39, where the full write-up and comment history live.
🤖 Generated with Claude Code