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) diff --git a/pyproject.toml b/pyproject.toml index e312e57..207a6d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,15 +6,15 @@ authors = ["Simon Perkins "] readme = "README.rst" [tool.poetry.dependencies] -python = "^3.10" +python = "^3.11" pytest = {version = "^8.0.0", optional = true, extras = ["testing"]} -xarray = "^2025.0" -dask = {version = "^2024.5.0", optional = true, extras = ["testing"]} -distributed = {version = "^2024.5.0", optional = true, extras = ["testing"]} +xarray = "^2025.3" +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.8" 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"] @@ -38,8 +38,9 @@ pygments = "^2.18.0" sphinx-copybutton = "^0.5.2" pydata-sphinx-theme = "^0.15.4" ipython = "^8.27.0" -dask = "^2024.9.0" -zarr = "^2.18.3" +dask = "^2025.3.0" +zarr = "^3.0" +pickleshare = "^0.7.5" [tool.ruff] line-length = 88 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 aea9cfa..f91f61c 100644 --- a/xarray_ms/backend/msv2/factories/antenna.py +++ b/xarray_ms/backend/msv2/factories/antenna.py @@ -87,7 +87,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"} @@ -123,7 +123,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 c5cc70a..c5a885f 100644 --- a/xarray_ms/backend/msv2/factories/correlated.py +++ b/xarray_ms/backend/msv2/factories/correlated.py @@ -244,8 +244,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"})), (