Skip to content

fix: fill mock sample placeholders from prior medians, not a blanket 1.0 - #1471

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/autofit-mock-ones-parameters-bug-sv303m
Aug 13, 2026
Merged

fix: fill mock sample placeholders from prior medians, not a blanket 1.0#1471
Jammy2211 merged 1 commit into
mainfrom
claude/autofit-mock-ones-parameters-bug-sv303m

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Problem

MockSamplesSummary.__init__ and MockSamples.default_sample_list both filled every parameter with a blanket 1.0. That value is invalid for any parameter its prior constrains — notably an elliptical profile's ell_comps, which must have a magnitude below 1, so (1.0, 1.0) raises on construction.

MockResult builds its own MockSamplesSummary whenever a caller passes a model but no samples_summary:

samples_summary=samples_summary or MockSamplesSummary(model=model or ModelMapper())

So reading Result.instance on such a result raised. This surfaced as seven aggregator integration scripts failing across autogalaxy_workspace_test and autolens_workspace_test, with:

ModelParameterException: ell_comps must satisfy ell_comps[0]**2 + ell_comps[1]**2 < 1;
got (1.0, 1.0), whose magnitude is 1.4142135623730951

The failure is raised from inside MockSearch._fit_fast (mock_search.py:82, if self.result.instance is None), during search.fit(...) — not from the aggregator, and with no database round-trip involved.

Change

Adds a shared prior_median_kwargs(model) helper in mock_samples.py that fills from each prior's median, and routes all three copies of the old idiom through it:

  • MockSamplesSummary.__init__
  • MockSamples.default_sample_list
  • _make_samples in mock_search.py, which already used exactly this expression

Prior medians are always in range, so they are safe for every model. Consolidating leaves the idiom in one place rather than three, which is what allowed the copies to drift apart in the first place.

Tests

New test_autofit/non_linear/samples/test_mock_placeholders.py — 4 tests built on a guard class mirroring the ell_comps constraint, so the regression is covered inside PyAutoFit with no autogalaxy dependency. Verified to fail 3/4 against unpatched code.

Suite With change Baseline
test_autofit 1698 passed, 1 failed 1694 passed, 1 failed
test_autogalaxy 1081 passed, 0 failed 1081 passed, 0 failed
test_autolens 518 passed, 1 failed 518 passed, 1 failed
7 reported scripts 7/7 pass 7/7 pass

The two residual failures are pre-existing and unrelated (graphical/functionality/test_messages.py::test_beta, potential_correction/test_iterative_interferometer.py::test__solve_joint_optimization__identity_damping_finite); both reproduce without this change.

Controlled check that the fix is load-bearing: with physically-valid fixture values but no samples_summary passed, the scripts still failed at (1.0, 1.0) before this change and pass after it.

Related

Pairs with a one-line PyAutoGalaxy change letting ag.m.MockResult accept and forward samples_summary. Merge this one first.


Generated by Claude Code

MockSamplesSummary and MockSamples.default_sample_list filled every
parameter with 1.0. That is invalid for any parameter its prior
constrains -- notably an elliptical profile's ell_comps, which must have
a magnitude below 1, so (1.0, 1.0) raises on construction.

MockResult builds its own MockSamplesSummary when the caller passes a
model but no samples_summary, so reading Result.instance on such a result
raised. This surfaced as seven aggregator integration scripts failing in
autogalaxy_workspace_test and autolens_workspace_test, from inside
MockSearch._fit_fast rather than from the aggregator.

Fill from each prior's median instead, via a shared prior_median_kwargs
helper that _make_samples in mock_search.py now also uses -- the same
idiom it already applied, in one place rather than three.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XqpBSWF2JDx4L9g1YCQk67
@Jammy2211
Jammy2211 merged commit aea9a40 into main Aug 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants