Skip to content

fix: make the stdisp cross-hair cursor work - #225

Merged
petercorke merged 2 commits into
mainfrom
bug/stdisp-cursor
Nov 22, 2026
Merged

petercorke merged 2 commits into
mainfrom
bug/stdisp-cursor

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Image.stdisp(), the stereo pair viewer, had two bugs that left its cross-hair cursor unusable:

  1. Clicking in the left image raised RuntimeError: y must be a sequence. The click and move handlers passed a scalar to Line2D.set_xdata and set_ydata, which Matplotlib 3.11 refuses. They now pass [x, x] and [y, y].
  2. The Cursor object was held only by a local variable, and Matplotlib keeps bound-method callbacks weakly, so where plt.show(block=True) returns at once (a notebook, or a non-interactive backend) the cursor was collected and the clicks did nothing. The figure now keeps a reference to it.

Both were found by the new stdisp tests (PR 222), which recorded them as strict xfail tests. Those two tests are now ordinary tests.

Testing

tests/test_image_io_extra.py: 42 passed, and one xfail that belongs to a separate bug (Image.Read with a wildcard). tests/test_image_io.py passes, and mypy reports no issues. The click test plays the part of the user with simulated mouse events: a click in the left image places the cross-hairs, a drag over the right image reads d=-4.00, and a second test checks the cursor still works after stdisp() has returned. Not run: CI on Windows or OpenCV 4 (CI will).

This change was written with AI assistance (Claude Code) and the diff has been read by the maintainer.

🤖 Generated with Claude Code

Clicking in the left image raised "y must be a sequence", because the handlers
passed scalars to Line2D.set_xdata and set_ydata, which Matplotlib now refuses.
And the Cursor object was held only by a local variable while Matplotlib keeps
bound-method callbacks weakly, so when show() did not block (a notebook, or a
non-interactive backend) the clicks did nothing. The figure now keeps the
cursor alive.

The two xfail tests that recorded these bugs are now ordinary tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 61f7916 into main Nov 22, 2026
34 checks passed
@petercorke
petercorke deleted the bug/stdisp-cursor branch November 22, 2026 11:34
@github-actions github-actions Bot mentioned this pull request Nov 22, 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.

1 participant