Repository navigation
feat: graph_spec — semantic model extraction (model-figures phase 1) - #1606
Merged
Merged
Conversation
…, part 1) Pure extraction of a model's structure into frozen dataclasses: component nesting tree, ParamRow as independent properties (sampling / sharing / dimensionality / provenance), shared / relation / assertion edges, a model.info path index and reconciling counts. No drawing, no matplotlib. Tests cover the 18-construct catalogue and determinism. Collapse rules land in the next commit. Refs #1605 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ9stuFNR4e9BF5GXsqvfv
…figures phase 1, part 2) Sibling Model components collapse into plates by class tree + prior configuration (R1), split by cross-member shared priors (R2) under the review's safety condition (sharing, relations, assertions and exceptions must match across members). Plates group over find_groups so their keys read as model.info prints them, and the path index records where the figure's partition is finer than model.info's. Sharing now counts direct occurrences only, so a relation operand is related, not shared. Acceptance: the epic's three lens models as structural doubles mirroring the workspace scripts (autofit may not import autolens). The MGE case meets every epic invariant; the group-scale double is today's smaller script composition, so its counts are pinned as measured and annotated. Refs #1605 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ9stuFNR4e9BF5GXsqvfv
An unset optional attribute such as Basis(regularization=None) is not a parameter slot and model.info prints nothing for it, so emitting a row marked in_model_info=True broke the correspondence contract. Refs #1605 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ9stuFNR4e9BF5GXsqvfv
This was referenced Sep 11, 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
Phase 1 of the
model-figuresepic (PyAutoMinddraft/feature/autofit/model_figures_epic.md): the semantic extraction layer every later figure renders over. A newautofit/graph_spec.pyturns anyAbstractPriorModelinto a frozen, JSON-stable nesting tree —ComponentNodes in declaration order, oneParamRowper parameter slot carrying independent properties (sampling statusfree|fixed|solved|missing, sharing as prior id + path occurrences, dimensionality with per-slot tuple components, provenance with relation expressions), plusSharedEdge/RelationEdge/AssertionEdge, amodel.infopath index and reconciling counts. Sibling components collapse into plates by rules R1 (class tree + prior configuration) and R2 (split by cross-member shared priors) under the review's safety condition (sharing, relations, assertions and exceptions must match), grouping over the existingfind_groups.It draws nothing and imports no matplotlib (asserted by a test).
af.VisualiseGraphis untouched. Closes #1605.API Changes
Added only —
af.GraphSpec(withGraphSpec.from_model(model, analysis=None, collapse=True, solved_paths=())) and the aliasaf.graph_spec_from(model, **kwargs), plus the dataclassesComponentNode,ParamRow,PlateInfo,Provenance,SharedEdge,RelationEdge,AssertionEdgeinautofit.graph_spec. No existing symbol changed.See full details below.
Test Plan
python -m pytest test_autofit/graph_spec— 18-construct catalogue, collapse rules (R1 / R2 / safety condition / fixed tuple rows /Model(int)rows), determinism (byte-identicalto_dict()across runs and id resets), matplotlib-purity subprocess check, and the three lens acceptance models as structural doubles.python -m pytest test_autofit/— full suite green locally (serial;test_prior_bounds_1489.py::TestEmceeContainmentfailed once on the first run and passed on re-run — a stochastic sampler test untouched by this diff).Acceptance cases vs the epic's targets
The three lens models are structural doubles of today's
autolens_workspacescripts (autofit may not import autolens; phase 3 re-runs these on the real classes). Structural invariants are asserted unconditionally; where a faithful double cannot reproduce one of the epic's prototype numbers, the measured value is pinned with an# epic target: N -- measured Mcomment.intensityrows counted)bulge, mass, shearell_comps, shared 60,60,30,30,30,30, 16 unique sampled scalars,areas_factormissingDelaunayhas nopixelsModel(int)) → 11 boxes, two ×30 plates split onell_comps, shared 60/60/30/30/30/30, 16 unique sampled scalars,areas_factor=missingsigmarecorded asvaries_by_membergroup/modeling.pycomposition shares no priors between galaxies and is far smaller than the prototype's model)0 - 7, per-galaxy fixedcentretuples present andvaries_by_member, nothing fixed droppedDeterminism: every acceptance extraction run twice is byte-identical.
Full API Changes (for automation & release notes)
Added
autofit.GraphSpec— frozen dataclass;GraphSpec.from_model(model, analysis=None, collapse=True, solved_paths=()),to_dict(),components(),node(path),rows(),row(path); fieldsroot,shared,relations,assertions,path_index,counts.autofit.graph_spec_from(model, **kwargs)— alias forGraphSpec.from_model.autofit.graph_spec.ComponentNode,ParamRow,PlateInfo,Provenance,SharedEdge,RelationEdge,AssertionEdge— the spec's record types.Migration
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01UJ9stuFNR4e9BF5GXsqvfv
Generated by Claude Code