Skip to content

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

@lucas-johnson

Description

@lucas-johnson

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions