Repository navigation
Description
Overview
aplt.plot_grid(..., indexes=...) raises IndexError when a highlighted index lies outside the plotted grid. HowToLens chapter_1_introduction/tutorial_2_ray_tracing.py hard-codes indexes for its 101x101 grid; under PYAUTO_SMALL_DATASETS=1 the grid is capped to 16x16 (256 points), so index 5118 is out of bounds and the tutorial crashes. Reproduced on PyAutoArray main (e398b80) and HowToLens main on 2026-11-20:
File ".../autoarray/plot/grid.py", line 175, in plot_grid
grid[idx_list, 1],
IndexError: index 5118 is out of bounds for axis 0 with size 256
Plan
- Make
plot_griddrop highlighted indexes that fall outside the grid, instead of crashing. - Skip an index group entirely when none of its indexes survive, keeping each surviving group's colour.
- Log one message saying how many indexes were dropped, so a genuine mistake is still visible.
- Add unit tests for in-range, partly out-of-range and fully out-of-range index groups.
- Witness: the HowToLens tutorial exits 0 with and without
PYAUTO_SMALL_DATASETS=1. - Tutorial stays unchanged: the fix belongs in the library.
effective level: supervised; merge mode: auto-merge on green if the Witness passes after a merge slot (shift worker ends at PR-open; close-out decides)
Detailed implementation plan
Affected repositories
- PyAutoArray (primary, the only edited repo)
- HowToLens (witness only, no edits)
Work classification
Library (bug)
Branch survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./array/PyAutoArray | main | clean |
| ./lens/HowToLens | main | clean |
Suggested branch: feature/plot-grid-small-datasets-indexes
Worktree root: ~/Code/PyAutoLabs-wt/plot-grid-small-datasets-indexes/
Implementation steps
autoarray/plot/grid.py,plot_grid, theif indexes is not None:block: for eachidx_list, convert to an integer numpy array, keep entries with-n <= idx < n(n = grid.shape[0]),continueif empty, else scatter as before with colourcolors[i % len(colors)]. Count dropped entries; if any,logger.infoonce naming the count and grid size.test_autoarray/plot/test_grid.py(new): plot_grid withaxsupplied, assert collections/offsets for the three cases and that no exception is raised.
Testing
python -m pytest -q -n 4 test_autoarray/plot- Witness script with and without
PYAUTO_SMALL_DATASETS=1. - Targeted smoke via
pyauto-heart smoke --targeted.
Original prompt: PyAutoMind draft/bug/autoarray/plot_grid_indexerror_under_small_datasets.md (shift 2026-11-20-am).
Activity
Jammy2211 commentedon Nov 20, 2026
PR opened: #706 (shift 2026-11-20-am). Gate: tests, Witness, targeted smoke, independent review CLEAN, Heart GREEN. Labelled
decision-taken: boolean-mask groups are kept as masks, a change from the plan's integer conversion, made after the review. Ends at PR-open for the close-out //prm.Jammy2211 commentedon Nov 20, 2026
Shipped. #706 merged (0f4e8a0, 2026-11-20) via human /prm after review of shift 2026-11-20-am.
plot_grid(indexes=...)now drops highlighted indexes that fall outside the grid and logs one INFO line with the count, instead of raisingIndexError; empty groups are skipped and each surviving group keeps its colour (bool-mask groups preserved viaflatnonzero). HowToLenschapter_1_introduction/tutorial_2_ray_tracing.pynow runs underPYAUTO_SMALL_DATASETS=1.