diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index d9c797e27cd..af4b68b0d9b 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash # install cython for building cftime without build isolation -micromamba install "cython>=0.29.20" py-cpuinfo +micromamba install "cython>=0.29.20" py-cpuinfo setuptools-scm # temporarily (?) remove numbagg and numba micromamba remove -y numba numbagg sparse # temporarily remove numexpr micromamba remove -y numexpr # temporarily remove backends -micromamba remove -y cf_units hdf5 h5py netcdf4 +micromamba remove -y cf_units hdf5 h5py netcdf4 pydap # forcibly remove packages to avoid artifacts micromamba remove -y --force \ numpy \ @@ -31,7 +31,8 @@ python -m pip install \ numpy \ scipy \ matplotlib \ - pandas + pandas \ + h5py # 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 \ @@ -70,6 +71,6 @@ python -m pip install \ git+https://github.com/intake/filesystem_spec \ git+https://github.com/SciTools/nc-time-axis \ git+https://github.com/xarray-contrib/flox \ + git+https://github.com/h5netcdf/h5netcdf \ git+https://github.com/dgasmith/opt_einsum # git+https://github.com/pydata/sparse - # git+https://github.com/h5netcdf/h5netcdf diff --git a/xarray/tests/__init__.py b/xarray/tests/__init__.py index 7ea02eafd76..c202e191293 100644 --- a/xarray/tests/__init__.py +++ b/xarray/tests/__init__.py @@ -142,8 +142,36 @@ def _importorskip( not has_scipy_or_netCDF4, reason="requires scipy or netCDF4" ) has_numpy_array_api, requires_numpy_array_api = _importorskip("numpy", "1.26.0") -has_h5netcdf_ros3, requires_h5netcdf_ros3 = _importorskip("h5netcdf", "1.3.0") + +def _importorskip_h5netcdf_ros3(): + try: + import h5netcdf + + has_h5netcdf = True + except ImportError: + has_h5netcdf = False + + if not has_h5netcdf: + return has_h5netcdf, pytest.mark.skipif( + not has_h5netcdf, reason="requires h5netcdf" + ) + + h5netcdf_with_ros3 = Version(h5netcdf.__version__) >= Version("1.3.0") + + import h5py + + h5py_with_ros3 = h5py.get_config().ros3 + + has_h5netcdf_ros3 = h5netcdf_with_ros3 and h5py_with_ros3 + + return has_h5netcdf_ros3, pytest.mark.skipif( + not has_h5netcdf_ros3, + reason="requires h5netcdf>=1.3.0 and h5py with ros3 support", + ) + + +has_h5netcdf_ros3, requires_h5netcdf_ros3 = _importorskip_h5netcdf_ros3() has_netCDF4_1_6_2_or_above, requires_netCDF4_1_6_2_or_above = _importorskip( "netCDF4", "1.6.2" ) diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index 256a02d49e2..cb765ce91f8 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -6,7 +6,6 @@ import numpy as np import pandas as pd import pytest -from numpy.core import defchararray import xarray as xr from xarray.core import formatting @@ -770,9 +769,9 @@ def test_repr_file_collapsed(tmp_path) -> None: ) def test__mapping_repr(display_max_rows, n_vars, n_attr) -> None: long_name = "long_name" - a = defchararray.add(long_name, np.arange(0, n_vars).astype(str)) - b = defchararray.add("attr_", np.arange(0, n_attr).astype(str)) - c = defchararray.add("coord", np.arange(0, n_vars).astype(str)) + a = np.char.add(long_name, np.arange(0, n_vars).astype(str)) + b = np.char.add("attr_", np.arange(0, n_attr).astype(str)) + c = np.char.add("coord", np.arange(0, n_vars).astype(str)) attrs = {k: 2 for k in b} coords = {_c: np.array([0, 1], dtype=np.uint64) for _c in c} data_vars = dict()