Skip to content

Commit

Permalink
map_over_datasets: fix error message for wrong result type (pydata#…
Browse files Browse the repository at this point in the history
…10016)

* `map_over_datasets`: fix error message for wrong result type

* newline for result
  • Loading branch information
mathause authored Feb 5, 2025
1 parent 4b48cf7 commit 160cced
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions xarray/core/datatree_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def _check_single_set_return_values(path_to_node: str, obj: Any) -> int | None:
isinstance(r, Dataset | None) for r in obj
):
raise TypeError(
f"the result of calling func on the node at position is not a Dataset or None "
f"or a tuple of such types: {obj!r}"
f"the result of calling func on the node at position '{path_to_node}' is"
f" not a Dataset or None or a tuple of such types:\n{obj!r}"
)

return len(obj)
Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_datatree_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_return_wrong_type(self, simple_datatree):
with pytest.raises(
TypeError,
match=re.escape(
"the result of calling func on the node at position is not a "
"the result of calling func on the node at position '.' is not a "
"Dataset or None or a tuple of such types"
),
):
Expand All @@ -84,7 +84,7 @@ def test_return_tuple_of_wrong_types(self, simple_datatree):
with pytest.raises(
TypeError,
match=re.escape(
"the result of calling func on the node at position is not a "
"the result of calling func on the node at position '.' is not a "
"Dataset or None or a tuple of such types"
),
):
Expand Down

0 comments on commit 160cced

Please sign in to comment.