Skip to content

fix: pickpoints with matplotlib=True no longer raises NameError - #213

Merged
petercorke merged 7 commits into
mainfrom
bug/pickpoints-plt
Nov 22, 2026
Merged

petercorke merged 7 commits into
mainfrom
bug/pickpoints-plt

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

pickpoints() in base/imageio.py called plt.ginput(), but plt is never defined in that module, so every call with the default matplotlib=True raised NameError: name 'plt' is not defined. It now gets pyplot from _plt(), as idisp does, and the # type: ignore[name-defined] that was hiding the problem from mypy is gone. The docstring gains a .. versionchanged:: 2.5.0 note.

Adds tests/base/test_pickpoints.py: with matplotlib=True the clicked points come back one per column and n is passed to ginput; with matplotlib=False a left click prints its position and nothing is returned.

Testing

pytest tests/base/test_pickpoints.py: 3 passed; the two Matplotlib tests fail on main without the fix. mypy reports no issues. A real click cannot be automated, so plt.ginput and OpenCV's mouse functions are replaced; the Agg backend, pyplot and the array conversion are real. I did not try it with a live window. 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

pickpoints() called plt.ginput() but plt was never defined in the module,
so every call with the default matplotlib=True failed. It now gets pyplot
from _plt(), as idisp() does. Adds tests for both backends.

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 5 complexity · 0 duplication

Metric Results
Complexity 5
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 4ddd9f9 into main Nov 22, 2026
34 checks passed
@petercorke
petercorke deleted the bug/pickpoints-plt branch November 22, 2026 04:22
@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