Repository navigation
test: raise coverage of ImagePointFeatures from 54% to 97% - #221
Merged
Merged
Conversation
The tests build feature objects by hand from cv2.KeyPoint values with known coordinates, scale, angle, strength and descriptors, so the answers are exact whichever detector or OpenCV version is installed. The detector tests use a blurred checkerboard whose corners are at multiples of 40 pixels. Five bugs are recorded as strict xfail tests: distance() with feature sets of different sizes, filter(minstrength=...) keeping the weaker features, descriptor with no descriptors, str() of a one-match FeatureMatch, and the direction of the hand drawn by draw(). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| ErrorProne | 4 high |
🟢 Metrics 128 complexity · 0 duplication
Metric Results Complexity 128 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.
Summary
Second of three changes to lift coverage of the
Image*.pymodules.ImagePointFeatures.pygoes from 54% to 97%. It is the largest of the modules (608 statements), and held nearly 40% of the missed lines.The tests are in a new file,
tests/test_image_point_features_extra.py. Most build the feature objects by hand fromcv2.KeyPointvalues with known coordinates, scale, angle, strength and descriptors, so the expected answers are exact and do not depend on the detector or the OpenCV version. They cover indexing, the properties, printing, adding,gridify,subset,sort,filter,distance,match(with each metric,crosscheck,topandsort),support, the drawing methods, and the whole ofFeatureMatch(indexing, inliers,by_id1andby_id2, printing, plotting,estimate). The detector tests use a blurred checkerboard whose corners are at multiples of 40 pixels:Harrismust find all 25 of them to within 2 pixels, and SIFT, ORB, BRISK and AKAZE must return keypoints and descriptors for it. Theidandnfeatoptions are tested too.Five bugs found while writing these are recorded as strict
xfailtests, not fixed here, so whoever fixes one has to remove its marker:distance()raisesIndexErrorunless both feature sets are the same size.filter(minstrength=x)keeps the features weaker thanx;minscaleis the right way round.descriptorproperty raisesTypeErrorwhen there are no descriptors.str()of aFeatureMatchwith a single match raisesIndexError.draw(..., filled=True, hand=True)draws the hand vertically whatever the orientation.Not covered:
ComboFeature, which is marked work in progress (it fails on OpenCV 5 withAttributeError, sinceAgastFeatureDetector_createis gone), and the SURF paths, which need a non-free OpenCV build.Testing
pytest tests: 1745 passed, 33 skipped, 6 xfailed.black,ruff checkandmypyreport no issues. Nothing is mocked. 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