Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NumPy 2.0 can_cast #251

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 82 additions & 37 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"pyproj<4.0.0,>=3.0.0",
"rasterio<2.0.0,>=1.3.0",
"xarray>=0.18",
"numpy<3,>1.23",
]
description = "Load a STAC collection into xarray with dask"
license = {text = "MIT"}
Expand Down
4 changes: 2 additions & 2 deletions stackstac/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def prepare_items(
asset_offset = 0

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

if not np.can_cast(asset_offset, dtype):
if not np.can_cast(type(asset_offset), dtype):
raise ValueError(
f"`rescale=True`, but safe casting cannot be completed between "
f"asset offset value {asset_offset} and output dtype {dtype}.\n"
Expand Down
2 changes: 1 addition & 1 deletion stackstac/to_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def items_to_dask(
"Create a dask Array from an asset table"
errors_as_nodata = errors_as_nodata or () # be sure it's not None

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