From 540751fab375f2361a7813561dda29327038ccbc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Aug 2026 13:52:11 +0000 Subject: [PATCH] fix: mge_model_from honours the centre_fixed value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _make_centre_priors returned centre[0], centre[1] when centre_fixed was set, silently ignoring the centre_fixed value — any caller passing only centre_fixed=(y, x) got Gaussians fixed at the default (0.0, 0.0) centre. Surfaced while writing the HowToLens scaling-relation tutorial; the workspace scaling-relation scripts pass only centre_fixed and are affected. Existing tests never caught it because they always used centre_fixed=(0.0, 0.0), which coincides with the default centre; a regression test with a non-zero fixed centre now pins the behaviour. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01BxKfSZisjnEn91LRGkN4SU --- autogalaxy/analysis/model_util.py | 2 +- test_autogalaxy/analysis/test_model_util.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/autogalaxy/analysis/model_util.py b/autogalaxy/analysis/model_util.py index 66db8131..a5f02750 100644 --- a/autogalaxy/analysis/model_util.py +++ b/autogalaxy/analysis/model_util.py @@ -127,7 +127,7 @@ def mge_model_from( def _make_centre_priors(): if centre_fixed is not None: - return centre[0], centre[1] + return centre_fixed[0], centre_fixed[1] elif centre_prior_is_uniform: return ( af.UniformPrior( diff --git a/test_autogalaxy/analysis/test_model_util.py b/test_autogalaxy/analysis/test_model_util.py index 5a3a352f..7a830ada 100644 --- a/test_autogalaxy/analysis/test_model_util.py +++ b/test_autogalaxy/analysis/test_model_util.py @@ -74,6 +74,19 @@ def test__mge_model_from__centre_fixed_with_two_bases(): assert model.prior_count == 4 +def test__mge_model_from__centre_fixed_uses_the_fixed_value(): + model = ag.model_util.mge_model_from( + mask_radius=1.0, + total_gaussians=5, + gaussian_per_basis=1, + centre_fixed=(1.5, -2.5), + ) + assert model.prior_count == 2 + + instance = model.instance_from_prior_medians() + assert instance.profile_list[0].centre == (1.5, -2.5) + + def test__mge_model_from__centre_fixed_overrides_centre_per_basis(): model = ag.model_util.mge_model_from( mask_radius=1.0,