From 06b75593c5500738dab5eb21e51ada997e26bafa Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 24 Mar 2025 13:45:50 +0200 Subject: [PATCH 1/7] Upgrade to xarray ^2025.3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 18286a8..e2e16b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,8 @@ readme = "README.rst" [tool.poetry.dependencies] python = "^3.10" pytest = {version = "^8.0.0", optional = true, extras = ["testing"]} -xarray = "^2025.0" dask = {version = "^2024.5.0", optional = true, extras = ["testing"]} +xarray = "^2025.3" distributed = {version = "^2024.5.0", optional = true, extras = ["testing"]} cacheout = "^0.16.0" arcae = "^0.2.7" From a150d201308992426291fafc23f0b67a943df92d Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 24 Mar 2025 13:46:19 +0200 Subject: [PATCH 2/7] Upgrade to python ^3.11 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e2e16b1..6dd1597 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Simon Perkins "] readme = "README.rst" [tool.poetry.dependencies] -python = "^3.10" +python = "^3.11" pytest = {version = "^8.0.0", optional = true, extras = ["testing"]} dask = {version = "^2024.5.0", optional = true, extras = ["testing"]} xarray = "^2025.3" From c33693f9993b2134d2dfeabfc6d820474c9b2fd0 Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 24 Mar 2025 13:47:05 +0200 Subject: [PATCH 3/7] Upgrade to zarr ^3.0 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6dd1597..f7218e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ distributed = {version = "^2024.5.0", optional = true, extras = ["testing"]} cacheout = "^0.16.0" arcae = "^0.2.7" typing-extensions = { version = "^4.12.2", python = "<3.11" } -zarr = {version = "^2.18.3", optional = true, extras = ["testing"]} +zarr = {version = "^3.0", optional = true, extras = ["testing"]} [tool.poetry.extras] testing = ["dask", "distributed", "pytest", "zarr"] @@ -39,7 +39,7 @@ sphinx-copybutton = "^0.5.2" pydata-sphinx-theme = "^0.15.4" ipython = "^8.27.0" dask = "^2024.9.0" -zarr = "^2.18.3" +zarr = "^3.0" [tool.ruff] line-length = 88 From 8b6d27ac6b2f22afcb7cc16b1997063f7e40ac1d Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 24 Mar 2025 13:48:35 +0200 Subject: [PATCH 4/7] Upgrade to dask and distributed ^2025.3.0 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f7218e5..4d8ac59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,9 +8,9 @@ readme = "README.rst" [tool.poetry.dependencies] python = "^3.11" pytest = {version = "^8.0.0", optional = true, extras = ["testing"]} -dask = {version = "^2024.5.0", optional = true, extras = ["testing"]} xarray = "^2025.3" -distributed = {version = "^2024.5.0", optional = true, extras = ["testing"]} +dask = {version = "^2025.3.0", optional = true, extras = ["testing"]} +distributed = {version = "^2025.3.0", optional = true, extras = ["testing"]} cacheout = "^0.16.0" arcae = "^0.2.7" typing-extensions = { version = "^4.12.2", python = "<3.11" } @@ -38,7 +38,7 @@ pygments = "^2.18.0" sphinx-copybutton = "^0.5.2" pydata-sphinx-theme = "^0.15.4" ipython = "^8.27.0" -dask = "^2024.9.0" +dask = "^2025.3.0" zarr = "^3.0" [tool.ruff] From 4fba12f678e14a5c86fa9b628c36f557c26322ae Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 24 Mar 2025 13:50:18 +0200 Subject: [PATCH 5/7] Add pickleshare to the documentation build --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 4d8ac59..cd8c987 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ pydata-sphinx-theme = "^0.15.4" ipython = "^8.27.0" dask = "^2025.3.0" zarr = "^3.0" +pickleshare = "^0.7.5" [tool.ruff] line-length = 88 From 01e68826a4e3b684076619dbdeedd2c8ace4140e Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 24 Mar 2025 16:20:57 +0200 Subject: [PATCH 6/7] Zarr v3 String Handling --- tests/test_zarr_roundtrip.py | 21 +++++++++++++------ xarray_ms/backend/msv2/factories/antenna.py | 6 ++++-- .../backend/msv2/factories/correlated.py | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/test_zarr_roundtrip.py b/tests/test_zarr_roundtrip.py index 2eb0215..a6a063d 100644 --- a/tests/test_zarr_roundtrip.py +++ b/tests/test_zarr_roundtrip.py @@ -1,18 +1,27 @@ +from contextlib import nullcontext + +import pytest import xarray.testing as xt from xarray.backends.api import open_dataset, open_datatree +ZARR_V3_WARNINGS = (FutureWarning, UserWarning) + -def test_dataset_roundtrip(simmed_ms, tmp_path): +@pytest.mark.parametrize("zarr_format", [2, 3]) +def test_dataset_roundtrip(simmed_ms, tmp_path, zarr_format): ds = open_dataset(simmed_ms) zarr_path = tmp_path / "test_dataset.zarr" - ds.to_zarr(zarr_path, compute=True, consolidated=True) - ds2 = open_dataset(zarr_path) + with pytest.warns(ZARR_V3_WARNINGS) if zarr_format == 3 else nullcontext(): + ds.to_zarr(zarr_path, compute=True, consolidated=True, zarr_format=zarr_format) + ds2 = open_dataset(zarr_path) xt.assert_identical(ds, ds2) -def test_datatree_roundtrip(simmed_ms, tmp_path): +@pytest.mark.parametrize("zarr_format", [2, 3]) +def test_datatree_roundtrip(simmed_ms, tmp_path, zarr_format): dt = open_datatree(simmed_ms) zarr_path = tmp_path / "test_datatree.zarr" - dt.to_zarr(zarr_path, compute=True, consolidated=True) - dt2 = open_datatree(zarr_path) + with pytest.warns(ZARR_V3_WARNINGS) if zarr_format == 3 else nullcontext(): + dt.to_zarr(zarr_path, compute=True, consolidated=True, zarr_format=zarr_format) + dt2 = open_datatree(zarr_path) xt.assert_identical(dt, dt2) diff --git a/xarray_ms/backend/msv2/factories/antenna.py b/xarray_ms/backend/msv2/factories/antenna.py index fb08ea9..acfd191 100644 --- a/xarray_ms/backend/msv2/factories/antenna.py +++ b/xarray_ms/backend/msv2/factories/antenna.py @@ -86,7 +86,7 @@ def get_dataset(self) -> Mapping[str, Variable]: pol_type = ( pac.list_flatten(filtered_feeds["POLARIZATION_TYPE"]).to_numpy().reshape(-1, 2) ) - receptor_labels = [f"pol_{i}" for i in range(nreceptors.item())] + receptor_labels = np.asarray([f"pol_{i}" for i in range(nreceptors.item())], object) metre_attrs = {"units": ["m"], "type": "quantity"} rad_attrs = {"units": ["rad"], "type": "quantity"} @@ -122,7 +122,9 @@ def get_dataset(self) -> Mapping[str, Variable]: "mount": Variable("antenna_name", mount), "telescope_name": Variable("telescope_name", telescope_names), "station": Variable("antenna_name", station), - "cartesian_pos_label": Variable("cartesian_pos_label", ["x", "y", "z"]), + "cartesian_pos_label": Variable( + "cartesian_pos_label", np.asarray(["x", "y", "z"], object) + ), "polarization_type": Variable(("antenna_name", "receptor_label"), pol_type), "receptor_label": Variable("receptor_label", receptor_labels), }, diff --git a/xarray_ms/backend/msv2/factories/correlated.py b/xarray_ms/backend/msv2/factories/correlated.py index 91fba85..38245fe 100644 --- a/xarray_ms/backend/msv2/factories/correlated.py +++ b/xarray_ms/backend/msv2/factories/correlated.py @@ -238,8 +238,8 @@ def get_variables(self) -> Mapping[str, Variable]: "baseline_antenna2_name", (("baseline_id",), ant2_names, {"coordinates": "baseline_antenna2_name"}), ), - ("polarization", (("polarization",), corr_type, None)), - ("uvw_label", (("uvw_label",), ["u", "v", "w"], None)), + ("polarization", (("polarization",), np.asarray(corr_type, object), None)), + ("uvw_label", (("uvw_label",), np.asarray(["u", "v", "w"], object), None)), ("field_name", ("time", field_names, {"coordinates": "field_name"})), ("scan_number", ("time", partition.scan_numbers, {"coordinates": "scan_number"})), ( From b4290ba8e1a700014d5640e830b9bb26f094903a Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Fri, 4 Apr 2025 13:44:42 +0200 Subject: [PATCH 7/7] Suppress warning in tutorial --- doc/source/tutorial.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/tutorial.rst b/doc/source/tutorial.rst index e857775..388557c 100644 --- a/doc/source/tutorial.rst +++ b/doc/source/tutorial.rst @@ -144,6 +144,7 @@ this to a zarr_ store. It is then trivial to open this using ``open_datatree``: .. ipython:: python + :okwarning: dt2 = xarray.open_datatree(zarr_path) xarray.testing.assert_identical(dt, dt2)