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

join_segmentations dtype error for np.uint #7291

Open
aeisenbarth opened this issue Jan 11, 2024 · 0 comments · May be fixed by #7292
Open

join_segmentations dtype error for np.uint #7291

aeisenbarth opened this issue Jan 11, 2024 · 0 comments · May be fixed by #7292
Labels

Comments

@aeisenbarth
Copy link
Contributor

Description:

When input arrays are created with np.uint, operations between different integer dtypes change behavior and produce a float, causing an error.

This is because factor = s2.max() + 1 is [uint64]+[int]→[float64].

Way to reproduce:

>>> import numpy as np
>>> from skimage.segmentation import join_segmentations
>>> s1 = np.array([[0, 0], [1, 1]], dtype=np.uint)
>>> s2 = np.array([[0, 1], [0, 1]], dtype=np.uint)
>>> s1.dtype
dtype('uint64')
>>> s12 = join_segmentations(s1, s2)
Traceback (most recent call last):
  File "…/site-packages/IPython/core/interactiveshell.py", line 3508, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-129-041632ba5934>", line 1, in <module>
    s12 = join_segmentations(s1, s2)
  File "…/site-packages/skimage/segmentation/_join.py", line 59, in join_segmentations
    j, _, map_j_to_j_initial = relabel_sequential(j_initial)
  File "…/site-packages/skimage/segmentation/_join.py", line 156, in relabel_sequential
    raise TypeError("label_field must have an integer dtype")
TypeError: label_field must have an integer dtype

Version information:

3.9.17 (main, Jul  5 2023, 21:05:34) 
[GCC 11.2.0]
Linux-5.15.0-91-generic-x86_64-with-glibc2.35
scikit-image version: 0.22.0
numpy version: 1.23.4
aeisenbarth added a commit to aeisenbarth/scikit-image that referenced this issue Jan 11, 2024
aeisenbarth added a commit to aeisenbarth/scikit-image that referenced this issue Jan 11, 2024
@aeisenbarth aeisenbarth linked a pull request Jan 11, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant