Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix join_segmentations dtype error for np.uint #7292

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion skimage/segmentation/_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def join_segmentations(s1, s2, return_mapping: bool = False):
s1_relabeled, _, backward_map1 = relabel_sequential(s1)
s2_relabeled, _, backward_map2 = relabel_sequential(s2)
# Create joined label image
factor = s2.max() + 1
factor = (s2.max() + 1).astype(s2.dtype)
aeisenbarth marked this conversation as resolved.
Show resolved Hide resolved
j_initial = factor * s1_relabeled + s2_relabeled
j, _, map_j_to_j_initial = relabel_sequential(j_initial)
if not return_mapping:
Expand Down
7 changes: 4 additions & 3 deletions skimage/segmentation/tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import pytest


def test_join_segmentations():
s1 = np.array([[0, 0, 1, 1], [0, 2, 1, 1], [2, 2, 2, 1]])
s2 = np.array([[0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 1]])
@pytest.mark.parametrize("dtype", [int, np.uint16, np.uint])
def test_join_segmentations(dtype):
s1 = np.array([[0, 0, 1, 1], [0, 2, 1, 1], [2, 2, 2, 1]], dtype=dtype)
s2 = np.array([[0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 1]], dtype=dtype)

# test correct join
# NOTE: technically, equality to j_ref is not required, only that there
Expand Down