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

Misleading error message with invalid morphology.skeletonize method #6661

Closed
jamesyan-git opened this issue Dec 23, 2022 · 4 comments · Fixed by #6805
Closed

Misleading error message with invalid morphology.skeletonize method #6661

jamesyan-git opened this issue Dec 23, 2022 · 4 comments · Fixed by #6805

Comments

@jamesyan-git
Copy link

Description:

When using skeletonize on a 2d numpy array with an invalid method parameter, an error message is shown falsely stating that there is a mismatch in the array dimension.

I would expect the error message to highlight the incorrect method as the issue rather than incorrect array dimensionality.

Let me know if I can provide any further detail :smi

Way to reproduce:

import numpy as np
from skimage.morphology import skeletonize

result = skeletonize(np.ones((5, 5)), method='foo')

Traceback or output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\james\anaconda3\envs\skan\lib\site-packages\skimage\morphology\_skeletonize.py", line 87, in skeletonize
    raise ValueError(f'skeletonize requires a 2D or 3D image as input, '
ValueError: skeletonize requires a 2D or 3D image as input, got 2D.

Version information:

3.10.8 | packaged by conda-forge | (main, Nov 24 2022, 14:07:00) [MSC v.1916 64 bit (AMD64)]
Windows-10-10.0.19044-SP0
scikit-image version: 0.19.3
numpy version: 1.23.5
@jni
Copy link
Member

jni commented Dec 24, 2022

Thanks for the report @jamesyan-git!

This might make a good issue for a first-time contributor — we should add an if clause checking that the method is valid first, then do the dimensionality checks. (e.g. if method not in {'lee', 'zhang'}: raise ValueError("<error message>"))

@lagru
Copy link
Member

lagru commented Dec 27, 2022

I can confirm the bug. Thanks for the report @jamesyan-git, and I agree with @jni's assessment. 👍

@arsh73552
Copy link
Contributor

Hey, Thanks for marking this as a good first issue, this seems like something I can do and I'll work on it!

@lagru
Copy link
Member

lagru commented Mar 13, 2023

Fixed in #6805.

@lagru lagru closed this as completed Mar 13, 2023
@lagru lagru added the 🐛 Bug label Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment