Repository navigation
fix: say what is wrong with the marker string of draw_point - #268
Merged
Merged
Conversation
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>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 11 |
| Duplication | 0 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
draw_pointtakes the marker and its color in one string, such as"r+", or the color incolor=. Three mistakes each failed with an error from deeper in the code that does not say what is wrong:draw_point(img, pos, "rg+")(two color letters)TypeError: 'NoneType' object is not iterableValueError: marker has more than one color letterdraw_point(img, pos, "r")(no marker character)ValueError: cannot convert float NaN to integerValueError: the marker string has no marker characterdraw_point(img, pos, "+")(no color at all)TypeError: 'NoneType' object is not iterableValueError: no color, givecolor=or a letterEach message names the string it was given. No default color is chosen for the third case, because
coloris documented as defaulting toNone. A call that worked still works, includingcolor=taking precedence over a letter in the string.I looked at replacing the string handling with the
parse_fmtparser from PR 267 and decided against it, becausedraw_pointprints the marker as a text glyph withcv2.putText(so any character works, such as"A"or"#"), andparse_fmtaccepts only Matplotlib markers.Tests: 16 in a new
tests/base/test_draw_point_errors.py, covering the three errors, calls that must still draw, andcolor=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