Skip to content

Commit 303e88f

Browse files
committed
Use 2D array to properly test to_dataset error handling logic
1 parent 4673c78 commit 303e88f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

xarray/tests/test_dataarray.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3793,8 +3793,16 @@ def test_to_dataset_whole(self) -> None:
37933793
actual = named.to_dataset("bar")
37943794

37953795
def test_to_dataset_split(self) -> None:
3796-
array = DataArray([1, 2, 3], coords=[("x", list("abc"))], attrs={"a": 1})
3797-
expected = Dataset({"a": 1, "b": 2, "c": 3}, attrs={"a": 1})
3796+
array = DataArray(
3797+
[[1, 2], [3, 4], [5, 6]],
3798+
coords=[("x", list("abc")), ("y", [0.0, 0.1])],
3799+
attrs={"a": 1},
3800+
)
3801+
expected = Dataset(
3802+
{"a": ("y", [1, 2]), "b": ("y", [3, 4]), "c": ("y", [5, 6])},
3803+
coords={"y": [0.0, 0.1]},
3804+
attrs={"a": 1},
3805+
)
37983806
actual = array.to_dataset("x")
37993807
assert_identical(expected, actual)
38003808

0 commit comments

Comments
 (0)