Skip to content

fix: Basis linear-profile placeholder on irregular grids - #581

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/pixelization-eager-jit-divergence
Aug 21, 2026
Merged

fix: Basis linear-profile placeholder on irregular grids#581
Jammy2211 merged 1 commit into
mainfrom
feature/pixelization-eager-jit-divergence

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Fixes the Basis library bug found while unblocking
autolens_workspace_developer/jax_profiling/jit/imaging/pixelization.py
(PyAutoGalaxy#580).

The bug

Basis.image_2d_list_from builds the zero placeholder for its
LightProfileLinear members as:

aa.Array2D(values=xp.zeros((grid.shape[0],)), mask=grid.mask)

which assumes a masked Grid2D. Evaluating a basis that contains a linear light
profile on a Grid2DIrregular therefore raises:

AttributeError: Grid2DIrregular does not have attribute mask

Grid2DIrregular is the grid type JIT-traced likelihood paths use, so any such
path with a linear-light basis — an MGE lens light, for instance — was simply
unreachable.

The fix

Dispatch on grid type: ArrayIrregular for irregular grids, Array2D for
Grid2D. This mirrors how ArrayMaker.via_grid_2d / via_grid_2d_irr
(PyAutoArray/autoarray/structures/decorators/to_array.py) already choose the
return type for the non-linear profiles in the same list, so the placeholder
now matches its siblings instead of contradicting them.

Testing

  • New regression test in test_autogalaxy/profiles/test_basis.py: a Basis of
    one Sersic + one lp_linear.Sersic on a Grid2DIrregular returns an
    ArrayIrregular equal to the non-linear profile's image, instead of raising.
  • Full test_autogalaxy suite: 1113 passed.
  • End-to-end: with this fix the pixelization profiling script runs to completion
    and its rebuilt log-evidence matches FitImaging.figure_of_merit to 13
    significant 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

`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
@Jammy2211
Jammy2211 merged commit d1b46b9 into main Aug 21, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/pixelization-eager-jit-divergence branch August 21, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant