Repository navigation
feat: __solved_parameters__ protocol for model figures + Model cls fix (PyAutoLens#736) - #1615
Merged
Merged
Conversation
Model figures phase 3. A class can now declare the quantities a fit solves
for it -- `__solved_parameters__ = ("intensity",)` -- and graph_spec adds
them as `solved` rows (provenance `solved-by-fit`, absent from model.info)
without PyAutoFit knowing the class. `solved_paths=` is additive too: an
entry matching no row is synthesised on its owner instead of being ignored.
Rule R7 now drops `af.Model(cls)` for any int/float subclass, so a free
`Redshift` is a pill on its galaxy card rather than a one-pill child card.
The presentation shows `name · solved` pills and counts them in the footer.
Also fixes `Model.constructor_argument_names` leaking the bound `cls`
argument of a custom `__new__` into the parameter list, which made
`af.Model(Redshift)` overwrite its own `cls` with a ConfigException.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0178yLU9v19GtACcRPFggjGa
Collaborator
Author
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 3 of the
model-figuresepic, PyAutoFit half (PyAutoLens#736; phases 1–2: #1606, #1614). PyAutoFit cannot know which lens parameters a fit solves rather than samples, andsolved_paths=could only re-tag rows that already exist — a linear light profile has nointensityslot at all. This PR adds a class-declared protocol: a class sets__solved_parameters__ = ("intensity",)andgraph_specappends asolvedrow for each declared name that is not a slot (re-tagging it when it is), with provenancesolved-by-fitandin_model_info=False. No lens class name appears in PyAutoFit; PyAutoGalaxy and PyAutoArray declare the attribute onLightProfileLinear,PointSolvedandPixelizationin the sibling PRs. Because the per-searchmodel.pngcallsModelPlotter(model)bare, it inherits the semantics automatically.Also:
solved_paths=is now additive (an unmatched path is synthesised on its owner, never silently ignored); rule R7 dropsaf.Model(cls)for anyint/floatsubclass so a freeRedshiftrenders as an ordinary pill on its galaxy card; the presentation showsname · solvedand a footerN parameters solved during fitting;counts["solved"]added.Bug fix found on the way:
Model.constructor_argument_namesfiltered onlyself, so for a class with a custom__new__(cls, …)(autogalaxy.Redshift(float))clsleaked in as a parameter andaf.Model(Redshift)overwrote its own.clswith aConfigException. The bound first argument is now dropped whether it isselforcls.API Changes
Added the
__solved_parameters__class-attribute protocol consumed byaf.GraphSpec/af.ModelPlotter;solved_paths=became additive;af.Modelof anint/floatsubclass is a row on its owner in the figure;af.Model(cls)with a custom__new__no longer mis-parsesclsas a parameter. No symbol removed or renamed. See full details below.Test Plan
test_autofit/graph_spec66 passed (14 new intest_solved.py),test_autofit/model_figure80 passed (4 new),test_autofit/non_linear/paths/test_model_figure_output.py9 passed — serial.test_autofit2732 passed / 2 skipped; black + pyflakes clean.autogalaxy.Redshift:af.Model(ag.Redshift).cls is ag.Redshift, config prior resolves,instance_from_prior_medians().redshift == 1.5.lib-tests3.12 / 3.13 / no-jax,docs.Full API Changes (for automation & release notes)
Added
__solved_parameters__: tuple[str, ...]on any modelled class;af.GraphSpec.from_modelappends asolvedrow (provenancesolved-by-fit,in_model_info=False) per declared name that is not a slot and re-tags a declared name that is.Provenance.kindvaluesolved-by-fit.GraphSpec.counts["solved"](solved scalars on the uncollapsed tree).name · solvedpill text; footer phraseN parameter(s) solved during fitting.Changed Behaviour
GraphSpec.from_model(..., solved_paths=): an entry matching no row is synthesised as a solved row on its owner node (root when the owner is not a component) instead of being ignored.Model(int)/Model(float)is a row on its owner) now applies to anyint/floatsubclass (e.g.autogalaxy.Redshift).Model.constructor_argument_namesdrops the bound first argument whether it isselforcls— fixesaf.Modelof a class with a custom__new__.Migration
__solved_parameters__on their classes (PyAutoArray / PyAutoGalaxy sibling PRs).Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_0178yLU9v19GtACcRPFggjGa