Skip to content

Commit 57d2d45

Browse files
Support NumPy 2.0 can_cast (#251)
1 parent 95fa740 commit 57d2d45

File tree

4 files changed

+86
-40
lines changed

4 files changed

+86
-40
lines changed

pdm.lock

Lines changed: 82 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies = [
99
"pyproj<4.0.0,>=3.0.0",
1010
"rasterio<2.0.0,>=1.3.0",
1111
"xarray>=0.18",
12+
"numpy<3,>1.23",
1213
]
1314
description = "Load a STAC collection into xarray with dask"
1415
license = {text = "MIT"}

stackstac/prepare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def prepare_items(
165165
asset_offset = 0
166166

167167
if rescale:
168-
if not np.can_cast(asset_scale, dtype):
168+
if not np.can_cast(type(asset_scale), dtype):
169169
raise ValueError(
170170
f"`rescale=True`, but safe casting cannot be completed between "
171171
f"asset scale value {asset_scale} and output dtype {dtype}.\n"
@@ -174,7 +174,7 @@ def prepare_items(
174174
"values, pass a different `dtype=` (typically `float`)."
175175
)
176176

177-
if not np.can_cast(asset_offset, dtype):
177+
if not np.can_cast(type(asset_offset), dtype):
178178
raise ValueError(
179179
f"`rescale=True`, but safe casting cannot be completed between "
180180
f"asset offset value {asset_offset} and output dtype {dtype}.\n"

stackstac/to_dask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def items_to_dask(
3636
"Create a dask Array from an asset table"
3737
errors_as_nodata = errors_as_nodata or () # be sure it's not None
3838

39-
if not np.can_cast(fill_value, dtype):
39+
if not np.can_cast(type(fill_value), dtype):
4040
raise ValueError(
4141
f"The fill_value {fill_value} is incompatible with the output dtype {dtype}. "
4242
f"Either use `dtype={np.array(fill_value).dtype.name!r}`, or pick a different `fill_value`."

0 commit comments

Comments
 (0)