fix: Basis linear-profile placeholder on irregular grids - #581
Merged
Conversation
`Basis.image_2d_list_from` built the zero placeholder for its
`LightProfileLinear` members as `Array2D(values=..., mask=grid.mask)`,
which assumes a masked `Grid2D`. Evaluating a basis containing a linear
light profile on a `Grid2DIrregular` therefore raised
AttributeError: Grid2DIrregular does not have attribute mask
This is the grid type JIT-traced likelihood paths use, so any such path
with a linear-light basis (e.g. an MGE lens light) was unreachable —
`autolens_workspace_developer/jax_profiling/jit/imaging/pixelization.py`
died on it at step 2.
Return an `ArrayIrregular` for irregular grids and keep the `Array2D`
for `Grid2D`, mirroring how `ArrayMaker.via_grid_2d` / `via_grid_2d_irr`
already dispatch the non-linear profiles' return type. Regression test
added; full test_autogalaxy suite passes (1113).
Refs #580
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdsQ7c6y3iuiQf2jy8gx6K
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.
Fixes the
Basislibrary bug found while unblockingautolens_workspace_developer/jax_profiling/jit/imaging/pixelization.py(PyAutoGalaxy#580).
The bug
Basis.image_2d_list_frombuilds the zero placeholder for itsLightProfileLinearmembers as:which assumes a masked
Grid2D. Evaluating a basis that contains a linear lightprofile on a
Grid2DIrregulartherefore raises:Grid2DIrregularis the grid type JIT-traced likelihood paths use, so any suchpath with a linear-light basis — an MGE lens light, for instance — was simply
unreachable.
The fix
Dispatch on grid type:
ArrayIrregularfor irregular grids,Array2DforGrid2D. This mirrors howArrayMaker.via_grid_2d/via_grid_2d_irr(
PyAutoArray/autoarray/structures/decorators/to_array.py) already choose thereturn type for the non-linear profiles in the same list, so the placeholder
now matches its siblings instead of contradicting them.
Testing
test_autogalaxy/profiles/test_basis.py: aBasisofone
Sersic+ onelp_linear.Sersicon aGrid2DIrregularreturns anArrayIrregularequal to the non-linear profile's image, instead of raising.test_autogalaxysuite: 1113 passed.and its rebuilt log-evidence matches
FitImaging.figure_of_meritto 13significant figures.
Workspace follow-up (the script itself) is
autolens_workspace_developer
feature/pixelization-eager-jit-divergence.🤖 Generated with Claude Code
https://claude.ai/code/session_01SdsQ7c6y3iuiQf2jy8gx6K