Skip to content

Fix _is_unique to correctly handle boolean arrays - #430

Merged
quantumjot merged 1 commit into
mainfrom
fix-is-unique-boolean-bug
Jan 9, 2026
Merged

Fix _is_unique to correctly handle boolean arrays#430
quantumjot merged 1 commit into
mainfrom
fix-is-unique-boolean-bug

Conversation

@quantumjot

Copy link
Copy Markdown
Owner

Fixes #429 where boolean segmentation masks were incorrectly identified as already labeled due to type coercion in np.array_equal(). This caused segmentation_to_objects() to skip labeling and pass boolean arrays directly to skimage.measure.regionprops(), resulting in a TypeError.

The fix adds a dtype check to return False for boolean arrays before performing the array comparison.

Changes:

  • Add dtype check in _is_unique() to return False for boolean arrays
  • Add unit tests for _is_unique() covering boolean, labeled, and unlabeled arrays

🤖 Generated with Claude Code

Fixes #429 where boolean segmentation masks were incorrectly identified
as already labeled due to type coercion in np.array_equal(). This caused
segmentation_to_objects() to skip labeling and pass boolean arrays
directly to skimage.measure.regionprops(), resulting in a TypeError.

The fix adds a dtype check to return False for boolean arrays before
performing the array comparison.

Changes:
- Add dtype check in _is_unique() to return False for boolean arrays
- Add unit tests for _is_unique() covering boolean, labeled, and unlabeled arrays

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@quantumjot
quantumjot merged commit 2de42c9 into main Jan 9, 2026
12 checks passed
@quantumjot
quantumjot deleted the fix-is-unique-boolean-bug branch January 9, 2026 21:03
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.

[BUG] _is_unique incorrectly identifies boolean arrays as labeled due to type coercion in array comparison

1 participant