Skip to content

Commit 6e9414d

Browse files
committed
update tests
1 parent d7c40a1 commit 6e9414d

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

xarray/tests/test_dataarray.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,12 @@ def test_coords(self) -> None:
15221522
self.mda["level_1"] = ("x", np.arange(4))
15231523
self.mda.coords["level_1"] = ("x", np.arange(4))
15241524

1525+
def test_coords_dims(self) -> None:
1526+
da = DataArray(
1527+
[[1.0, 2.0], [3.0, 4.0]], coords={"a": ("x", [0, 1])}, dims=("x", "y")
1528+
)
1529+
assert da.coords.dims == ("x",)
1530+
15251531
def test_coords_to_index(self) -> None:
15261532
da = DataArray(np.zeros((2, 3)), [("x", [1, 2]), ("y", list("abc"))])
15271533

xarray/tests/test_dataset.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,11 @@ def test_coords_properties(self) -> None:
892892
"b": np.dtype("int64"),
893893
}
894894

895+
def test_coords_dims(self) -> None:
896+
# https://github.com/pydata/xarray/issues/9466
897+
ds_no_coord = Dataset(data_vars={"a": ("x", [0, 1])})
898+
assert not len(ds_no_coord.coords.dims)
899+
895900
def test_coords_modify(self) -> None:
896901
data = Dataset(
897902
{

xarray/tests/test_datatree.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,18 @@ def test_properties(self) -> None:
666666
"b": np.dtype("int64"),
667667
}
668668

669+
def test_dims(self) -> None:
670+
# https://github.com/pydata/xarray/issues/9466
671+
ds = Dataset(
672+
data_vars={
673+
"foo": (["x", "y"], np.random.randn(2, 3)),
674+
},
675+
)
676+
dt = DataTree(dataset=ds)
677+
dt["child"] = DataTree()
678+
679+
assert not len(dt.coords.dims)
680+
669681
def test_modify(self) -> None:
670682
ds = Dataset(
671683
data_vars={

0 commit comments

Comments
 (0)