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
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, xarray.Coordinates, or None: {data}"
)
return ds


Expand Down
5 changes: 5 additions & 0 deletions xarray/tests/test_datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def test_data_arg(self) -> None:
with pytest.raises(TypeError):
DataTree(dataset=xr.DataArray(42, name="foo")) # type: ignore[arg-type]

# A dict is not an accepted data object; the error message must not
# advertise ``dict`` as a valid type (regression test for #11514).
with pytest.raises(TypeError, match=r"xarray\.Coordinates"):
DataTree(dataset=dict()) # type: ignore[arg-type]

def test_child_data_not_copied(self) -> None:
# regression test for https://github.com/pydata/xarray/issues/9683
class NoDeepCopy:
Expand Down