From 76ab23dda6bc16b2aeab64d7c4384cfa84bd46a4 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sun, 27 Sep 2026 12:33:34 +0100 Subject: [PATCH] test(model_figure): move the missing-state witness off Delaunay.areas_factor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PyAutoGalaxy now configures Delaunay.areas_factor as a Constant (0.5), so the MGE pixelized acceptance case has no unconfigured parameter: areas_factor is a fixed Constant row, fixed_leaf_slots 64 -> 65, missing 1 -> 0. The real-class witness of the `missing` state moves to the same lens model with its regularization swapped for al.reg.CurvatureMask, whose `coefficient` still has no prior configured (row missing/ConfigException, one missing, 13 sampled, "coefficient · missing" pill). mge_pixelized() takes an optional regularization class; its docstring is updated. Refs PyAutoLabs/PyAutoMind#441 Co-Authored-By: Claude Opus 5.5 --- test_autolens/model_figure/lens_models.py | 10 ++++-- .../model_figure/test_acceptance_lens.py | 35 ++++++++++++++++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/test_autolens/model_figure/lens_models.py b/test_autolens/model_figure/lens_models.py index 4be78bf12..024999e17 100644 --- a/test_autolens/model_figure/lens_models.py +++ b/test_autolens/model_figure/lens_models.py @@ -105,7 +105,7 @@ 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. @@ -113,7 +113,11 @@ def mge_pixelized(): ``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, @@ -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) diff --git a/test_autolens/model_figure/test_acceptance_lens.py b/test_autolens/model_figure/test_acceptance_lens.py index 346268b60..7484ebb13 100644 --- a/test_autolens/model_figure/test_acceptance_lens.py +++ b/test_autolens/model_figure/test_acceptance_lens.py @@ -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(): @@ -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 # ---------------------------------------------------------------------------