Skip to content

Fix hypergeometric famhodge search, add Hodge polygon plot, and 404 malformed labels - #7161

Open
roed-math wants to merge 3 commits into
LMFDB:mainfrom
roed-math:ai/t30-hgm-fixes
Open

Fix hypergeometric famhodge search, add Hodge polygon plot, and 404 malformed labels#7161
roed-math wants to merge 3 commits into
LMFDB:mainfrom
roed-math:ai/t30-hgm-fixes

Conversation

@roed-math

Copy link
Copy Markdown
Contributor

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 /data routes and the specialization value t), while a full motive label pasted as a single path segment 301-redirects to the motive page. The unescaped . in HGM_LABEL_RE was also fixed.

New tests cover all three items and the full hypergm suite passes (35).

Note: the hgm.hodge_polygon knowl 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

roed314 and others added 3 commits July 19, 2026 11:37
…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]&degree=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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HGM improvements

2 participants