Fix hypergeometric famhodge search, add Hodge polygon plot, and 404 malformed labels - #7161
Open
roed-math wants to merge 3 commits into
Open
Fix hypergeometric famhodge search, add Hodge polygon plot, and 404 malformed labels#7161roed-math wants to merge 3 commits into
roed-math wants to merge 3 commits into
Conversation
…DB#3406) Three good-first-issue fixes for hypergeometric motives: - (a) A bare famhodge query now defaults to a family search (the family Hodge vector is a family-level invariant), so it returns matching families instead of zero motives; an explicit motive search on famhodge with no matches flashes a link to the family search. - (b) New plot.hodge_polygon_plot renders the Hodge polygon (abelian-variety / local-field Newton-polygon style, scaled to a 2:1 box) on family and motive pages of positive weight. - (c) Malformed labels (family, motive, /plot/*, bad t) return 404 instead of 500 or a redirect-with-flash; a full motive label pasted as one path segment 301-redirects to the motive page. Escaped the unescaped '.' in HGM_LABEL_RE. Verified with the flask test client on devmirror and pytest lmfdb/hypergm (35 passed); pyflakes clean. Added tests for (a), (b) and (c). Note: the hgm.hodge_polygon knowl does not yet exist (content proposed in PR). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review follow-up on the famhodge work. SearchWrapper handles shortcuts such as download before it calls the wrapped hgm_search, so inferring the search type inside hgm_search came too late: the Download link rendered on a bare ?famhodge=[1,5,1] page preserves the original URL, so on the download request info["search_type"] was still empty, the family query ran against db.hgm_motives, and the download came back with zero rows while the page showed 104 families. default_search_type is now applied in index() before hgm_search is called, and also in HGMDownload.get_table (which writes the normalized value back to info, so the sort order and the contingent t/conductor columns agree with the table). Explicit search_type/hst still wins. hgm_postprocess counted families using only the famhodge part of the query and built its link from famhodge alone, so an impossible search such as ?famhodge=[1,5,1]°ree=999&search_type=Motive announced 104 matching families and linked to a search that had silently dropped degree=999. It now counts with the full parsed query -- under its guard every constraint left in the query is a column of hgm_families too -- and builds the link from the request arguments, dropping motive-only fields and the mode/pagination/download arguments while keeping degree, weight, A/B, the p-parts and the display choices. The message now refers to the whole search and agrees in number. Verified: sage -python -m pytest lmfdb/hypergm/test_hgm.py -> 40 passed (was 35); pyflakes clean. New tests follow the rendered Download link of the bare famhodge page, check that an impossible extra constraint produces no hint, that a compatible extra constraint (A=[7,2]) is carried into the family link, and the singular wording; the Hodge polygon assertion now matches the heading and its data-URI image together and a weight 0 page is checked to have no polygon. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3406.
This addresses the three open items of the HGM good-first-issue checklist.
(a) A bare family-Hodge-vector query such as
?famhodge=[1,5,1]now runs a family search (the family Hodge vector is a family-level invariant) and returns the matching families instead of zero motives; an explicit motive search on a family Hodge vector with no matching motives flashes a link to the corresponding family search.(b) A Hodge polygon is now displayed on family and motive pages of positive weight, rendered in the style of the abelian-variety and local-field Newton polygons (grid, shaded region, convex polygon line, vertex markers) and scaled to a consistent 2:1 box.
(c) Malformed labels now return a clean 404 instead of a 500 or a redirect-with-flash (this includes the family, motive,
/plot/*and/dataroutes and the specialization valuet), while a full motive label pasted as a single path segment 301-redirects to the motive page. The unescaped.inHGM_LABEL_REwas also fixed.New tests cover all three items and the full
hypergmsuite passes (35).Note: the
hgm.hodge_polygonknowl still needs to be created (proposed text is in the old PR thread).Ported from roed-math#25, where the full write-up and comment history live.
🤖 Generated with Claude Code