From 2157b21202f59ab18ac09bd71e30495e76845b69 Mon Sep 17 00:00:00 2001 From: pp-mo Date: Fri, 14 Aug 2026 19:30:58 +0100 Subject: [PATCH 1/9] Specific fixes for currently-failing roundtrip tests. --- tests/data_testcase_schemas.py | 1 + .../integration/test_iris_xarray_roundtrips.py | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/data_testcase_schemas.py b/tests/data_testcase_schemas.py index 7622da3..ce68460 100644 --- a/tests/data_testcase_schemas.py +++ b/tests/data_testcase_schemas.py @@ -525,6 +525,7 @@ def standard_testcase(request, session_testdir): # """ "small_rotPole_precipitation", "small_FC_167", + "test_monotonic_coordinate", ], # Xarray can save ~anything "save": [r"test_monotonic_coordinate"], diff --git a/tests/integration/test_iris_xarray_roundtrips.py b/tests/integration/test_iris_xarray_roundtrips.py index d0eb2bf..7fcf045 100644 --- a/tests/integration/test_iris_xarray_roundtrips.py +++ b/tests/integration/test_iris_xarray_roundtrips.py @@ -79,9 +79,20 @@ def test_roundtrip_ixi(standard_testcase, use_irislock, adjust_chunks): "testdata____ugrid__21_triangle_example", # Problem with units on time bounds "label_and_climate__small_FC_167", - # Broken UGRID files now won't load in Iris >= 3.10 - "unstructured_grid__mesh_C12", - "_unstructured_grid__theta_nodal_xios", + # # Broken UGRID files now won't load in Iris >= 3.10 + # "unstructured_grid__mesh_C12", + # "_unstructured_grid__theta_nodal_xios", + + # **No** mesh files will now roundtrip, since xarray 2026.04.0. + # This is because xarray now normalises the array type when loading + # from ncdata, removing masks and converting to nanarrays (thus making ints + # into floats). + # Previously we could create xarray Datasets with masked integer variables + # as data -- though that was alwaysobviously a bit tricksy. + # Iris can't accept the new form as it insists on integer types for + # mesh connectivities :-( + # TODO: do something to get this working again? + "unstructured" ] ) if any(key in standard_testcase.name for key in exclude_case_keys): From 45645c0378cdaa8b0262bf1d8ea16039b74f5c2b Mon Sep 17 00:00:00 2001 From: pp-mo Date: Fri, 14 Aug 2026 18:28:58 +0100 Subject: [PATCH 2/9] Supply set_auto_chartostring for Nc4DatasetLike. --- lib/ncdata/dataset_like.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ncdata/dataset_like.py b/lib/ncdata/dataset_like.py index 3702f95..b92ffa9 100644 --- a/lib/ncdata/dataset_like.py +++ b/lib/ncdata/dataset_like.py @@ -81,6 +81,11 @@ def __setattr__(self, attr, value): else: self.setncattr(attr, value) + def set_auto_chartostring(self, value): + if bool(value): + msg = "Cannot enable 'auto_chartostring' for Nc4Dataselike or Nc4VariableLike." + raise ValueError() + class Nc4DatasetLike(_Nc4DatalikeWithNcattrs): """ From f0c1cf821eaae0f651c83145792e21df7055eb35 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 28 Aug 2026 14:38:56 +0100 Subject: [PATCH 3/9] Fix data array for string data example. --- tests/data_testcase_schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data_testcase_schemas.py b/tests/data_testcase_schemas.py index ce68460..658bf22 100644 --- a/tests/data_testcase_schemas.py +++ b/tests/data_testcase_schemas.py @@ -434,7 +434,7 @@ def _define_unit_dtype_testcases(): name="vx", dims=["strlen"], dtype="S1", - data=np.array("abc", dtype="S1"), + data=np.array(list("abc"), dtype="S1"), ) ], } From 7cf469fe465ee9537f5ab51596ee3414204aee89 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Thu, 17 Sep 2026 18:04:35 +0100 Subject: [PATCH 4/9] Remove some excluded testcases, that now don't fail. --- tests/data_testcase_schemas.py | 2 +- .../test_iris_load_and_save_equivalence.py | 6 ++-- .../test_iris_xarray_roundtrips.py | 31 ++++++++----------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/tests/data_testcase_schemas.py b/tests/data_testcase_schemas.py index 658bf22..8212577 100644 --- a/tests/data_testcase_schemas.py +++ b/tests/data_testcase_schemas.py @@ -356,7 +356,7 @@ def _define_iris_testdata_testcases(): # "_ORCA2__votemper", # ] EXCLUDES = [] - for filepath in _netcdf_testfile_paths: + for filepath in sorted(_netcdf_testfile_paths): param_name = str(filepath) # remove unwanted path elements param_name = param_name.replace(str(_testdirpath), "") diff --git a/tests/integration/test_iris_load_and_save_equivalence.py b/tests/integration/test_iris_load_and_save_equivalence.py index 238e456..e51252d 100644 --- a/tests/integration/test_iris_load_and_save_equivalence.py +++ b/tests/integration/test_iris_load_and_save_equivalence.py @@ -59,8 +59,9 @@ def test_load_direct_vs_viancdata( # Some of the legacy UGRID unstructured files have incorrect encodings # which are currently causing loading errors in Iris since UGRID loading # became an always-on thing in v3.11 - "unstructured_grid__theta_nodal_xios", - "ugrid__21_triangle_example", + # TEMP - re-enable ?? + # "unstructured_grid__theta_nodal_xios", + # "ugrid__21_triangle_example", ] if any( name_fragment in standard_testcase.name @@ -121,7 +122,6 @@ def test_save_direct_vs_viancdata(standard_testcase, tmp_path): # Some of the legacy UGRID unstructured files have incorrect encodings # which are currently causing loading errors in Iris since UGRID loading # became an always-on thing in v3.11 - "unstructured_grid__theta_nodal_xios", "unstructured_grid__mesh_C12", "ugrid__21_triangle_example", ] diff --git a/tests/integration/test_iris_xarray_roundtrips.py b/tests/integration/test_iris_xarray_roundtrips.py index 7fcf045..016af63 100644 --- a/tests/integration/test_iris_xarray_roundtrips.py +++ b/tests/integration/test_iris_xarray_roundtrips.py @@ -70,19 +70,12 @@ def test_roundtrip_ixi(standard_testcase, use_irislock, adjust_chunks): + BAD_LOADSAVE_TESTCASES["xarray"]["load"] # TODO: remaining unresolved problems ... + [ - # string dimension problem - "ds__dtype__string", # outstanding dims-mismatch problems. "testing__small_theta_colpex", # coordinate attributes on mesh coordinate variables - "testdata____unstructured_grid__data_C4", "testdata____ugrid__21_triangle_example", - # Problem with units on time bounds - "label_and_climate__small_FC_167", - # # Broken UGRID files now won't load in Iris >= 3.10 - # "unstructured_grid__mesh_C12", - # "_unstructured_grid__theta_nodal_xios", - + # Broken UGRID files now won't load in Iris >= 3.10 + "unstructured_grid__mesh_C12", # **No** mesh files will now roundtrip, since xarray 2026.04.0. # This is because xarray now normalises the array type when loading # from ncdata, removing masks and converting to nanarrays (thus making ints @@ -92,7 +85,8 @@ def test_roundtrip_ixi(standard_testcase, use_irislock, adjust_chunks): # Iris can't accept the new form as it insists on integer types for # mesh connectivities :-( # TODO: do something to get this working again? - "unstructured" + # TEMP - re-enable ?? :: but we do expect this to fail with xr>2026.02 + # "unstructured" ] ) if any(key in standard_testcase.name for key in exclude_case_keys): @@ -220,14 +214,15 @@ def test_roundtrip_xix( # float time(time) ; # time:bounds = 'time_bnds' # float time_bnds(time, time_bnds) ; - "label_and_climate__small_FC_167", - "rotated__xyt__small_rotPole_precipitation", - # This one fails to load in xarray, for somewhat unclear reasons - # NotImplementedError: Can not use auto rechunking with object dtype. - # We are unable to estimate the size in bytes of object data - "unstructured_grid__lfric_surface_mean", - # Iris loses the name of the unstructured dimension, causing multiple problems - "unstructured_grid__data_C4", + # TEMP - re-enable ?? + # "label_and_climate__small_FC_167", + # "rotated__xyt__small_rotPole_precipitation", + # # This one fails to load in xarray, for somewhat unclear reasons + # # NotImplementedError: Can not use auto rechunking with object dtype. + # # We are unable to estimate the size in bytes of object data + # "unstructured_grid__lfric_surface_mean", + # # Iris loses the name of the unstructured dimension, causing multiple problems + # "unstructured_grid__data_C4", ] if any(key in standard_testcase.name for key in excluded_casename_keys): pytest.skip("excluded testcase") From 8c0679b013ab47607010222d0e7a4ec229d52e75 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 18 Sep 2026 10:20:23 +0100 Subject: [PATCH 5/9] Exclude all UGRID files from iris-xarray-iris roundtrip tests. --- tests/integration/test_iris_xarray_roundtrips.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/test_iris_xarray_roundtrips.py b/tests/integration/test_iris_xarray_roundtrips.py index 016af63..16d27ec 100644 --- a/tests/integration/test_iris_xarray_roundtrips.py +++ b/tests/integration/test_iris_xarray_roundtrips.py @@ -85,8 +85,7 @@ def test_roundtrip_ixi(standard_testcase, use_irislock, adjust_chunks): # Iris can't accept the new form as it insists on integer types for # mesh connectivities :-( # TODO: do something to get this working again? - # TEMP - re-enable ?? :: but we do expect this to fail with xr>2026.02 - # "unstructured" + "unstructured", ] ) if any(key in standard_testcase.name for key in exclude_case_keys): From 096be94c47fd77317ac676d1b400b317a56a95d6 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 18 Sep 2026 10:31:13 +0100 Subject: [PATCH 6/9] Skip another file for ixi tests, with latest xarray. --- tests/integration/test_iris_xarray_roundtrips.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/test_iris_xarray_roundtrips.py b/tests/integration/test_iris_xarray_roundtrips.py index 16d27ec..3e47a3c 100644 --- a/tests/integration/test_iris_xarray_roundtrips.py +++ b/tests/integration/test_iris_xarray_roundtrips.py @@ -72,6 +72,8 @@ def test_roundtrip_ixi(standard_testcase, use_irislock, adjust_chunks): + [ # outstanding dims-mismatch problems. "testing__small_theta_colpex", + # all-masked variables --> changing dtype, since xarray>v2026.02.0 + "testing__cell_methods", # coordinate attributes on mesh coordinate variables "testdata____ugrid__21_triangle_example", # Broken UGRID files now won't load in Iris >= 3.10 From 4a87dcde7ca5e6dd46c98cf79b82ede924d57e65 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 18 Sep 2026 11:18:31 +0100 Subject: [PATCH 7/9] Tiny linter fix. --- lib/ncdata/dataset_like.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ncdata/dataset_like.py b/lib/ncdata/dataset_like.py index b92ffa9..4d58410 100644 --- a/lib/ncdata/dataset_like.py +++ b/lib/ncdata/dataset_like.py @@ -84,7 +84,7 @@ def __setattr__(self, attr, value): def set_auto_chartostring(self, value): if bool(value): msg = "Cannot enable 'auto_chartostring' for Nc4Dataselike or Nc4VariableLike." - raise ValueError() + raise ValueError(msg) class Nc4DatasetLike(_Nc4DatalikeWithNcattrs): From 0e0389eda8e41f34a5b79a257b8538a2b92c7b38 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 18 Sep 2026 13:24:18 +0100 Subject: [PATCH 8/9] Fix doctest failure with later xarray: generalise output for cross-version compatibility. --- docs/userdocs/getting_started/introduction.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/userdocs/getting_started/introduction.rst b/docs/userdocs/getting_started/introduction.rst index 0a4a51d..22d4e81 100644 --- a/docs/userdocs/getting_started/introduction.rst +++ b/docs/userdocs/getting_started/introduction.rst @@ -265,9 +265,9 @@ Example code snippets : Dimensions: (dim0: 3) Dimensions without coordinates: dim0 Data variables: - vx0 (dim0) int64 ... dask.array - vx1 (dim0) int64 ... dask.array - v_mag (dim0) float64 ... dask.array + vx0 (dim0) ... dask.array Date: Thu, 17 Sep 2026 18:15:40 +0100 Subject: [PATCH 9/9] Temporary fix to run against trial iris branch. --- .github/workflows/ci-tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index ffeb139..845eb51 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -81,6 +81,14 @@ jobs: mkdir --parents ${GITHUB_WORKSPACE}/iris_test_data mv iris-test-data-${IRIS_TEST_DATA_VERSION} ${GITHUB_WORKSPACE}/iris_test_data_download + - name: "TEMPORARY: install specific Iris from pp-mo/lazy_encoding" + run: | + cd ${GITHUB_WORKSPACE} + git clone https://github.com/pp-mo/iris.git ./iris2 + cd ./iris2 + git checkout lazy_encoding + pip install -e . + - name: "Run tests" if: matrix.session == 'tests' run: |