Skip to content

fix: print a FeatureMatch that holds a single match - #227

Merged
petercorke merged 3 commits into
mainfrom
bug/featurematch-str
Nov 22, 2026
Merged

petercorke merged 3 commits into
mainfrom
bug/featurematch-str

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

str() of a FeatureMatch that holds a single match raised IndexError. It indexed self.p1[0, 0], but p1 and p2 are 1D arrays when there is only one match, so there is no second axis. It now flattens them first. repr() and printing a match picked with matches[i] use the same method, so they are fixed too. A match with several entries was already fine.

Found by the new FeatureMatch tests (PR 221), which recorded it as a strict xfail test. That test is now an ordinary test, and a second one checks that the line starts with + or - once inliers are set.

Testing

tests/test_image_point_features_extra.py and tests/test_image_point_features.py: 131 passed and 4 xfail, each of which belongs to a different bug. mypy reports no issues. The new test checks the whole line, " 1.00: (20.0, 25.0) <--> (30.0, 30.0)". 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

petercorke and others added 2 commits November 22, 2026 20:54
str() of a one-match FeatureMatch indexed p1[0, 0], but p1 and p2 are 1D arrays
when there is a single match, so it raised IndexError. It now flattens them
first. This also fixes repr(), and printing a match picked with match[i].

The xfail test that recorded the bug is now an ordinary test, and a second test
checks the inlier marker.

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 c2244e1 into main Nov 22, 2026
34 checks passed
@petercorke
petercorke deleted the bug/featurematch-str branch November 22, 2026 12:01
@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