Skip to content

fix: EP projection KeyError for a prior shared across model paths (#1773) - #1778

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/ep-projected-model-shared-prior
Nov 18, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/ep-projected-model-shared-prior

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1773. Result.projected_model (the EP projection step) raised a KeyError when one prior is shared by several model paths, for example one centre prior tied across the Gaussians of a multi-Gaussian expansion. Each sample stores a shared prior's value under only one of its aliases, but Samples.values_for_path looked it up under the exact path it was given.

values_for_path now resolves the path to the group of all paths naming the same prior (Samples.paths) and reads the value under whichever alias the sample holds. This is the same rule Sample.parameter_lists_for_paths already uses. An unknown path still raises KeyError.

This unblocks the ep_gnfw_slope EP smoke test (MGE source, 20 Gaussians sharing one centre/ell_comps prior).

API Changes

None — internal changes only. Samples.values_for_path keeps its signature; for a shared prior it now returns the values instead of raising KeyError.
See full details below.

Test Plan

  • New tests in test_autofit/graphical/test_unification.py: values_for_path returns the shared prior's values under any alias, an unknown path raises KeyError, and projected_model works for a model with a shared prior
  • test_autofit/graphical/test_unification.py + test_autofit/non_linear/samples: 132 passed
  • Full test_autofit suite: 4291 passed, 2 skipped, 1 xfailed
  • Heart dev-ship readiness for PyAutoFit: GREEN (shown, non-blocking: manifest drift in generated blocks/hooks; no release rehearsal for current source)
  • Downstream grep of workspaces and dependent libraries for values_for_path / projected_model: no callers affected
Full API Changes (for automation & release notes)

Changed Behaviour

  • Samples.values_for_path(path) — a path naming a prior shared with other paths now resolves to that prior's values under whichever alias each sample stores, instead of raising KeyError. Unshared paths behave as before.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

A prior shared by several model paths is stored in each sample's kwargs
under only one alias, so Result.projected_model (EP projection) raised a
KeyError when it asked for another alias. values_for_path now resolves
the path to its group of aliases and reads whichever one the sample
holds, matching Sample.parameter_lists_for_paths. Adds unit tests for
shared priors in values_for_path and projected_model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Nov 18, 2026
@Jammy2211
Jammy2211 merged commit fea8c01 into main Nov 18, 2026
6 checks passed
@Jammy2211
Jammy2211 deleted the feature/ep-projected-model-shared-prior branch November 18, 2026 12:57
@pyautolabs-bot pyautolabs-bot Bot removed the pending-release PR queued for the next release build label Nov 19, 2026
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.

fix: EP projection KeyError for a prior shared across model paths

1 participant