Repository navigation
feat: model figures phase 2 — matplotlib renderer + opt-in model.png (#1613) - #1614
Merged
Merged
Conversation
Phase 2 of the model-figures epic. A pure-matplotlib containment figure
drawn over the phase-1 GraphSpec: name-first pills inside component cards,
plates for repeated siblings ("N components"), sharing as a blue badge with
gutter links, relation pills showing their expression, dashed assertion
labels, missing/solved states, a one-line legend and a defined-count
footer. Text size is fixed; scalability comes from collapse and a width
budget that wraps top-level cards in declaration order.
- autofit/model_figure/{presentation,layout,render,plotter}.py, exported
as af.ModelPlotter(model).figure(path=None, filename="model",
format="show|png|svg|pdf", detail="names|priors", collapse=True,
max_depth=None, show_fixed=True, width=14.0)
- DirectoryPaths._save_model_info writes model.png beside model.info when
the NEW output.yaml key `model_figure` is true. The key is read strictly
(absent -> off) so it cannot switch on in configs that lack it; a render
failure is logged and never raised.
- 85 new tests (vocabulary rules, width budget, fixed text size,
declaration order, determinism, file output, config gate).
- Acceptance renders committed under docs/images/model_figures/ with the
script that regenerates them; figures embedded in the model,
multi_level_model and multiple_datasets cookbook docs.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0178yLU9v19GtACcRPFggjGa
This was referenced Sep 11, 2026
Collaborator
Author
|
Workspace PR: PyAutoLabs/autofit_workspace#152 |
This was referenced Sep 11, 2026
Merged
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 2 of the
model-figuresepic (issue #1613; phase 1 was #1606). Draws the phase-1GraphSpecas a pure-matplotlib containment figure: the figure is the map (which component owns which parameter, what is shared, fixed, related, constrained, missing),model.infostays the legend (priors and values). One vocabulary at every scale: white component cards with name-first pills, dashed plates badgedN componentsfor repeated siblings, a blueshared across group/↗ ownerbadge with links routed through a dedicated gutter, cream relation pills carrying their defining expression, dashed orangeassert …labels with both operands, a redmissingstate,2Dtags on tuples,redshift = 0.5as a card subtitle, a one-line legend and a footer with defined counts (16 unique sampled scalars · 63 fixed leaf slots · 6 shared priors (unique variables, not references) · 2 plates standing for 60 components).Text size is fixed; scalability comes from collapsing content and a width budget (default 14 in at 100 dpi) that wraps top-level cards in declaration order, never masonry. Zero new dependencies; graphviz deliberately not adopted.
af.VisualiseGraphuntouched.Per-search output:
model.pngbesidemodel.info, behind a newoutput.yamlkeymodel_figure(defaultfalse). The key is read strictly, absent → off, becauseshould_output's fallback todefault: truewould otherwise switch the figure on in every config that has not added the key yet. A render failure is logged and never raised, so a figure bug cannot kill a fit.model_graphis not reused (it gates graphical-model text, #1264).Acceptance renders (structural doubles of the lens models until phase 3 renders the real PyAutoLens classes) are committed as evidence under
docs/images/model_figures/withmake_figures.py; the three cookbook docs pages embed them.Evidence renders
30 componentsplates split onell_comps,areas_factor · missing, footer16 unique sampled scalarscentre · fixed, varies by member,independentpriorsAPI Changes
Added
af.ModelPlotter(newautofit.model_figurepackage) and a new, default-offoutput.yamlkeymodel_figure. No existing symbol removed, renamed or changed. See full details below.Test Plan
test_autofit/model_figure76 passed,test_autofit/graph_spec52 passed (the matplotlib-purity test forautofit.graph_specstill green),test_autofit/non_linear/paths/test_model_figure_output.py9 passed — serial.test_autofitsuite green in the worktree before commit (counts in the ship report).model_figure: truewritesmodel.pngbesidemodel.info;falseand absent write nothing; renderer failure leavesmodel.infointact and raises nothing.docs/sphinx_warning_baseline.txt.lib-tests3.12 / 3.13 + no-jax leg,docs.Full API Changes (for automation & release notes)
Added
autofit.model_figure.ModelPlotter(model, analysis=None, solved_paths=())— exported asaf.ModelPlotter.ModelPlotter.figure(path=None, filename="model", format="show", detail="names", collapse=True, max_depth=None, show_fixed=True, width=14.0) -> matplotlib.figure.Figure—format ∈ show|png|svg|pdf(mirrorsautofit.plot.output_figure);pathis a directory.ModelPlotter.spec(),.presentation(...),.layout(...)— the three layers, for tests and tooling.autofit.model_figure.presentation.build_presentation,autofit.model_figure.layout.build_layout/Style,autofit.model_figure.render.draw/save— layer entry points (semi-public).output.yamlkeymodel_figure: false— writesmodel.pngbesidemodel.infoper search whentrue; read strictly (absent → off), unlike every other output key.autofit.non_linear.paths.directory._model_figure_enabled()— private helper.Changed Behaviour
DirectoryPaths._save_model_infoadditionally writesmodel.pngwhenmodel_figureistrueand visualisation is not skipped by test mode; any exception is logged at INFO and swallowed.Migration
model_figure: trueto itsconfig/output.yaml.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_0178yLU9v19GtACcRPFggjGa