Skip to content

test: cover idisp's colormap, colorbar and pixel-readout options - #212

Merged
petercorke merged 3 commits into
mainfrom
test/base-coverage-imageio
Nov 22, 2026
Merged

petercorke merged 3 commits into
mainfrom
test/base-coverage-imageio

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Second of three changes to bring every file in machinevisiontoolbox/base to at least 80% coverage. base/imageio.py goes from 62% to 86%.

Adds tests/base/test_idisp_options.py, which covers parts of idisp that had no tests:

  • the signed, invsigned, random, grey and invert colormaps, with and without powernorm and ncolors, checking the colormap and normalisation that reach Matplotlib;
  • the black option for float, integer and bool images, checking the displayed values;
  • colorbars: plain, with ncolors, with labelled ticks, and with extra options passed on;
  • the text shown for the pixel under the cursor, for integer, float, bool and color images, BGR order, positions outside the image, and a custom coordformat;
  • the clipboard keys (c, C, x, v, V);
  • the OpenCV window functions: cv_destroy_window, and idisp with matplotlib=False for fps and block.

Testing

pytest tests: 1527 passed, 33 skipped. The Matplotlib tests run on the Agg backend and check what idisp passes to Matplotlib. The clipboard tests use a stand-in for pyclip and the OpenCV tests replace cv2 with a recorder, because a real clipboard and real windows depend on the machine. Not covered: pickpoints and the backend selection in _ensure_mpl_backend. Not run: CI on Windows or OpenCV 4 (CI will).

While writing these tests I found two bugs in imageio.py, which are not fixed here: pickpoints(matplotlib=True) raises NameError because plt is never defined, and the v and V clipboard keys copy np.uint8(10) instead of 10 on NumPy 2. The tests accept either form for the second.

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

🤖 Generated with Claude Code

Adds tests/base/test_idisp_options.py. The Matplotlib tests use the Agg
backend and check the colormap, normalisation, displayed values and the
pixel text, for the signed, invsigned, random, grey and invert colormaps,
black, colorbars and the clipboard keys. The OpenCV window functions are
tested with cv2 replaced by a recorder.

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

Metric Results
Complexity 61
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 3abd184 into main Nov 22, 2026
32 checks passed
@petercorke
petercorke deleted the test/base-coverage-imageio branch November 22, 2026 03:15
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