From 6e3246adf35284b937cd7640e3cd6b3bb6cd2055 Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Sun, 22 Nov 2026 21:14:14 +1000 Subject: [PATCH] fix: make filter(minstrength=) keep the stronger features The minstrength filter compared limits >= strength, so it kept the features weaker than the limit, the opposite of its documented "minimum <= strength" and of minscale. It now compares strength >= limits. The xfail test that recorded the bug is now an ordinary test. Co-Authored-By: Claude Sonnet 5.5 --- src/machinevisiontoolbox/ImagePointFeatures.py | 2 +- tests/test_image_point_features_extra.py | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/machinevisiontoolbox/ImagePointFeatures.py b/src/machinevisiontoolbox/ImagePointFeatures.py index b50c3dd0..313dddd0 100644 --- a/src/machinevisiontoolbox/ImagePointFeatures.py +++ b/src/machinevisiontoolbox/ImagePointFeatures.py @@ -984,7 +984,7 @@ def filter(self, **kwargs: Any) -> "BaseFeature2D": k = (limits[0] <= v) & (v <= limits[1]) elif filter == "minstrength": v = features.strength - k = limits >= v + k = v >= limits elif filter == "percentstrength": v = features.strength vmax = v.max() diff --git a/tests/test_image_point_features_extra.py b/tests/test_image_point_features_extra.py index 50f16a71..017a1217 100644 --- a/tests/test_image_point_features_extra.py +++ b/tests/test_image_point_features_extra.py @@ -295,11 +295,6 @@ def test_unknown_key(self): with pytest.raises(ValueError, match="unknown filter"): make_features().filter(colour=1) - @pytest.mark.xfail( - strict=True, - reason="minstrength keeps features weaker than the limit: the test is " - "written limits >= v, not v >= limits", - ) def test_minstrength_keeps_the_stronger(self): f = make_features(5).filter(minstrength=0.25) nt.assert_array_equal(f.id, [2, 3, 4])