Skip to content

fix: repair three stale plot API calls in chapter 4 tutorial 3 - #57

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/plot-array-stale-kwargs
Aug 4, 2026
Merged

fix: repair three stale plot API calls in chapter 4 tutorial 3#57
Jammy2211 merged 1 commit into
mainfrom
feature/plot-array-stale-kwargs

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Fixes the workspace-smoke failure in the public chapter_4_pixelizations teaching notebook:

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

Reported from PyAutoHeart workspace-smoke run 30858578587, job smoke / run_notebooks (3.12, howtogalaxy, chapter_4_pixelizations), 2026-08-03. That run installed released autolens 2026.7.29.2; the newer 2026.8.4.1 does not fix it — PyAutoGalaxy main is at the release commit bf91c570 and the wrapper still rejects mask.

The caller was wrong, not the signature, so no library change is involved.

Two further stale-API breaks were hidden behind the reported one, because execution stopped at the first. The tutorial is only green now because it was re-run after each fix:

Stale call Why it broke Fix
plot_array(..., mask=mask) autogalaxy/util/plot_utils.py:124 has no mask param. The overlay is auto-derived from array.mask at autoarray/plot/array.py:128, but auto_mask_edge returns None for an unmasked array — and the call sat before apply_mask. Move below apply_mask, drop the kwarg
aplt.subplot_image_and_mapper Not re-exported by autogalaxy.plot; lives in autoarray.plot Use aaplt. — the convention tutorial_2_mappers.py in this same chapter already uses
inversion.reconstruction_to_native Attribute no longer exists mapped_reconstructed_operated_data (the plottable Array2D)

Moving the plot rather than deleting the kwarg restores the mask boundary the author intended, 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)

The private-path import from autoarray.inversion.plot.inversion_plots import subplot_of_mapper is also replaced by the public aaplt export, so one import now covers both helpers.

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

Scripts Changed

  • scripts/chapter_4_pixelizations/tutorial_3_inversions.py — moved plot_array below apply_mask and dropped mask=; repointed subplot_image_and_mapper and subplot_of_mapper at aaplt; replaced inversion.reconstruction_to_native with mapped_reconstructed_operated_data
  • notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb — regenerated from the script via PyAutoHands (not hand-edited)

Test Plan

  • All five chapter_4_pixelizations tutorials run green locally (the failing CI job covers the whole chapter, not just tutorial 3)
  • Failure reproduced on unchanged input first, matching the CI trace exactly
  • AST detector re-run on the post-fix tree: 0 out-of-signature plot_array kwargs (it correctly still flagged the notebook until it was regenerated)
  • Regenerated notebook confirmed to carry every fix
  • Smoke tests pass for all affected workspaces

Follow-ups filed (not in this PR)

  • HowToLens ch4 t3 plots before apply_mask at lines 76/190, so its mask overlay never draws. Not a crash — a quality gap.
  • The related aplt.Output drift in autocti_workspace_test (unverified — different library) and euclid_strong_lens_modeling_pipeline.

Generated by the PyAutoLabs agent workflow.

The tutorial crashed in workspace-smoke with
'TypeError: plot_array() got an unexpected keyword argument mask'
(cloud#30858578587). Two further stale-API breaks sat behind it, hidden
because execution stopped at the first.

- plot_array(mask=...): the aplt wrapper has no 'mask' parameter. The
  overlay is auto-derived from array.mask one layer down, but returns None
  for an unmasked array -- which is why the kwarg was added. Moving the
  call below apply_mask restores the intended mask boundary with no kwarg.
- aplt.subplot_image_and_mapper: not re-exported by autogalaxy.plot. It
  lives in autoarray.plot, which tutorial_2_mappers.py in this same
  chapter already imports as 'aaplt'.
- inversion.reconstruction_to_native: no longer exists; the plottable
  Array2D is mapped_reconstructed_operated_data.

Also drops a private-path import of subplot_of_mapper in favour of the
public aaplt export, so one import covers both helpers.

All five chapter_4_pixelizations tutorials verified green locally.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 4, 2026
@Jammy2211
Jammy2211 merged commit 7f60ea1 into main Aug 4, 2026
6 checks passed
@Jammy2211
Jammy2211 deleted the feature/plot-array-stale-kwargs branch August 4, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant