Skip to content

Commit

Permalink
Fixes for new dependencies, exclude numpy v2 (#84)
Browse files Browse the repository at this point in the history
* Exclude extra numpy v2 dtypes from sanity check.

* Fixes to accomodata numpy v2, and intermittent xarray problem.

* Pin numpy in CI tests.
  • Loading branch information
pp-mo authored Jun 25, 2024
1 parent add0ac3 commit 12d5ad9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: "Install dependencies"
run: |
conda install --yes pytest iris xarray filelock requests
conda install --yes "numpy<2" pytest iris xarray filelock requests
- name: "Install *latest* Iris"
run: |
Expand Down
1 change: 1 addition & 0 deletions requirements/readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:

dependencies:
- netCDF4>=1.4
- numpy <2.0
- iris
- xarray
- filelock
Expand Down
28 changes: 22 additions & 6 deletions tests/data_testcase_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ def data_types():
yield "string"


# Just confirm that the above list of types matches those used by netCDF4, except for
# 'string' replacing 'S1'.
assert set(data_types()) == (
set(nc.default_fillvals.keys()) - set(["S1"]) | set(["string"])
# Confirm that the above list of types matches those of netCDF4, with specific fixes
# Get the dtype list from the netCDF default fill-values.
_nc_dtypes = set(nc.default_fillvals.keys())
# Remove the numpy-only complex types
_nc_dtypes = set(
typename for typename in _nc_dtypes if np.dtype(typename).kind != "c"
)

# Also replace 'S1' with our own 'string' type marker
_nc_dtypes.remove("S1")
_nc_dtypes.add("string")
# This should match the list of dtypes which we support (and test against)
assert set(data_types()) == _nc_dtypes

# Suitable test values for each attribute/data type.
_INT_Approx_2x31 = int(2**31 - 1)
Expand Down Expand Up @@ -509,7 +515,17 @@ def standard_testcase(request, session_testdir):
},
"xarray": {
# We think Xarray can load ~anything (maybe returning nothing)
"load": [],
"load": [
# .. except a few specific bounds variables generate a peculiar error
# """
# xarray.core.variable.MissingDimensionsError: 'time_bnd' has more than
# 1-dimension and the same name as one of its dimensions
# ('time', 'time_bnd'). xarray disallows such variables because they
# conflict with the coordinates used to label dimensions.
# """
"small_rotPole_precipitation",
"small_FC_167",
],
# Xarray can save ~anything
"save": [r"test_monotonic_coordinate"],
},
Expand Down

0 comments on commit 12d5ad9

Please sign in to comment.