Repository navigation
Expose the swept factor graph on EPResult for the EP state figure (#1620) - #1621
Merged
Merged
Conversation
factor_graph.optimise() builds its EPOptimiser (and so the graph it sweeps) internally and returned only the history and mean field, so a caller could not draw af.EPPlotter(kind="state") without private API: the plotter needs the optimiser's own graph, because FactorGraphModel.graph rebuilds and renames prior factors on every access and the history is keyed by the swept one. EPResult now carries factor_graph (additive, default None). Docs show the high-level form. Refs #1620 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DLx38vS6F1M7K5LnpVbeZ7
This was referenced Sep 13, 2026
Collaborator
Author
|
Workspace PRs: PyAutoLabs/autofit_workspace#154, PyAutoLabs/HowToFit#52 — merge this library PR first (library-first gate). |
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
Phase 6a of the model-figures rollout (issue #1620) puts the model figure beside every
model.infoinautofit_workspaceand HowToFit, including the EP state figure after an expectation-propagation run. Doing that from a workspace script exposed one gap:FactorGraphModel.optimise(...)builds itsEPOptimiser, and so the factor graph it sweeps, internally, and returned only the history and the mean field.af.EPPlotter(kind="state")needs the optimiser's own graph, because the EP history is keyed by its factor objects andFactorGraphModel.graphbuilds a fresh graph, renaming prior factors, on every access.EPResultnow carriesfactor_graph, the swept graph, so the high-level form is one line:docs/features/graphical.md("Seeing the EP run") shows that form beside the existing optimiser form. The two workspace PRs on the same-named branch consume it.Opened under Heart RED
release validation FAILED (stage integrate)(unrelated autolens integrate scripts) with explicit human authorisation on 2026-09-13; merge stays human via/prm.API Changes
Additive only.
EPResult.__init__gains a trailing keywordfactor_graph=Noneand stores it asEPResult.factor_graph;optimise()populates it. Nothing removed, renamed or made required.See full details below.
Test Plan
test_autofit/graphical/test_ep_result_factor_graph.py(new, 4 tests):result.factor_graphis set afteroptimise, is a freshDeclarativeFactorGraphdistinct fromFactorGraphModel.graph(whosePriorFactornames differ), the state figure renders from it with noabsentfactor, andEPResult(...)without the keyword still constructs.test_autofit/graphical/gaussian/test_declarative.py: theStubEPOptimiserdouble gainsfactor_graph = Noneso the stub matches the real optimiser's surface.test_autofit: 2847 passed / 2 skipped (baseline 2843 + 4 new).docs/sphinx_warning_baseline.txt.abstract.pycarries pre-existing black drift outside this hunk, left as is).Full API Changes (for automation & release notes)
Added
autofit.graphical.declarative.result.EPResult.factor_graph— theDeclarativeFactorGraphthe EP optimiser swept;EPResult(..., factor_graph=None)keyword, populated byAbstractDeclarativeFactor.optimise().Changed Behaviour
AbstractDeclarativeFactor.optimise()passesfactor_graph=opt.factor_graphinto the returnedEPResult. No change to the history or mean field it returns.Migration
af.EPPlotter(result.factor_graph, ep_history=result.ep_history).figure(kind="state").Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DLx38vS6F1M7K5LnpVbeZ7