Skip to content

Commit

Permalink
Merge pull request #228 from JonKing93/master
Browse files Browse the repository at this point in the history
Type checking of nodata values
  • Loading branch information
mdbartos authored Dec 4, 2023
2 parents 7f70cca + eb41cae commit 174cafa
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 174cafa

Please sign in to comment.