Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion autogalaxy/profiles/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,14 @@ def image_2d_list_from(
)
elif kwargs.get("binned", True) is False:
image_2d_list.append(xp.zeros((grid.over_sampled.shape[0],)))
else:
elif isinstance(grid, aa.Grid2D):
image_2d_list.append(
aa.Array2D(values=xp.zeros((grid.shape[0],)), mask=grid.mask)
)
else:
image_2d_list.append(
aa.ArrayIrregular(values=xp.zeros((grid.shape[0],)))
)

return image_2d_list

Expand Down
19 changes: 19 additions & 0 deletions test_autogalaxy/profiles/test_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ def test__image_2d_from__returns_array2d_for_linear_only_basis(grid_2d_7x7):
assert isinstance(image, aa.Array2D)


def test__image_2d_from__grid_2d_irregular__linear_profile_placeholder_has_no_mask():
# Regression test: the linear-intensity-unknown placeholder used to be built as
# `Array2D(..., mask=grid.mask)`, which raised `AttributeError: Grid2DIrregular
# does not have attribute mask` whenever a basis containing a linear light
# profile was evaluated on an irregular grid (as JIT-traced likelihood paths do).
grid = aa.Grid2DIrregular(values=[(1.0, 1.0), (2.0, 2.0), (3.0, 3.0)])

lp = ag.lp.Sersic(intensity=0.1)
lp_linear = ag.lp_linear.Sersic(effective_radius=2.0, sersic_index=2.0)

basis = ag.lp_basis.Basis(profile_list=[lp, lp_linear])

image = basis.image_2d_from(grid=grid)

assert isinstance(image, aa.ArrayIrregular)
assert image.shape == (3,)
assert image == pytest.approx(np.asarray(lp.image_2d_from(grid=grid)), 1.0e-8)


def test__image_2d_from__operated_only_false__returns_only_non_operated_profile_image(
grid_2d_7x7, lp_0, lp_operated_0
):
Expand Down
Loading