Repository navigation
Description
Overview
All five public autofit.plot functions declare **kwargs and never reference it — a caller's customization is accepted without error and has no effect. The failure is silent: no TypeError, no warning, just a plot that ignores what you asked for. autofit_workspace/scripts/plot/*.py teaches the broken idiom at four call sites (76 kwargs), and states in prose that the kwargs are forwarded; PyAutoFit/docs/cookbooks/search.md carries the same claim. Verifying the report surfaced a second silent defect in the same call: corner_cornerpy passes weight_list= to corner.corner, which has no such parameter (it is weights) — so sample weights are currently ignored on every weighted corner plot.
Fix direction chosen: forward the kwargs, with a strict signature filter. Unrecognised names raise TypeError rather than vanishing. Both defects are fixed in the same wave.
Plan
- Add a shared kwargs-forwarding helper to
plot_util.pythat validates caller kwargs against the target function's named parameters and raisesTypeErroron anything unrecognised, with a did-you-mean hint. - Forward validated kwargs from all five plot functions to their underlying library (
corner.corner,anesthetic,matplotlib), with library-computed values acting as defaults the caller can override. - Fix the
weight_list=→weights=bug so weighted posteriors plot correctly. - Preserve the
_corner_range_fromdegenerate-column guard: it applies whenever the caller omitsrangeor passesNone. - Stop
@log_plot_exceptionswallowing the new validationTypeErroroncorner_anesthetic. - Rewrite the four workspace scripts' kwarg lists to genuine
corner.pykwargs and correct the prose that claims forwarding — three of the four were copy-pasted from a different sampler's plotting API. - Cover both defects with tests, and confirm test-mode/degenerate input still renders.
Detailed implementation plan
Work Classification
Both (library + workspace). The library PR merges first; the workspace PR follows behind the library-first merge gate.
Affected Repositories
PyAutoLabs/PyAutoFit(primary)PyAutoLabs/autofit_workspace
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| PyAutoFit | main |
clean |
| autofit_workspace | main |
clean |
worktree_check_conflict autofit-plot-functions-kwargs PyAutoFit autofit_workspace → exit 0 (no conflict). autofit_workspace carries a stale unregistered branch feature/plot-api-update (HEAD 389e968, "Regenerate notebooks from updated scripts") — a warning, not a block.
Suggested branch: claude/autofit-plot-functions-kwargs-vvwj5x (both repos)
Worktree root: ~/Code/PyAutoLabs-wt/autofit-plot-functions-kwargs/ (created later by /start_library)
Grounding
Verified against PyAutoFit 055bb3d99 and autofit_workspace 94671f62, with corner 2.3.0 installed and exercised.
The **kwargs are dead. grep -n kwargs over the three plot modules matches only def lines.
weights are dropped. corner.corner's signature has weights, not weight_list. Unrecognised names fall into corner_impl(**hist2d_kwargs) → hist2d(**kwargs), whose body reads only extent and discards the rest. Confirmed empirically: corner.corner(data=..., weight_list=w, ...) returns a figure with no error and unweighted contours.
Forwarding alone would not fix the tutorials. Because of that same hist2d sink, wrong-library kwargs would stay silently ignored one layer deeper. Measured against corner 2.3.0's real signature:
| script | kwargs | take effect | still dropped |
|---|---|---|---|
emcee_plotter.py |
30 | 30 | 0 |
dynesty_plotter.py |
19 | 14 | 5 — dims, span, quantiles_2d, hist2d_kwargs, truth_kwargs (dynesty's API) |
zeus_plotter.py |
16 | 6 | 10 — span, truth, alpha, linewidth, fill, fontsize, title_fontsize, cut, size, weight_list (zeus's API) |
nautilus_plotter.py |
11 | 8 | 3 — panelsize, yticksize, xticksize |
This is why the fix is forward + strict filter, not plain forwarding: the filter converts those 18 into loud errors, and the workspace rewrite removes them.
Collision hazards.
zeus_plotter.pypassesweight_list=None, which duplicates the library's ownweight_list=keyword →TypeError: got multiple values for keyword argument. A hard crash, not silence.rangecollides twice:emcee_plotter.pypassesrange=None,nautilus_plotter.pypassesrange=np.ones(n) * 0.999. Naive caller-wins defeats_corner_range_from's degenerate-column guard.corner_anestheticis wrapped in@log_plot_exception, which catchesTypeError— a validation error there would surface as a misleading "posterior estimate not yet sufficient" info log.
Implementation Steps — PyAutoFit (PR 1, merges first)
-
autofit/non_linear/plot/plot_util.py— add the forwarding helper:def forward_kwargs(kwargs, *, accepts, reserved=(), target=""):
acceptsis the set of parameter names the target genuinely honours; a target's own**kwargsis deliberately not treated as "accepts anything" (corner'shist2d_kwargssink is exactly the trap being closed). Unrecognised names raise aPlotKwargsError(TypeError)naming them, withdifflib.get_close_matchessupplying a hint (weight_list→ "did you meanweights?").reservednames arguments the library owns and the caller may never override.For corner,
accepts= named parameters ofcorner.corner∪ named parameters ofcorner.core.hist2d(minusx,y) — hist2d kwargs are a documented, legitimate pass-through, so they stay valid. -
samples_plotters.py::corner_cornerpyweight_list=→weights=.- Build
defaults = {"weights": ..., "labels": ..., "range": _corner_range_from(data)}, validate the caller's kwargs, thendefaults.update(validated).dataisreserved. range: the guard is the default, so it applies when the caller omitsrangeor passesNone; a non-Nonecaller value wins.- Keep the existing
data.ndim < 2 or data.shape[0] <= data.shape[1]early return.
-
nest_plotters.py::corner_anesthetic— route validated kwargs to their actual targets (make_2d_axesvsNestedSamples.plot_2d); anything matching neither raises. Narrow@log_plot_exceptionto re-raisePlotKwargsErrorso validation failures are not reported as an unconverged posterior. -
mle_plotters.py—subplot_parameters,log_likelihood_vs_iteration,figure_of_merit_vs_iteration: forward validated kwargs toplt.plot/plt.semilogy(Line2Dproperties), reservingc. -
Internal callers —
abstract_mcmc.py:56,abstract_nest.py:77,abstract_mle.py:38-64pass onlysamples/path/format/the explicit flags, so no call-site changes; confirm none regress. -
docs/cookbooks/search.md:165— the 30-kwarg emcee list stays valid (all 30 are genuine corner kwargs); update the surrounding prose to state that kwargs are forwarded and validated. -
Tests —
test_autofit/non_linear/plot/test_samples_plotters.py(+ new modules for nest/mle):- a recognised kwarg reaches the target (monkeypatch
corner.corner, assert receipt); - an unrecognised kwarg raises
TypeErrornaming it; weightsis passed through asweights=and equalssamples.weight_list;- caller
range=Nonestill yields the_corner_range_fromguard; a non-Nonerangewins; - degenerate-column input (every sample equal) still renders without corner's "no dynamic range" crash;
corner_anestheticvalidation error is not swallowed by@log_plot_exception.
- a recognised kwarg reaches the target (monkeypatch
Implementation Steps — autofit_workspace (PR 2, behind the library-first gate)
- Rewrite the four
scripts/plot/*.pykwarg lists to genuinecorner.pykwargs only — drop dynesty's 5, zeus's 10, nautilus's 3.zeus_plotter.py'sweight_list=Nonemust go. - Correct the prose in each script so the claim matches behaviour (kwargs are forwarded to
corner.pyand validated). - Regenerate the notebooks from the scripts per workspace convention.
Verify
- A call passing a non-default kwarg (e.g.
bins=5) visibly changes the output figure. - A bogus kwarg raises
TypeErrornaming it, rather than being ignored. - Weighted samples produce a visibly different corner figure than the same samples unweighted.
- Degenerate-column input (e.g. a
PYAUTO_TEST_MODE=1run) still renders — the_corner_range_fromguard survives. - No workspace script still passes an argument that does nothing.
Key Files
autofit/non_linear/plot/plot_util.py— newforward_kwargshelper +PlotKwargsError;log_plot_exceptionnarrowedautofit/non_linear/plot/samples_plotters.py—corner_cornerpy: forwarding + theweightsfixautofit/non_linear/plot/nest_plotters.py—corner_anesthetic: split forwardingautofit/non_linear/plot/mle_plotters.py— the three matplotlib trace plotsdocs/cookbooks/search.md— prose claim about kwargstest_autofit/non_linear/plot/test_samples_plotters.py— extended coverageautofit_workspace/scripts/plot/{emcee,dynesty,zeus,nautilus}_plotter.py— kwarg lists + prose
Sizing note
pyauto-brain bug and the sizing faculty both return too-large (score 13) and recommend phasing. Recorded and overridden: the score is inflated by prompt word-count plus the multi-repo flag. The actual change is ~15 lines of library code, four workspace scripts, and one docs snippet — the prompt's own Difficulty: small header is the better estimate. Not phased; one library PR plus its paired workspace PR.
Original Prompt
Click to expand starting prompt
autofit.plot functions accept **kwargs and silently discard them
Type: bug
Target: autofit
Repos:
- PyAutoFit
- autofit_workspace
Difficulty: small
Autonomy: supervised
Priority: normal
Status: formalised
Filed: 2026-08-07 (backfilled from git)
Filed 2026-08-07, found while fixing docs/api/plot.rst
(complete/2026/08/pyautofit_plot_rst_dead_plotters.md). Deliberately left out of
that PR: it is a library/workspace defect, not a docs one, and the docs change
was docs-only by design.
The defect
All five public autofit.plot functions take **kwargs in their signature and
never reference it in the body. Verified mechanically — kwargs appears in
autofit/non_linear/plot/{samples_plotters,nest_plotters,mle_plotters}.py only
on the def lines:
corner_cornerpy(samples, path=None, filename="corner", format="show", **kwargs)corner_anesthetic(samples, path=None, filename="corner_anesthetic", format="show", **kwargs)subplot_parameters(...),log_likelihood_vs_iteration(...),
figure_of_merit_vs_iteration(...)— same shape
corner_cornerpy calls the underlying library with a fixed argument set:
corner.corner(
data=data,
weight_list=samples.weight_list,
labels=samples.model.parameter_labels_with_superscripts_latex,
range=_corner_range_from(data),
)So a caller's customization is accepted without error and has no effect. The
failure mode is the bad one: silent. No TypeError, no warning, just a plot
that ignores what you asked for.
Why it matters — the workspace teaches the broken idiom
autofit_workspace/scripts/plot/*.py passes long kwarg lists as though they
were forwarded, and says so in prose: "In all the examples below, we use the
kwargs of this function to pass in any of the input parameters that are
described in the API docs." That claim is false today.
Silently-discarded kwargs at those call sites (counted 2026-08-07):
| script | discarded kwargs |
|---|---|
scripts/plot/emcee_plotter.py |
30 |
scripts/plot/dynesty_plotter.py |
19 |
scripts/plot/zeus_plotter.py |
16 |
scripts/plot/nautilus_plotter.py |
11 |
| total | 76 |
A user following the plot tutorials sets bins, smooth, show_titles,
truths, … and sees none of them applied. The tutorials are the documentation
for this API, so this is the primary way the behaviour is encountered.
The decision to make (why supervised, not auto)
Two coherent fixes; picking one is a judgement about the intended surface:
- Forward them — pass
**kwargsthrough tocorner.corner/
anesthetic/ matplotlib. Matches what the workspace already claims and
makes the existing tutorials correct as written. Watch the collisions:
corner_cornerpyalready setsdata,weight_list,labelsandrange
explicitly, andrangein particular is computed by_corner_range_from
to dodge corner's "no dynamic range" crash on degenerate columns — a
user-suppliedrangemust not silently reintroduce that. Decide precedence
(caller wins / library wins) and state it. - Drop
**kwargsfrom the signatures and correct the workspace scripts +
prose. Honest, and callers get a loudTypeErrorinstead of silence — but
it removes customization the tutorials imply exists, so it is the bigger
user-facing change.
Either way the workspace scripts and their prose need updating in the same
wave, so this is a paired PyAutoFit + autofit_workspace task.
Verify
- A call passing a non-default kwarg (e.g.
bins=5) visibly changes the
output figure (fix 1), or raisesTypeError(fix 2). - The four
scripts/plot/*.pytutorials and their surrounding prose agree with
whichever behaviour was chosen — no script still passes an argument that does
nothing. - Degenerate-column input (every sample equal, e.g. a
PYAUTO_TEST_MODE=1run)
still does not crashcorner, i.e. the_corner_range_fromguard survives.
Activity
Jammy2211 commentedon Aug 24, 2026
Library PR Created
pending-release)pending-release) — blocked on fix: forward autofit.plot **kwargs instead of silently discarding them #1524 by the library-first merge gateBoth on branch
claude/autofit-plot-functions-kwargs-vvwj5x.What shipped
The approved direction — forward
**kwargs, with a strict signature filter.checked_kwargsvalidates against the target's named parameters only; a**kwargssink is deliberately not read as "accepts anything", which is what makes this different from plain forwarding:corner.cornerfunnels unrecognised names intocorner.core.hist2d, whose body reads onlyextent, so plain forwarding would have left them silently ignored one layer deeper.The second defect found during verification is fixed in the same PR:
corner_cornerpypassedweight_list=tocorner.corner, which has no such parameter. Weighted posteriors have been rendering unweighted.Deviations from the plan on the issue
corner_anestheticrouting. The plan said kwargs matchingmake_2d_axes's named parameters shape the figure.figsizeandfacecolor— the two values this function computes — are not named parameters; anesthetic takes them through its own**fig_kw. As written, a caller'sfigsizewas routed toplot_2dand the library's own value won. A test caught it; the axes-routed set now namesfigsize/facecolor/dpiexplicitly.aplt.PlotKwargsErrorexported (not in the plan). A caller told their kwarg "raisesPlotKwargsError" should be able to catch it without reaching intoautofit.non_linear.docs/api/plot.rstalso updated (plan named onlydocs/cookbooks/search.md) — it is the API page for this surface and documented none of the new behaviour.Verification
Full suite 2089 passed, 36 skipped on 3.12. Beyond that, rendered against the pinned
corner==2.2.2and compared RGBA buffer hashes:bins=5,show_titles=True, and weighting each change the figure; all-constant columns still render with no "no dynamic range" crash. Each of the four workspace scripts' exact kwarg lists renders end-to-end.Worth flagging for review: the four plot scripts appear in neither
smoke_tests.txtnorsmoke_notebooks.txt, so workspace CI never executes them. The render check above is the only coverage they have.Sizing calibration
The Brain bug agent and sizing faculty both scored this too-large (13) and advised phasing; that was overridden. Actual outcome: 613 insertions / 16 deletions in the library across 11 files, plus 4 workspace scripts and their notebooks — a single coherent PR pair, no phasing needed. The score was inflated by prompt word-count plus the multi-repo flag.
Generated by Claude Code
Jammy2211 commentedon Aug 24, 2026
Shipped
56f1b875056fa3Merged in library-first order. Both branches proven merged (
merge-base --is-ancestorYES, 0 unmerged commits) before this close-out.CI — every run, every leg
unittest (3.12)✅ ·unittest (3.13)✅ ·unittest-nojax✅changes✅ ·smoke (3.12)✅ ·smoke (3.13)✅Each head sha produced only
pull_requestruns — no separatepushruns exist for these workflows on this branch, so the four above are the complete set. No re-runs; every leg passed first attempt.What shipped
autofit.plot's five functions forward their**kwargstocorner.corner/anesthetic/matplotlib, validated bychecked_kwargsagainst the target's named parameters — a**kwargssink is not read as "accepts anything", which is what stops corner'shist2dfunnel from silently swallowing an unrecognised name one layer deeper. Rejections raisePlotKwargsError(aTypeError, exported asaplt.PlotKwargsError) naming the argument with a did-you-mean hint.The
weight_list=→weights=fix went with it: every weighted corner posterior had been rendering unweighted.The four workspace plot tutorials had their kwarg lists rewritten to genuine
corner.pyarguments — 18 names across three scripts had been copied from dynesty's, zeus's and nautilus's plotting APIs — and their prose now states what actually happens.Release
pending-releaseon both PRs. A release is owed: this is library code and a user-visible behaviour change (weighted figures change appearance; wrong kwargs now raise), so it needs to reach PyPI for a user to benefit.Generated by Claude Code