Skip to content

docs: draw the mask overlay in ch3 tutorial 3 by plotting after apply_mask - #79

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/howtolens-ch3-mask-overlay
Sep 9, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/howtolens-ch3-mask-overlay

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Two aplt.plot_array calls in chapter_3_pixelizations/tutorial_3_inversions.py sat above their dataset.apply_mask(mask=mask), so the figure the prose introduces right after building an annular mask showed no mask at all. plot_array derives its overlay from the array's own mask one layer down (autoarray/plot/array.py → if mask is None: mask = auto_mask_edge(array)), and auto_mask_edge returns None for a fully-unmasked array. The tutorial runs green — that is why it went unnoticed. The reader was told about the mask and then shown a plain image.

Each site now applies the mask before it plots, and each relocated figure is retitled "Image Data With Mask Applied" (the canonical idiom, per autogalaxy_workspace/markdown/ellipse/fit.md) instead of the bare "Data" it inherited. At the second site that also removes a duplicate: the two figures were byte-identical, because dataset was unchanged between them.

Reproduced on a live stack (autolens 2026.9.8.1) with the tutorial's own 0.5″/2.8″ annulus:

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

Sibling fix to HowToGalaxy#56, where this was first spotted.

Scripts Changed

  • scripts/chapter_3_pixelizations/tutorial_3_inversions.py — moved both pre-apply_mask plot_array calls below their apply_mask and retitled them "Image Data With Mask Applied"; the genuine raw-data figure before any mask exists is left in place.

Notebook regenerated via PyAutoHands (notebooks/chapter_3_pixelizations/tutorial_3_inversions.ipynb). The navigator catalogue (llms-full.txt, workspace_index.json) regenerates byte-identical — it records each script's path, header summary and __Contents__ names, none of which moved.

Prose

At site one the fix reads better than a straight figure-move would: the docstring "We now create the masked source-plane grid via the tracer" was introducing apply_mask, and now sits directly above the lens_galaxy/tracer/source_plane_grid block it actually describes. The mask docstring gained ", and apply it to the dataset", and the relocated figure got a short intro in the tutorial's voice. At site two the blanket docstring ("This code is doing all the same as above…") still reads correctly and is left verbatim, with no docstring added so the block stays one notebook cell.

Test Plan

  • scripts/chapter_3_pixelizations/tutorial_3_inversions.py runs green under CI's exact smoke env (every default from config/build/profile_smoke.yaml + MPLBACKEND=Agg): exit 0, zero tracebacks, Python 3.12.3. The script is not in config/build/no_run.yaml, so this is what smoke_tests.yml executes.
  • Second PyAutoHands regeneration on the swept tree is a no-op (git status byte-identical, md5sums of the notebook and both catalogue files identical between runs).
  • Notebook cell order verified by parsing the .ipynb: at site one, apply_mask (cell 9) → new markdown intro (10) → retitled plot_array (11) → tracer prose (12) → tracer code (13). No cell-id or execution-count churn.
  • smoke_tests.yml on Python 3.12 and 3.13 — only 3.12 was run locally.
  • navigator_check.yml, tutorials_complete.yml.

Not verified: the rendered PNG was not eyeballed. auto_mask_edge was confirmed to return a real edge array at the point each relocated call now runs, which is the mechanism the figure depends on.

Closes #78

Generated by the PyAutoLabs agent workflow.


Generated by Claude Code

…_mask

Two `aplt.plot_array` calls in chapter_3_pixelizations/tutorial_3_inversions.py
sat above their `dataset.apply_mask(mask=mask)`, so the figure the prose
introduces right after building an annular mask showed no mask at all.
`plot_array` derives its overlay from the array's own mask one layer down
(`auto_mask_edge`), which returns None for a fully-unmasked array. The tutorial
runs green, which is why it went unnoticed.

Each site now applies the mask before it plots, and each relocated figure is
retitled "Image Data With Mask Applied" — the canonical idiom — instead of the
bare "Data" it inherited. At the second site that also removes a duplicate: the
two figures were byte-identical because `dataset` was unchanged between them.

Site one reads better for the move: the docstring "We now create the masked
source-plane grid via the tracer" was introducing `apply_mask`, and now sits
directly above the tracer block it describes.

The genuine raw-data figure before any mask exists is left in place.

Notebook regenerated via PyAutoHands; the navigator catalogue is unchanged
(it records paths, header summaries and __Contents__ names, none of which moved).

Closes #78

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119sx8hEa8cDa8c2q55FtmM
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Sep 9, 2026 — with Claude
@Jammy2211
Jammy2211 merged commit 5b51731 into main Sep 9, 2026
7 checks passed
@Jammy2211
Jammy2211 deleted the feature/howtolens-ch3-mask-overlay branch September 9, 2026 23:26
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: ch3 tutorial 3 plots the mask overlay before apply_mask, so no mask is drawn

2 participants