From 9d283da45ab3aeccd7023ba2fa92f83eb0a67469 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sat, 29 Aug 2026 16:09:19 -0400 Subject: [PATCH] feat: prior configs + docs for the AdaptPower regularization siblings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds prior configs for the four *Power regularization classes introduced in PyAutoArray (PyAutoLabs/PyAutoArray#512): adapt_power, adapt_split_power, adapt_split_zeroth_power and matern_adapt_power_kernel. Each is a copy of its legacy counterpart — the same LogUniform(1e-6, 1e6) coefficient priors, which now span lambda^2 rather than lambda^4 — plus a Constant prior fixing power at 1.0 so a non-linear search never samples the convention switch. Also adds AdaptPower / AdaptSplitPower to the docs/api pixelization autosummary, and a composition test proving the ag.reg re-export chain and the prior-config resolution. Depends on PyAutoLabs/PyAutoArray#512. Refs PyAutoLabs/PyAutoArray#511 --- .../priors/regularization/adapt_power.yaml | 34 ++++++++++++ .../regularization/adapt_split_power.yaml | 34 ++++++++++++ .../adapt_split_zeroth_power.yaml | 54 +++++++++++++++++++ .../matern_adapt_power_kernel.yaml | 54 +++++++++++++++++++ docs/api/pixelization.rst | 2 + test_autogalaxy/test_regularization_power.py | 38 +++++++++++++ 6 files changed, 216 insertions(+) create mode 100644 autogalaxy/config/priors/regularization/adapt_power.yaml create mode 100644 autogalaxy/config/priors/regularization/adapt_split_power.yaml create mode 100644 autogalaxy/config/priors/regularization/adapt_split_zeroth_power.yaml create mode 100644 autogalaxy/config/priors/regularization/matern_adapt_power_kernel.yaml create mode 100644 test_autogalaxy/test_regularization_power.py diff --git a/autogalaxy/config/priors/regularization/adapt_power.yaml b/autogalaxy/config/priors/regularization/adapt_power.yaml new file mode 100644 index 000000000..ce6f829eb --- /dev/null +++ b/autogalaxy/config/priors/regularization/adapt_power.yaml @@ -0,0 +1,34 @@ +AdaptPower: + inner_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + outer_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + signal_scale: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + power: + type: Constant + value: 1.0 diff --git a/autogalaxy/config/priors/regularization/adapt_split_power.yaml b/autogalaxy/config/priors/regularization/adapt_split_power.yaml new file mode 100644 index 000000000..64a9580c1 --- /dev/null +++ b/autogalaxy/config/priors/regularization/adapt_split_power.yaml @@ -0,0 +1,34 @@ +AdaptSplitPower: + inner_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + outer_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + signal_scale: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + power: + type: Constant + value: 1.0 diff --git a/autogalaxy/config/priors/regularization/adapt_split_zeroth_power.yaml b/autogalaxy/config/priors/regularization/adapt_split_zeroth_power.yaml new file mode 100644 index 000000000..65b695e8a --- /dev/null +++ b/autogalaxy/config/priors/regularization/adapt_split_zeroth_power.yaml @@ -0,0 +1,54 @@ +AdaptSplitZerothPower: + zeroth_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + zeroth_signal_scale: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + inner_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + outer_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + signal_scale: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + power: + type: Constant + value: 1.0 diff --git a/autogalaxy/config/priors/regularization/matern_adapt_power_kernel.yaml b/autogalaxy/config/priors/regularization/matern_adapt_power_kernel.yaml new file mode 100644 index 000000000..2bbac942d --- /dev/null +++ b/autogalaxy/config/priors/regularization/matern_adapt_power_kernel.yaml @@ -0,0 +1,54 @@ +MaternAdaptPowerKernel: + scale: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + nu: + type: Uniform + lower_limit: 0.5 + upper_limit: 5.5 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + inner_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + outer_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + signal_scale: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + power: + type: Constant + value: 1.0 diff --git a/docs/api/pixelization.rst b/docs/api/pixelization.rst index 0da8ab16d..f3632971a 100644 --- a/docs/api/pixelization.rst +++ b/docs/api/pixelization.rst @@ -69,6 +69,8 @@ Regularization [ag.reg] ConstantSplit Adapt AdaptSplit + AdaptPower + AdaptSplitPower Settings -------- diff --git a/test_autogalaxy/test_regularization_power.py b/test_autogalaxy/test_regularization_power.py new file mode 100644 index 000000000..7eafc3e0b --- /dev/null +++ b/test_autogalaxy/test_regularization_power.py @@ -0,0 +1,38 @@ +""" +Model-composition gate for the ``*Power`` regularization siblings added in PyAutoArray. + +These schemes are re-exported as ``ag.reg.*`` and carry their own prior configs +(``autogalaxy/config/priors/regularization/*_power.yaml``). Composing them proves both the re-export +chain and that the prior config resolves — including ``power``, which is fixed as a ``Constant`` +prior so a non-linear search never samples it. +""" + +import autofit as af +import autogalaxy as ag + + +def test__power_classes_are_re_exported(): + assert ag.reg.AdaptPower is not ag.reg.Adapt + assert ag.reg.AdaptSplitPower is not ag.reg.AdaptSplit + assert ag.reg.AdaptSplitZerothPower is not ag.reg.AdaptSplitZeroth + assert ag.reg.MaternAdaptPowerKernel is not ag.reg.MaternAdaptKernel + + +def test__model_composition__power_is_a_constant_and_is_not_sampled(): + model = af.Model(ag.reg.AdaptSplitPower) + + assert "power" not in [prior_tuple[0] for prior_tuple in model.prior_tuples] + assert model.instance_from_prior_medians().power == 1.0 + + assert set(prior_tuple[0] for prior_tuple in model.prior_tuples) == { + "inner_coefficient", + "outer_coefficient", + "signal_scale", + } + + +def test__model_identifier__differs_from_the_legacy_class(): + identifier_legacy = af.Model(ag.reg.AdaptSplit).identifier + identifier_power = af.Model(ag.reg.AdaptSplitPower).identifier + + assert identifier_legacy != identifier_power