Skip to content

fix: say what is wrong with the marker string of draw_point - #268

Merged
petercorke merged 3 commits into
mainfrom
fix/draw-point-two-colors
Nov 23, 2026
Merged

petercorke merged 3 commits into
mainfrom
fix/draw-point-two-colors

Conversation

@petercorke

Copy link
Copy Markdown
Owner

draw_point takes the marker and its color in one string, such as "r+", or the color in color=. Three mistakes each failed with an error from deeper in the code that does not say what is wrong:

call before now
draw_point(img, pos, "rg+") (two color letters) TypeError: 'NoneType' object is not iterable ValueError: marker has more than one color letter
draw_point(img, pos, "r") (no marker character) ValueError: cannot convert float NaN to integer ValueError: the marker string has no marker character
draw_point(img, pos, "+") (no color at all) TypeError: 'NoneType' object is not iterable ValueError: no color, give color= or a letter

Each message names the string it was given. No default color is chosen for the third case, because color is documented as defaulting to None. A call that worked still works, including color= taking precedence over a letter in the string.

I looked at replacing the string handling with the parse_fmt parser from PR 267 and decided against it, because draw_point prints the marker as a text glyph with cv2.putText (so any character works, such as "A" or "#"), and parse_fmt accepts only Matplotlib markers.

Tests: 16 in a new tests/base/test_draw_point_errors.py, covering the three errors, calls that must still draw, and color= winning over a letter. mypy reports no issues and the full suite passes (2214 passed, 33 skipped).

AI-assisted: written with Claude Code (Claude Sonnet 5.5) and reviewed by the maintainer.

🤖 Generated with Claude Code

petercorke and others added 2 commits November 24, 2026 06:31
Two color letters, no marker character and no color at all each failed with an
unrelated TypeError or ValueError from deeper in the code. Raise ValueError
with a message for each.

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

codacy-production Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 11 complexity · 0 duplication

Metric Results
Complexity 11
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 86a6592 into main Nov 23, 2026
34 checks passed
@petercorke
petercorke deleted the fix/draw-point-two-colors branch November 23, 2026 20:52
@github-actions github-actions Bot mentioned this pull request Nov 23, 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