Repository navigation
fix: make plot_array overlays respect imshow_origin "lower" (#565) - #616
Merged
Merged
Conversation
With imshow_origin: lower the raster was reflected about the extent's y midpoint but every vector overlay (mask edge, border, origin marker, grid, mesh grid, positions, lines, regions, quiver) stayed in unreflected data coordinates, so critical curves and caustics silently slid off their arcs. Add private helpers _overlay_yx_for_origin / _vector_yx_for_origin in plot/utils.py that reflect overlay y (and negate quiver dy) under "lower", following the pattern _apply_contours already used, and route every plot_array overlay through them. The uniform rectangular mesh path of plot_inversion_reconstruction had the same defect; _plot_rectangular now returns its raster extent so its overlays are reflected too. "upper" is unchanged. Patches are documented as not origin-aware. Add origin-agnostic regression tests (positions, lines, inversion grid) parametrised over both origins, red on unfixed main for every "lower" case. Document on the config key that imshow_origin is presentation only. Reported by @ClarkGuilty in PyAutoLabs Discussion #14, including the reproducer and the regression-test design. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #565 — community report by @ClarkGuilty, Discussion #14.
With
visualize/general.yaml -> imshow_origin: lower,plot_arrayreflected the image raster about the extent's y midpoint but drew every vector overlay (mask edge, border, origin marker, grid, mesh grid, positions, lines, regions, quiver vectors) in unreflected data coordinates. The figure still looked plausible, so critical curves and caustics silently slid off the arcs they belong to.The fix follows the pattern
_apply_contoursalready used: two private helpers inautoarray/plot/utils.pyreflect overlayyabout the raster extent's midpoint when the origin is"lower"(_overlay_yx_for_origin, and_vector_yx_for_originwhich also negatesdyfor quiver rows).plot_arraypasses every overlay through them before drawing;"upper"is byte-for-byte unchanged. The same audit found the uniform rectangular mesh path ofplot_inversion_reconstruction(animshowhonouring the origin) had the identical defect, so_plot_rectangularnow returns its raster extent and the lines/regions/grid overlays are reflected there too. Patches are drawn as given and documented as not origin-aware. WhenextentisNonematplotlib draws in pixel-index coordinates under either origin, so no reflection is applied.The
imshow_originconfig comment now records the caveat from the report: the setting is presentation only, and underlowerthe displayed y axis and reported model y parameters disagree in sign.API Changes
None. Both helpers are private; the config key, its default and every public
plot_*signature are unchanged. User-visible behaviour change: withimshow_origin: lower, overlays now land on the image features they describe.Test Plan
test_autoarray/plot/test_array.py: three origin-agnostic regression tests (positions marker, asymmetric polyline, uniform-mesh inversion grid), each parametrised overupper/lower. They read the drawn overlay back from the axes, map it through the image's own extent and origin, and assert the array is bright there — so they keep passing under any correct fix rather than pinning today's layout. Red on unfixedmainfor everylowercase (assert 0.0 == 1.0), green now.python -m pytest test_autoarray/plot/— 41 passedpython -m pytest test_autoarray/— 1981 passed, 4 xfailedKnown remaining
lowerquirk, out of scope:zoom_to_brightestinplot_inversion_reconstructionsets axis limits from an unreflected zoom extent, so on a uniform mesh underlowerthe zoom window can sit over the wrong part of the image. Pre-existing; noted on #565.Full API Changes (for automation & release notes)
Added
autoarray.plot.utils._overlay_yx_for_origin(yx, extent, origin_imshow)(private)autoarray.plot.utils._vector_yx_for_origin(vector_yx, extent, origin_imshow)(private)autoarray.plot.inversion._plot_rectangularnow returns the raster extent (uniform path) orNone(private)Removed
Migration
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code