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
10 changes: 7 additions & 3 deletions test_autolens/model_figure/lens_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,19 @@ def mge_basis(total_gaussians: int = 30, gaussian_per_basis: int = 2):
return af.Model(al.lp_basis.Basis, profile_list=bulge_gaussian_list)


def mge_pixelized():
def mge_pixelized(regularization=None):
"""
Acceptance case (b) -- MGE lens light, pixelized source.

The lens is the 2 x 30 MGE of
``features/multi_gaussian_expansion/modeling.py`` plus an ``Isothermal`` and
an ``ExternalShear``; the source is the ``Pixelization`` of
``features/pixelization/modeling.py`` built on a ``Delaunay`` mesh, whose
``areas_factor`` has no prior configured and is therefore ``missing``.
``areas_factor`` is configured as a ``Constant`` and is therefore ``fixed``.

``regularization`` swaps the ``ConstantSplit`` for another real class --
``al.reg.CurvatureMask``, whose ``coefficient`` has no prior configured, is
the case's witness of the ``missing`` state.
"""
lens = af.Model(
al.Galaxy,
Expand All @@ -126,7 +130,7 @@ def mge_pixelized():
pixelization = af.Model(
al.Pixelization,
mesh=af.Model(al.mesh.Delaunay, pixels=500, zeroed_pixels=0),
regularization=af.Model(al.reg.ConstantSplit),
regularization=af.Model(regularization or al.reg.ConstantSplit),
)

source = af.Model(al.Galaxy, redshift=1.0, pixelization=pixelization)
Expand Down
35 changes: 31 additions & 4 deletions test_autolens/model_figure/test_acceptance_lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,37 @@ def test__mge__shared_centre_is_badged_on_its_owner():
assert "shared across group" in badges


def test__mge__areas_factor_is_missing_on_the_mesh(mge_spec):
def test__mge__areas_factor_is_a_fixed_constant_on_the_mesh(mge_spec):
row = rows_of(mge_spec)["galaxies.source.pixelization.mesh.areas_factor"]

assert row.sampling == "fixed"
assert row.prior_cls_name == "Constant"


def test__mge__unconfigured_regularization_coefficient_is_missing():
# `CurvatureMask` ships no prior for `coefficient`: the real-class witness
# of the `missing` state (it was `Delaunay.areas_factor` until that was
# configured as a Constant).
import autolens as al

model = lens_models.mge_pixelized(regularization=al.reg.CurvatureMask)
spec = af.GraphSpec.from_model(model)

row = rows_of(spec)["galaxies.source.pixelization.regularization.coefficient"]

assert row.sampling == "missing"
assert row.prior_cls_name == "ConfigException"
assert spec.counts["missing"] == 1
# the missing coefficient is not sampled: one fewer than the case's 14
assert spec.counts["unique_sampled_scalars"] == model.prior_count == 13

presentation = af.ModelPlotter(model).presentation()

card = card_of(presentation, "galaxies/source/pixelization/regularization")
pill = pill_named(card, "coefficient")

assert pill is not None
assert pill.text == "coefficient · missing"


def test__mge__reconstruction_is_solved_on_the_pixelization_card():
Expand Down Expand Up @@ -215,11 +241,12 @@ def test__mge__counts(mge_spec):
assert mge_spec.counts["plates"] == 2
# `centre_0`, `centre_1`, and each basis's own `ell_comps` pair.
assert mge_spec.counts["shared_priors"] == 6
assert mge_spec.counts["fixed_leaf_slots"] == 64
# `pixels`, `zeroed_pixels` and the Constant `areas_factor` among them.
assert mge_spec.counts["fixed_leaf_slots"] == 65
# 60 member intensities plus the source reconstruction.
assert mge_spec.counts["solved"] == 61
# `Delaunay.areas_factor`, which has no prior configured.
assert mge_spec.counts["missing"] == 1
# nothing in the case is unconfigured (see the `CurvatureMask` witness).
assert mge_spec.counts["missing"] == 0


# ---------------------------------------------------------------------------
Expand Down
Loading