Summary
In PlotAccessor.show, the per-panel title / aspect / frameon block runs once per render command instead of once per panel, because it sits inside the inner for cmd, params in render_cmds: loop.
Details
src/spatialdata_plot/pl/basic.py:1801-1813 is indented inside the inner render-command loop (which starts at ~basic.py:1687):
ax.set_title(t)
ax.set_aspect("equal")
ax.axis("off")
# ... title[i] length / IndexError check ...
So set_title / set_aspect("equal") / axis("off") execute for every render command on a panel (N× for an N-call chain), and the title[i] length validation re-runs each iteration — meaning an IndexError/length mismatch can surface mid-loop rather than up front.
This is harmless to current output (the calls are idempotent) but is redundant work and a fragile place for any future per-command side effect.
Suggested fix
Dedent the title/aspect/frameon block so it runs once after the inner loop (a natural home is a small _finalize_panel(ax, i, title, ...) helper). Validate len(title) == num_panels once, before the panel loop.
Found during a maintainability/refactor audit of main.
Summary
In
PlotAccessor.show, the per-panel title / aspect / frameon block runs once per render command instead of once per panel, because it sits inside the innerfor cmd, params in render_cmds:loop.Details
src/spatialdata_plot/pl/basic.py:1801-1813is indented inside the inner render-command loop (which starts at ~basic.py:1687):So
set_title/set_aspect("equal")/axis("off")execute for every render command on a panel (N× for an N-call chain), and thetitle[i]length validation re-runs each iteration — meaning anIndexError/length mismatch can surface mid-loop rather than up front.This is harmless to current output (the calls are idempotent) but is redundant work and a fragile place for any future per-command side effect.
Suggested fix
Dedent the title/aspect/frameon block so it runs once after the inner loop (a natural home is a small
_finalize_panel(ax, i, title, ...)helper). Validatelen(title) == num_panelsonce, before the panel loop.Found during a maintainability/refactor audit of
main.