Skip to content

fix: stale plot_array kwargs break HowToGalaxy chapter 4 tutorial #56

Description

@Jammy2211

Overview

The public HowToGalaxy teaching notebook chapter_4_pixelizations/tutorial_3_inversions crashes with TypeError: plot_array() got an unexpected keyword argument 'mask', caught by PyAutoHeart workspace-smoke (run 30858578587, job smoke / run_notebooks (3.12, howtogalaxy, chapter_4_pixelizations), 2026-08-03T22:49:33Z).

That run installed released autolens 2026.7.29.2. The newer 2026.8.4.1 release does not fix it — PyAutoGalaxy main sits at the release commit bf91c570 and the wrapper still rejects mask. This is live breakage in a user-facing tutorial.

The caller is wrong, not the signature — plus a second, larger instance of the same stale-plot-API drift was found in autolens_workspace_developer.

Plan

  • Move the HowToGalaxy plot_array call below dataset.apply_mask(...) and drop the mask= kwarg, so the mask-boundary overlay is auto-derived — preserving the author's visual intent rather than just deleting the argument.
  • Regenerate the HowToGalaxy notebook and navigator catalogue from the fixed script (never hand-edit the .ipynb).
  • Repair the related aplt.Output drift across 10 files in autolens_workspace_developer, which currently raise AttributeError before they even reach the TypeError.
  • Verify by re-running the AST detector on the post-fix tree, not by trusting the pre-fix inventory.
  • File a separate follow-up prompt for the same drift in autocti_workspace_test and euclid_strong_lens_modeling_pipeline.
Detailed implementation plan

Work Classification

Workspace (both repos are workspace/tutorial repos; no library change).

Affected Repositories

  • HowToGalaxy (primary)
  • autolens_workspace_developer

Branch Survey

Repository Current Branch Dirty?
./HowToGalaxy main clean
./autolens_workspace_developer main clean

Neither repo is claimed by any active.md worktree — no conflict.

Suggested branch: feature/plot-array-stale-kwargs
Worktree root: ~/Code/PyAutoLabs-wt/plot-array-stale-kwargs/

Root cause

aplt.plot_array resolves to PyAutoGalaxy/autogalaxy/util/plot_utils.py:124, whose parameters are array, title, output_path, output_filename, output_format, colormap, use_log10, vmin, vmax, symmetric, positions, lines, line_colors, grid, cb_unit, ax — no mask. The overlay is derived one layer down at PyAutoArray/autoarray/plot/array.py:128 (if mask is None: mask = auto_mask_edge(array)).

auto_mask_edge returns None for a fully-unmasked array, so it draws nothing. The tutorial's call sits before apply_mask, where dataset.data is still unmasked — which is why the author reached for mask=mask. Measured on the installed stack:

unmasked   -> mask.is_all_false: True  | auto_mask_edge: None
after mask -> mask.is_all_false: False | auto_mask_edge: (156, 2)

So relocating the call below apply_mask restores the intended overlay with no kwarg at all.

An AST sweep of every .py and .ipynb across all ~25 workspace repos found mask= at exactly one logical site. HowToLens and HowToFit are clean.

Implementation Steps

  1. HowToGalaxy/scripts/chapter_4_pixelizations/tutorial_3_inversions.py:70 — move the plot below dataset = dataset.apply_mask(mask=mask) and drop the kwarg:

    dataset = dataset.apply_mask(mask=mask)
    
    aplt.plot_array(array=dataset.data, title="Data")

    Matches the canonical idiom in autogalaxy_workspace/markdown/ellipse/fit.md:158.

  2. Regenerate notebooks + catalogue from the HowToGalaxy repo root:

    PYTHONPATH=../PyAutoHands/autohands python3 ../PyAutoHands/autohands/generate.py howtogalaxy

    Commit the regenerated .ipynb, llms-full.txt and workspace_index.jsonnavigator_check.yml gates them.

  3. autolens_workspace_developeraplt.Output no longer exists on the autolens/autogalaxy plot namespace (it survives only as autoarray.plot.Output); its removal was deliberate and is documented in autolens_assistant/AGENTS.md:218. Fixing only the 7 plot_array(output=...) sites would leave these scripts still crashing on adjacent calls (e.g. subplot_tracer(..., output=aplt.Output(...)) at plotting_alignment/plot/imaging/orientation/simulator.py:137-139), so repair the repo's whole drift — 10 files:

    # before
    aplt.plot_array(array=..., output=aplt.Output(path=P, filename=F, format="png"))
    # after
    aplt.plot_array(array=..., output_path=P, output_filename=F, output_format="png")

    Two forms need care beyond a blind rename:

    • scaling_relation_agg/error_make.py:20 binds output = aplt.Output(path=".", format="png") to a variable reused at line 55 — delete the binding, inline flat kwargs at the call site.
    • Flat kwargs differ per callee (subplot_tracer has no output_filename) — check each signature.

Key Files

  • HowToGalaxy/scripts/chapter_4_pixelizations/tutorial_3_inversions.py — the CI failure
  • autolens_workspace_developer/plotting_alignment/ — 9 of the 10 drifted files
  • autolens_workspace_developer/scaling_relation_agg/error_make.py — the variable-bound Output
  • PyAutoGalaxy/autogalaxy/util/plot_utils.py:124 — the wrapper signature (read-only reference; not modified)
  • PyAutoArray/autoarray/plot/array.py:128 — auto mask-edge derivation (read-only reference)

Verification

  1. Reproduce the TypeError on unchanged input first (done — confirmed identical to the CI trace).
  2. Run the tutorial from the HowToGalaxy repo root; expect a clean run and a "Data" figure carrying the circular mask boundary:
    NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib \
    PYAUTO_TEST_MODE=1 PYAUTO_SKIP_FIT_OUTPUT=1 PYAUTO_FAST_PLOTS=1 \
    python scripts/chapter_4_pixelizations/tutorial_3_inversions.py
  3. Re-run the AST detector on the post-fix tree; require zero remaining out-of-signature plot_array kwargs.
  4. Sweep for residual aplt.Output in autolens_workspace_developer; expect zero.
  5. That repo has no smoke coverage — compile-check all 10 files, run the cheap non-fitting ones, and state in the PR which were only compile-checked.
  6. Regenerate notebooks last, after the script is green.

Out of scope (tracked separately)

  • autocti_workspace_test — 27 files with aplt.Output. Unverified: autocti is not installed locally and PyAutoCTI has its own plot namespace that may still export Output.
  • euclid_strong_lens_modeling_pipeline/tools/psf_size.py, extra_galaxies_centres_gui.py.

Confirmed not bugs: PyAutoArray/test_autoarray/plot/test_output.py (there aplt is autoarray.plot, which does export Output) and the autolens_assistant markdown documenting the removal.

Also noted, not fixed: HowToLens/scripts/chapter_4_pixelizations/tutorial_3_inversions.py:76,190 plots before apply_mask with no kwarg, so it silently draws no mask — a quality gap, not a crash.

Sizing note

The Brain Feature Agent scored this large (score 9) and advised splitting into phases. Overridden to small, no phasing: the score tracks prompt prose length rather than scope (repos_affected = 2), and its "public-API change may ripple downstream" risk does not apply since no library is modified.

Original Prompt

Click to expand starting prompt

In the PyAutoLabs workspace, HowToGalaxy chapter_4_pixelizations fails in
PyAutoHeart's workspace-smoke with:

TypeError: plot_array() got an unexpected keyword argument 'mask'

Evidence: PyAutoHeart workspace-smoke run 30858578587, job
"smoke / run_notebooks (3.12, howtogalaxy, chapter_4_pixelizations)",
2026-08-03T22:49:33Z. That run installed released autolens 2026.7.29.2;
2026.8.4.1 has since published, so first confirm whether the release
already fixes it before assuming it's live.

This is a public teaching notebook so it's user-facing. Find whether the
caller or the plot_array signature is wrong, check for sibling call sites
with the same kwarg across HowToGalaxy/HowToLens/HowToFit and the
workspaces, and fix them all. Route through start_dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions