Add Szpiro ratio for elliptic curves over number fields - #33
Conversation
Add a szpiro_ratio column (classical Szpiro ratio log(Norm(D_min))/log(Norm(N)), Hindry p.8) to the ECNF section: curve page display, search box, search-results column and sort order, all guarded by a module-level flag so the site keeps working until the column is added to ec_nfcurves. The ratio is left NULL for the 712 curves with everywhere good reduction, for which it is not defined. scripts/ecnf/generate_szpiro_ratio.py computes the column for all 767518 curves from stored data (conductor_norm, normdisc, non_min_p, local_data) in about 3 minutes, cross-checking the two available formulas against each other, and has a --verify mode that recomputes random rows from scratch with Sage. Verified: full generation run with --verify 25 (all match to 1e-12); base changes of 11.a1/11.a2/37.a1 agree with the classical Q-side ratios including ramified-prime scaling; lmfdb/ecnf/test_ecnf.py passes (13 tests) with the column absent; pyflakes clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # lmfdb/ecnf/main.py
Review follow-up on the Szpiro ratio for elliptic curves over number fields. The mathematical definition and the frontend are unchanged. - main.py: document HAVE_SZPIRO_RATIO as a startup-time compatibility guard. It, the result columns, the search array and the sort choices are all built at import, so adding the column does not activate the feature in a running worker; the workers have to be restarted. - generate_szpiro_ratio.py: spell out the migration order (generate, knowl, add column, upload, index, restart, smoke test), including the ec_nfcurves_szpiro_ratio_sort btree matching the sort tuple, created after update_from_file so the swap does not build it twice. - generate_szpiro_ratio.py: fail closed. Every data-integrity assert is now an explicit ValueError/RuntimeError naming the curve; the two partition counts must add up to the table count and the rows written must match the expected number; rows stream to a temporary file that replaces the output path only after all cross-checks, the count checks and any --verify have passed, so no partial file is left where it could be uploaded. --sample-check N now makes exactly N checks (positions drawn with random.sample over the rows actually processed, not a Bernoulli frequency from the full table count), the numeric flags must be nonnegative, --verify above the generated row count errors clearly, and --seed makes the sampling reproducible. - test_ecnf.py: the positive search test no longer passes when the constraint is ignored. With the column present the test asserts the displayed value 1.0 on the curve page, that a 0.5-1.5 range contains the full curve url while a disjoint 1.1-1.5 range does not, that sort_order=szpiro_ratio un-hides the column, and that an everywhere-good-reduction curve shows no ratio row; without it, the compatibility branch only claims that the pages still load. New schema-independent tests cover the generator helpers. Verified: pytest -k szpiro (2 passed) and pyflakes/pylint/ruff clean; the curve-page markup and the everywhere-good-reduction omission checked against a simulated column-present row, since devmirror has no szpiro_ratio column yet; a bounded run (--limit 1000 --sample-check 100 --verify 20) wrote exactly 2000 rows and made exactly 100 cross-checks; an injected mismatch exited nonzero leaving the previous output intact and no temporary file behind. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Pushed 1ab4984 with the review follow-up. The classical definition and the frontend design are unchanged; what changed is the deployment contract, the index, the tests and the generator's failure behaviour. The PR description has been corrected too. 1. Activation contract. 2. Index. Deployment step 5 creates 3. Tests. The old positive search proved nothing, since the same curve comes back when the constraint is ignored. With the column present, One thing worth knowing for the test: the curve-page assertion matches the label text, not the knowl markup, because 4. Fail closed. Every data-integrity 5. Verified
Not yet possible here: devmirror has no 🤖 Generated with Claude Code |
Adds the classical Szpiro ratio$\sigma = \log|N(\mathfrak{D}_{\mathrm{min}})|/\log N(\mathfrak{N})$ (Hindry) to the ECNF section: curve homepage display, search box, results column and sort order. All uses are guarded by a check that the
szpiro_ratiocolumn exists inec_nfcurves, so this is safe to deploy before the data upload.That check is a startup-time compatibility guard, not a live one: it, the result columns, the search array and the sort choices are all built when
lmfdb.ecnf.mainis imported, so adding the column does not make the feature appear in a running web worker (and neither doesdb.refresh_tables()). The migration therefore ends with a restart. The full order (generate and verify the file, create theec.szpiro_ratioknowl, add the column, upload, create the index backing the new range search and sort, restart every web worker, smoke test display/search/sort) is written out in the generator's docstring.Includes
scripts/ecnf/generate_szpiro_ratio.py, which computes the ratio for all 767518 curves from stored invariants in ~3 minutes (NULL for the 712 curves with everywhere good reduction, where the ratio is undefined), cross-checks two independent formulas on every non-minimal-model row plus exactly--sample-checkminimal-model rows, and can re-verify random rows from scratch in Sage; values were additionally checked against base changes of Q-curves with known ratios. Being a one-time production migration it fails closed: every integrity problem raises with the offending label and exits nonzero, and rows are streamed to a temporary file that replaces the output path only once the row counts match and all cross-checks and the requested--verifyhave passed. Addresses LMFDB#6292.🤖 Generated with Claude Code