From 4c2937970285ca15070985ac2341b197a5e01667 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Tue, 25 Jun 2024 10:58:48 +0100 Subject: [PATCH 1/3] Exclude extra numpy v2 dtypes from sanity check. --- tests/data_testcase_schemas.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/data_testcase_schemas.py b/tests/data_testcase_schemas.py index 26f8c7e..cdb5980 100644 --- a/tests/data_testcase_schemas.py +++ b/tests/data_testcase_schemas.py @@ -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) From 50e53ab54154f3fea43fd083b2351a1052c3407d Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Tue, 25 Jun 2024 11:55:29 +0100 Subject: [PATCH 2/3] Fixes to accomodata numpy v2, and intermittent xarray problem. --- requirements/readthedocs.yml | 1 + tests/data_testcase_schemas.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/requirements/readthedocs.yml b/requirements/readthedocs.yml index 97930e5..4cce034 100644 --- a/requirements/readthedocs.yml +++ b/requirements/readthedocs.yml @@ -5,6 +5,7 @@ channels: dependencies: - netCDF4>=1.4 + - numpy <2.0 - iris - xarray - filelock diff --git a/tests/data_testcase_schemas.py b/tests/data_testcase_schemas.py index cdb5980..8ccb8af 100644 --- a/tests/data_testcase_schemas.py +++ b/tests/data_testcase_schemas.py @@ -515,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"], }, From 038aaea42a7b0fd0bf76e2c0820f056d83e0b762 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Tue, 25 Jun 2024 12:11:45 +0100 Subject: [PATCH 3/3] Pin numpy in CI tests. --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index afdaa2b..5fec7cf 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -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: |