This pull request replaces the call to np.min_scalar_type with np.can_cast in the nodata check that occurs when creating a Raster or MultiRaster.
Currently, the use of np.min_scalar_type causes this check to fail unexpectedly in a few cases. For example, try creating an int8 raster with a nodata value of 0:
Even though 0 is representable in int8, this code results in the following error:
TypeError: `nodata` value not representable in dtype of array.
This occurs because np.min_scalar_type(0) returns uint8, which is not <= int8. Replacing this with np.can_cast instead checks that the nodata value is representable in the raster's dtype, which I believe is the intended behavior.
This pull request replaces the call to
np.min_scalar_type
withnp.can_cast
in the nodata check that occurs when creating a Raster or MultiRaster.Currently, the use of
np.min_scalar_type
causes this check to fail unexpectedly in a few cases. For example, try creating an int8 raster with a nodata value of 0:Even though 0 is representable in int8, this code results in the following error:
This occurs because
np.min_scalar_type(0)
returns uint8, which is not <= int8. Replacing this withnp.can_cast
instead checks that the nodata value is representable in the raster's dtype, which I believe is the intended behavior.