diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index b1db58b7d03..68e841b4181 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -4,10 +4,12 @@ micromamba install "cython>=0.29.20" py-cpuinfo # temporarily (?) remove numbagg and numba micromamba remove -y numba numbagg +# temporarily remove numexpr +micromamba remove -y numexpr # temporarily remove backends -micromamba remove -y cf_units h5py hdf5 netcdf4 +micromamba remove -y cf_units hdf5 h5py netcdf4 # forcibly remove packages to avoid artifacts -conda uninstall -y --force \ +micromamba remove -y --force \ numpy \ scipy \ pandas \ @@ -30,8 +32,17 @@ python -m pip install \ scipy \ matplotlib \ pandas +# for some reason pandas depends on pyarrow already. +# Remove once a `pyarrow` version compiled with `numpy>=2.0` is on `conda-forge` +python -m pip install \ + -i https://pypi.fury.io/arrow-nightlies/ \ + --prefer-binary \ + --no-deps \ + --pre \ + --upgrade \ + pyarrow # without build isolation for packages compiling against numpy -# TODO: remove once there are `numpy>=2.0` builds for numcodecs and cftime +# TODO: remove once there are `numpy>=2.0` builds for these python -m pip install \ --no-deps \ --upgrade \ diff --git a/ci/requirements/all-but-dask.yml b/ci/requirements/all-but-dask.yml index c16c174ff96..2f47643cc87 100644 --- a/ci/requirements/all-but-dask.yml +++ b/ci/requirements/all-but-dask.yml @@ -5,6 +5,7 @@ channels: dependencies: - black - aiobotocore + - array-api-strict - boto3 - bottleneck - cartopy diff --git a/ci/requirements/environment-3.12.yml b/ci/requirements/environment-3.12.yml index 805f71c0023..99b260a69a3 100644 --- a/ci/requirements/environment-3.12.yml +++ b/ci/requirements/environment-3.12.yml @@ -4,6 +4,7 @@ channels: - nodefaults dependencies: - aiobotocore + - array-api-strict - boto3 - bottleneck - cartopy diff --git a/ci/requirements/environment-windows-3.12.yml b/ci/requirements/environment-windows-3.12.yml index a1c78c64bbb..5b3034b7a20 100644 --- a/ci/requirements/environment-windows-3.12.yml +++ b/ci/requirements/environment-windows-3.12.yml @@ -2,6 +2,7 @@ name: xarray-tests channels: - conda-forge dependencies: + - array-api-strict - boto3 - bottleneck - cartopy diff --git a/ci/requirements/environment-windows.yml b/ci/requirements/environment-windows.yml index 1fd2cf54dba..cc361bac5e9 100644 --- a/ci/requirements/environment-windows.yml +++ b/ci/requirements/environment-windows.yml @@ -2,6 +2,7 @@ name: xarray-tests channels: - conda-forge dependencies: + - array-api-strict - boto3 - bottleneck - cartopy diff --git a/ci/requirements/environment.yml b/ci/requirements/environment.yml index c96f3fd717b..d3dbc088867 100644 --- a/ci/requirements/environment.yml +++ b/ci/requirements/environment.yml @@ -4,6 +4,7 @@ channels: - nodefaults dependencies: - aiobotocore + - array-api-strict - boto3 - bottleneck - cartopy diff --git a/ci/requirements/min-all-deps.yml b/ci/requirements/min-all-deps.yml index 775c98b83b7..d2965fb3fc5 100644 --- a/ci/requirements/min-all-deps.yml +++ b/ci/requirements/min-all-deps.yml @@ -8,6 +8,7 @@ dependencies: # When upgrading python, numpy, or pandas, must also change # doc/user-guide/installing.rst, doc/user-guide/plotting.rst and setup.py. - python=3.9 + - array-api-strict=1.0 # dependency for testing the array api compat - boto3=1.24 - bottleneck=1.3 - cartopy=0.21 diff --git a/pyproject.toml b/pyproject.toml index 4b5f6b31a43..d2a5c6b8748 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,6 +138,7 @@ module = [ "toolz.*", "zarr.*", "numpy.exceptions.*", # remove once support for `numpy<2.0` has been dropped + "array_api_strict.*", ] # Gradually we want to add more modules to this list, ratcheting up our total diff --git a/xarray/tests/test_array_api.py b/xarray/tests/test_array_api.py index 03dcfd9b20f..a5ffb37a109 100644 --- a/xarray/tests/test_array_api.py +++ b/xarray/tests/test_array_api.py @@ -1,7 +1,5 @@ from __future__ import annotations -import warnings - import pytest import xarray as xr @@ -9,10 +7,19 @@ np = pytest.importorskip("numpy", minversion="1.22") -with warnings.catch_warnings(): - warnings.simplefilter("ignore") - import numpy.array_api as xp # isort:skip - from numpy.array_api._array_object import Array # isort:skip +try: + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + + import numpy.array_api as xp + from numpy.array_api._array_object import Array +except ImportError: + # for `numpy>=2.0` + xp = pytest.importorskip("array_api_strict") + + from array_api_strict._array_object import Array # type: ignore[no-redef] @pytest.fixture