diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index ffeb139..62dadc5 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -26,7 +26,7 @@ jobs: fail-fast: false matrix: session: ["tests", "doctests-docs", "doctests-api"] - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] exclude: - session: "doctests-docs" python-version: "3.10" @@ -34,12 +34,16 @@ jobs: python-version: "3.11" - session: "doctests-docs" python-version: "3.12" + - session: "doctests-docs" + python-version: "3.13" - session: "doctests-api" python-version: "3.10" - session: "doctests-api" python-version: "3.11" - session: "doctests-api" python-version: "3.12" + - session: "doctests-api" + python-version: "3.13" defaults: run: diff --git a/docs/changelog_fragments/255.bug.rst b/docs/changelog_fragments/255.bug.rst new file mode 100644 index 0000000..ada4570 --- /dev/null +++ b/docs/changelog_fragments/255.bug.rst @@ -0,0 +1 @@ +Fixes to work with Iris >= v3.16 and xarray > v2026.02. diff --git a/docs/changelog_fragments/258.dev.rst b/docs/changelog_fragments/258.dev.rst new file mode 100644 index 0000000..d6ba1cf --- /dev/null +++ b/docs/changelog_fragments/258.dev.rst @@ -0,0 +1 @@ +Support and test against Python 3.14. diff --git a/docs/details/interface_support.rst b/docs/details/interface_support.rst index 08c95e1..5f0315b 100644 --- a/docs/details/interface_support.rst +++ b/docs/details/interface_support.rst @@ -5,7 +5,8 @@ Support for Interfaces and Dependencies Python Compatibility -------------------- -NcData currently supports Python >= 3.10, and is tested against 3.10, 3.11, 3.12 and 3.13. +NcData currently supports Python >= 3.10, and is tested against +3.10, 3.11, 3.12, 3.13 and 3.14. NetCDF4 Compatibility --------------------- 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 changing dtype, since xarray>v2026.02.0 + "testing__cell_methods", # 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", + # **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 version_tuple(iris.__version__) < version_tuple("3.16"): + # TODO: remove backwards compatibility when we drop Python 3.11 support + exclude_case_keys.extend( + [ + "ds__dtype__string", + "ds__stringvar", + ] + ) if any(key in standard_testcase.name for key in exclude_case_keys): pytest.skip("excluded testcase") @@ -209,14 +224,6 @@ 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", ] if any(key in standard_testcase.name for key in excluded_casename_keys): pytest.skip("excluded testcase") diff --git a/tests/unit/tests/test_version_tuple.py b/tests/unit/tests/test_version_tuple.py new file mode 100644 index 0000000..dabdbec --- /dev/null +++ b/tests/unit/tests/test_version_tuple.py @@ -0,0 +1,37 @@ +""" +Tests for the test utility :func:`tests.version_majorminor`. +""" + +import pytest + +from tests import version_tuple + + +def test_empty(): + assert version_tuple("") == () + + +def test_basic(): + assert version_tuple("1.2.3") == (1, 2, 3) + + +def test_one(): + assert version_tuple("1") == (1,) + + +@pytest.mark.parametrize("tail", ["alpha", ".alpha", "."]) +@pytest.mark.parametrize("base", ["1", "1.2"]) +def test_valid_tails(tail, base): + assert version_tuple(base + tail) == version_tuple(base) + + +@pytest.mark.parametrize("version", ["a1.", "1a.2", "a1.2", "1.2a."]) +def test_invalid_nonnumerics(version): + with pytest.raises(ValueError, match="invalid"): + version_tuple(version) + + +def test_interlength_compares(): + assert version_tuple("2") > version_tuple("1.99") + assert version_tuple("1.2.3") > version_tuple("1.1") + assert version_tuple("1.2.3") < version_tuple("1.3")