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

can_cast throws error with numpy 2.0.0 #250

Open
floriandeboissieu opened this issue Jul 2, 2024 · 0 comments · May be fixed by #251
Open

can_cast throws error with numpy 2.0.0 #250

floriandeboissieu opened this issue Jul 2, 2024 · 0 comments · May be fixed by #251

Comments

@floriandeboissieu
Copy link

With new version of numpy v2.0.0, np.can_cast does not accept ints, float or complex anymore. Thus stackstac.stack raise an error systematically, example:

import stackstac
import pystac_client

URL = "https://earth-search.aws.element84.com/v1"
catalog = pystac_client.Client.open(URL)

stac_items = catalog.search(
    intersects=dict(type="Point", coordinates=[-105.78, 35.79]),
    collections=["sentinel-2-l2a"],
    datetime="2020-04-01/2020-05-01"
).get_all_items()

stack = stackstac.stack(stac_items)

returns:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\gitlab_runner\miniforge3\envs\fordead-gitlab-ci\Lib\site-packages\stackstac\stack.py", line 290, in stack
    asset_table, spec, asset_ids, plain_items = prepare_items(
                                                ^^^^^^^^^^^^^^
  File "C:\Users\gitlab_runner\miniforge3\envs\fordead-gitlab-ci\Lib\site-packages\stackstac\prepare.py", line 168, in prepare_items
    if not np.can_cast(asset_scale, dtype):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can_cast() does not support Python ints, floats, and complex because the result used to depend on the value.
This change was part of adopting NEP 50, we may explicitly allow them again in the future.
floriandeboissieu added a commit to floriandeboissieu/stackstac that referenced this issue Jul 2, 2024
@floriandeboissieu floriandeboissieu linked a pull request Jul 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant