Skip to content

Commit

Permalink
fix nodata dtype check
Browse files Browse the repository at this point in the history
Replaces np.min_scalar_type with np.can_cast
  • Loading branch information
JonKing93 authored Sep 14, 2023
1 parent 32fb2ef commit eb41cae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pysheds/sview.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __new__(cls, input_array, viewfinder=None, metadata={}):
except:
raise TypeError('`object` and `flexible` dtypes not allowed.')
try:
assert np.min_scalar_type(viewfinder.nodata) <= obj.dtype
assert np.can_cast(viewfinder.nodata, obj.dtype, casting='safe')
except:
raise TypeError('`nodata` value not representable in dtype of array.')
# Don't allow original viewfinder and metadata to be modified
Expand Down Expand Up @@ -288,7 +288,7 @@ def __new__(cls, input_array, viewfinder=None, metadata={}):
except:
raise TypeError('`object` and `flexible` dtypes not allowed.')
try:
assert np.min_scalar_type(viewfinder.nodata) <= obj.dtype
assert np.can_cast(viewfinder.nodata, obj.dtype, casting='safe')
except:
raise TypeError('`nodata` value not representable in dtype of array.')
# Don't allow original viewfinder and metadata to be modified
Expand Down

0 comments on commit eb41cae

Please sign in to comment.