fix(mass_stellar_dark): drop assertions, rename alpha→deflections#192
Merged
Conversation
The two `mass_stellar_dark/` scripts (`fit.py`, `likelihood_function.py`) carried `assert np.allclose(...)` lines comparing a manual stellar + dark + shear deflection sum against the `Tracer`/`Galaxy` total. These asserts belong in a `_test` workspace, not in tutorial scripts. Underlying NaN at r=0 in `NFWSph` is fixed in PyAutoGalaxy on the same branch; this commit removes the asserts and renames the local `alpha_*` variables to `deflections_*` so the tutorial code mirrors the library's `deflections_yx_2d_from` API. Math-prose `α(θ)` notation in the docstrings is intentionally left as-is (lensing literature convention). 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
scripts/imaging/features/advanced/mass_stellar_dark/(fit.py,likelihood_function.py) carriedassert np.allclose(...)lines comparing a manual stellar + dark + shear deflection sum against theTracer/Galaxytotal. Asserts belong in a_testworkspace, not in tutorial scripts — removed.alpha_*variables todeflections_*so the tutorial code mirrors the library'sdeflections_yx_2d_fromAPI. Math-proseα(θ)notation in the docstrings is intentionally left as-is (lensing-literature convention).Why now
The asserts were also failing on
mainbecause of a NaN at the origin pixel insideNFWSph.deflections_2d_via_analytic_from. The library fix lives in PyAutoLabs/PyAutoGalaxy#430 on the same branch name (feature/nfw-sph-deflection-origin-fix). This PR should land after PyAutoGalaxy#430.Scripts Changed
scripts/imaging/features/advanced/mass_stellar_dark/fit.py— 5alpha_*→deflections_*, 5 prints updated, 1 assert removed.scripts/imaging/features/advanced/mass_stellar_dark/likelihood_function.py— 4alpha_*→deflections_*, 4 prints updated, 1 assert removed.Test plan
python scripts/imaging/features/advanced/mass_stellar_dark/fit.pyruns end-to-end (no warnings, no AssertionError). Stellar+dark+shear summed deflection matcheslens.deflections_yx_2d_from(grid)to machine precision.python scripts/imaging/features/advanced/mass_stellar_dark/likelihood_function.pyruns end-to-end. Manual source-plane grid matchestracer.traced_grid_2d_list_from(grid)[1]to machine precision.🤖 Generated with Claude Code