Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ authors = ["Simon Perkins <simon.perkins@gmail.com>"]
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"]
Expand All @@ -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
Expand Down
21 changes: 15 additions & 6 deletions tests/test_zarr_roundtrip.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 4 additions & 2 deletions xarray_ms/backend/msv2/factories/antenna.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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),
},
Expand Down
4 changes: 2 additions & 2 deletions xarray_ms/backend/msv2/factories/correlated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})),
(
Expand Down
Loading