Skip to content
Draft
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
4 changes: 3 additions & 1 deletion xarray/core/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def _to_new_dataset(data: Dataset | Coordinates | None) -> Dataset:
elif data is None:
ds = Dataset()
else:
raise TypeError(f"data object is not an xarray.Dataset, dict, or None: {data}")
raise TypeError(
f"data object is not an xarray.Dataset, Coordinates, or None: {data}"
)
return ds


Expand Down
6 changes: 6 additions & 0 deletions xarray/tests/test_datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ def test_create_with_data(self) -> None:
with pytest.raises(TypeError):
DataTree(name="mary", dataset="junk") # type: ignore[arg-type]

with pytest.raises(
TypeError,
match=r"data object is not an xarray.Dataset, Coordinates, or None: \{\}",
):
DataTree(name="mary", dataset={}) # type: ignore[arg-type]

def test_set_data(self) -> None:
john = DataTree(name="john")
dat = xr.Dataset({"a": 0})
Expand Down
Loading