Repository navigation
fix: EP projection KeyError for a prior shared across model paths (#1773) - #1778
Merged
Merged
Conversation
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>
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1773.
Result.projected_model(the EP projection step) raised aKeyErrorwhen one prior is shared by several model paths, for example onecentreprior tied across the Gaussians of a multi-Gaussian expansion. Each sample stores a shared prior's value under only one of its aliases, butSamples.values_for_pathlooked it up under the exact path it was given.values_for_pathnow 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 ruleSample.parameter_lists_for_pathsalready uses. An unknown path still raisesKeyError.This unblocks the
ep_gnfw_slopeEP smoke test (MGE source, 20 Gaussians sharing one centre/ell_comps prior).API Changes
None — internal changes only.
Samples.values_for_pathkeeps its signature; for a shared prior it now returns the values instead of raisingKeyError.See full details below.
Test Plan
test_autofit/graphical/test_unification.py:values_for_pathreturns the shared prior's values under any alias, an unknown path raisesKeyError, andprojected_modelworks for a model with a shared priortest_autofit/graphical/test_unification.py+test_autofit/non_linear/samples: 132 passedtest_autofitsuite: 4291 passed, 2 skipped, 1 xfailedvalues_for_path/projected_model: no callers affectedFull 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 raisingKeyError. Unshared paths behave as before.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code