Skip to content

Commit

Permalink
wrap Dataset input in a DataTree node before setting
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Sep 18, 2024
1 parent bf036ba commit b520f9c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions xarray/core/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ def __setitem__(
# TODO should possibly deal with hashables in general?
# path-like: a name of a node/variable, or path to a node/variable
path = NodePath(key)
if isinstance(value, Dataset):
value = DataTree(dataset=value)
return self._set_item(path, value, new_nodes_along_path=True)
else:
raise ValueError("Invalid format for key")
Expand Down

0 comments on commit b520f9c

Please sign in to comment.