Address #295 review: epsilon_tv, public rho_psi helper, gradient-test consolidation#310
Merged
Merged
Conversation
added 9 commits
June 21, 2026 22:08
…eep values/boundary/cm
…ck; drop pol FD now in canonical suite
…es in canonical FD suite)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev-backend #310 +/- ##
============================================
Coverage 47.43% 47.43%
============================================
Files 55 55
Lines 26978 26979 +1
Branches 4599 4599
============================================
+ Hits 12797 12798 +1
Misses 12689 12689
Partials 1492 1492 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
achael
approved these changes
Jun 22, 2026
achael
left a comment
Owner
There was a problem hiding this comment.
looks great! the test consolidation is quite helpful. no comments
Collaborator
Author
|
@achael Great! Merging this branch. |
rohandahale
pushed a commit
that referenced
this pull request
Jun 22, 2026
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.
Follow-up to #295 three review notes
Closes the three follow-up notes Andrew left when approving #295, in one PR off
dev-backend.1.
epsilon_tvin the spectral-index TVmultifreq_imager_utils.py:reg_tv_spec/reggrad_tv_specnow readepsilon = kwargs.get('epsilon_tv', 0.)like every other TV regularizer, and the hardcoded module-globalEPSILON = 1.e-12is gone. This makes the spectral TV consistent withreg_tv/reg_ptv/reg_vtvand lets a caller tune it through the existingepsilon_tvplumbing (RegParams→**reg_params._asdict()). Behavior note: the default smoothing flips1e-12 → 0to match the others.2.
_rho_psi_safe→ publicrho_psi_from_mfrac_vfracpol_imager_utils.py: the jax-NaN-safe ρ/ψ helper (double-whereguards at zero polarization) is now public, per Andrew's "could have utility outside the pol transforms." Pure rename + docstring; two call sites (mcv,vcv) updated.3. Gradient-test consolidation
The finite-difference gradient tests were scattered across five files with non-uniform methodology (forward vs central differences, per-pixel-relative vs scale-aware metrics, sampled vs full-grid), two real coverage holes, and a couple of tolerances loose enough to pass a real bug. This rebuilds them around one canonical FD suite and closes the gaps.
tests/test_gradients.py— the canonical numpy FD suite. Six parallel sections, one shared harness (central differences + max-fractional-error relative to the per-slot gradient scale + a non-vacuousness guard):REGULARIZERS(16, incl. l1, flux, flux_mf)REGULARIZERS_POL(8, all four slots,ptvun-xfailed)REGULARIZERS_SPECTRAL(12)Coverage holes closed.
logamp's gradient had no finite-difference check anywhere in the repo;l1/flux/flux_mfhad no numpy-suite FD check (the old tests iteratediu.REGULARIZERS= 12, but the dispatcher usesREGULARIZERS= 16). All now FD-validated. (logampis log|V|, singular at a visibility null, so its section uses a compact source +debias=Falseto keep |V| well-conditioned — the gradient itself is correct, verified analytically.)Tolerances tightened.
test_chisquared.py'sGRAD_MAX_TOL_NFFT = 10.0(direct↔nfft gradients actually agree to ~3e-5) is replaced by a1e-2bound; because the direct path is now FD-validated here, that bound effectively pins nfft gradient correctness. The pol-TV regularizer max tolerance of2.0is gone with the sampled tests it guarded.Redundancy removed / relabeled. The sampled forward-difference parity classes in
test_regularizers.pyand the pol FD intest_chisquared.pyare subsumed by the canonical suite and deleted (value tests, the TV boundary backstop,cm, and the epsilon-singularity test stay). The reg-only jax tests moved fromtest_objective_jax.pytotest_regularizers_jax.py.TestComputeRegularizerTermis relabeled as a routing/forwarding check (backend and legacy share the same leaf, so it is not a correctness test).Rigor check (bug injection). To confirm the suite actually catches bugs, three deliberate faults were injected and each was caught at a fractional error of 0.5–1.9 (≫ the 1e-3 tolerance), with unaffected siblings staying green; all reverted:
mcv_gradψ-cross-term (the historical bug class) → S6 mcv fails;chisqgrad_logamp→ S1 logamp fails;reggrad_tv_spec→ S5tv_*fail.