Skip to content

fix: idisp clipboard keys v and V copy plain numbers - #214

Merged
petercorke merged 1 commit into
mainfrom
bug/idisp-clipboard-scalars
Nov 22, 2026
Merged

petercorke merged 1 commit into
mainfrom
bug/idisp-clipboard-scalars

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

In idisp, the v and V clipboard keys copy the position and value of the pixel under the cursor. On NumPy 2 a color pixel was copied as 2,1,(np.uint8(10), np.uint8(20), np.uint8(30)), which cannot be pasted into a script or a spreadsheet, and on a monochrome image the key handler raised TypeError. They now copy plain numbers: 2,1,(10, 20, 30) for a color image and 2,1,6 for a monochrome one. The idisp docstring gains a .. versionchanged:: 2.5.0 note.

This PR is stacked on PR 212 (cover idisp's colormap, colorbar and pixel-readout options), which adds the clipboard tests. Its tests accepted either form of the text; here they expect plain numbers, and there are new tests for monochrome and float images. Until PR 212 merges, the diff shown here includes PR 212's commit; after it merges, the diff is only this fix.

Testing

pytest tests/base: 312 passed, 2 skipped; the three clipboard tests fail without the fix. mypy reports no issues. The clipboard is a stand-in for pyclip, since a real clipboard depends on the machine, and I did not try the keys in 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

On NumPy 2 the v and V keys copied "2,1,(np.uint8(10), np.uint8(20),
np.uint8(30))" to the clipboard, and raised an error in the key handler
for a monochrome image. They now copy plain numbers: "2,1,(10, 20, 30)"
for a color image and "2,1,6" for a monochrome one. The tests from the
idisp options PR, which accepted either form, now expect plain numbers.

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 b36ffc4 into main Nov 22, 2026
34 checks passed
@petercorke
petercorke deleted the bug/idisp-clipboard-scalars branch November 22, 2026 03:33
@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