Skip to content

fix: keep single-blob filter() matches - #35

Merged
petercorke merged 2 commits into
mainfrom
fix/blobs-filter-single-blob
Aug 2, 2026
Merged

fix: keep single-blob filter() matches#35
petercorke merged 2 commits into
mainfrom
fix/blobs-filter-single-blob

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • Blobs.filter() built its mask via np.array(mask).all(axis=0), which stays 2D when there's only one blob in the set. Indexing self[m] with a 2D boolean array silently dropped the blob even when it matched the filter criteria.
  • Fix: flatten the mask before indexing (self[m.flatten()]).

Fixes #17

Test plan

  • Added regression tests using the existing single-blob fixture (blobs1): one asserting a matching blob is kept, one asserting a non-matching blob is removed.
  • Verified the new keep-test fails without the fix (0 != 1) and passes with it.
  • Full tests/test_image_blobs.py: 99 passed, 3 skipped, no regressions.

np.array(mask).all(axis=0) produces a 2D mask when Blobs holds a
single blob, so self[m] indexed with it dropped the blob even when
it matched the filter criteria. Flatten before indexing.

Fixes #17
@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 b3af989 into main Aug 2, 2026
30 of 32 checks passed
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.

Filtering blobs when only one blob is detected

1 participant