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

more engine environment tricks in preparation for numpy>=2 #8978

Merged
merged 10 commits into from
Apr 29, 2024
9 changes: 5 additions & 4 deletions ci/install-upstream-wheels.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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
30 changes: 29 additions & 1 deletion xarray/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
7 changes: 3 additions & 4 deletions xarray/tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Loading