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

snitc not breaking when wrong type of dataset is supplied #13

Open
lucas-johnson opened this issue Jun 1, 2022 · 1 comment
Open

snitc not breaking when wrong type of dataset is supplied #13

lucas-johnson opened this issue Jun 1, 2022 · 1 comment

Comments

@lucas-johnson
Copy link

Looks like an awesome package that is going to be super helpful! I'm just getting started here. Thanks for building this!

Behavior

When I accidentally passed a <class 'numpy.ndarray'> instead of a <class 'rasterio.io.DatasetReader'> as the dataset argument to stmetrics.spatial.snitc() I get the following error:

Traceback (most recent call last):
  File "/Users/lucasj/Code/lib/stseg/test.py", line 14, in <module>
    segments = stmetrics.spatial.snitc(
  File "/Users/lucasj/Code/lib/stseg/venv/lib/python3.9/site-packages/stmetrics/spatial.py", line 100, in snitc
    for band in range(img.shape[0]):
UnboundLocalError: local variable 'img' referenced before assignment

Expected behavior

The program should break on this TypeError:

TypeError("Sorry we can't read this type of file. \

Suggestion

Consider using Raise to stop the execution like:

else:
    raise TypeError("Sorry we can't read this type of file. \
                     Please use Rasterio or xarray")
@andersonreisoares
Copy link
Collaborator

Thank you for bring this to our attention @lucas-johnson.

This will be fixed in our next commit. I'm also adding a test function to make sure this is working.

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

No branches or pull requests

2 participants