We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
nodata=nan
1 parent e21f746 commit 948e51dCopy full SHA for 948e51d
1 file changed
stackstac/ops.py
@@ -45,11 +45,21 @@ def mosaic(
45
nodata:
46
The value to treat as invalid. Default: NaN.
47
48
+ To catch common mis-use, raises a ``ValueError`` if ``nodata=nan``
49
+ is used when the array has an integer or boolean dtype. Since NaN
50
+ cannot exist in those arrays, this indicates a different ``nodata``
51
+ value needs to be used.
52
+
53
Returns
54
-------
55
xarray.DataArray:
56
The mosaicked `~xarray.DataArray`.
57
"""
58
+ if np.isnan(nodata) and arr.dtype.kind in "biu":
59
+ # Try to catch usage errors forgetting to set `nodata=`
60
+ raise ValueError(
61
+ f"Cannot use {nodata=} when mosaicing a {arr.dtype} array, since {nodata} cannot exist in the array."
62
+ )
63
return arr.reduce(
64
_mosaic,
65
dim=dim,
0 commit comments