test: pin FitEllipse masked-points-loop behaviour#395
Merged
Conversation
Add 5 unit tests + a 30x30 imaging fixture to test_autogalaxy/ellipse/ test_fit_ellipse.py that cover every branch of the 300-iteration mask-rejection loop in autogalaxy/ellipse/fit_ellipse.py:69-136: zero-masked, under-masked (trim), over-masked (extra-points), unreachable (ValueError), and the multipole inner branch. Pinned to rtol=1e-12 reference arrays where the path is deterministic; spot-checks where the iteration count varies. Numpy-only. Step 3 of 7 in z_features/ellipse_fitting_jax.md. Prompt 6 will rewrite this loop with JAX-friendly oversample-then-NaN-mask; these tests are the regression target it must reproduce. Issue #394. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Pin the current behaviour of
FitEllipse.points_from_major_axis_from's 300-iteration mask-rejection loop with five new unit tests intest_autogalaxy/ellipse/test_fit_ellipse.py. Step 3 of 7 in theellipse_fitting_jaxfeature decomposition — prompt 6 will rewrite this loop with a JAX-friendly oversample-then-NaN-mask approach; these tests are the regression target it must reproduce.Each test pins one of the four loop branches plus a multipole variant. Where the loop converges deterministically (zero-masked, under-masked-trim, multipole), the full
(N, 2)returned array is pinned atrtol=1e-12. Where the iteration count varies more (over-masked-extra-points), the first and last point are spot-checked at the same tolerance.zero_maskedunder_masked_trimover_masked_extra_pointsunreachable_raisesValueErrorwith_multipole_under_maskedunder_masked_trimwithEllipseMultipole(m=4)— pins the inner multipole branch at lines 113-120All tests numpy-only per
PyAutoGalaxy/CLAUDE.md's "Never use JAX in unit tests" rule. JAX parity will be checked in the workspace_test scripts shipped in prompt 2 once prompt 7 lands.Issue #394.
API Changes
None — test additions only.
Test Plan
python -m pytest test_autogalaxy/ellipse/test_fit_ellipse.py -vpasses (16/16: 11 pre-existing + 5 new)python -m pytest test_autogalaxy/passesRegularGridInterpolatoris deterministic)🤖 Generated with Claude Code