Skip to content

Commit 160cced

Browse files
authored
map_over_datasets: fix error message for wrong result type (#10016)
* `map_over_datasets`: fix error message for wrong result type * newline for result
1 parent 4b48cf7 commit 160cced

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

xarray/core/datatree_mapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def _check_single_set_return_values(path_to_node: str, obj: Any) -> int | None:
160160
isinstance(r, Dataset | None) for r in obj
161161
):
162162
raise TypeError(
163-
f"the result of calling func on the node at position is not a Dataset or None "
164-
f"or a tuple of such types: {obj!r}"
163+
f"the result of calling func on the node at position '{path_to_node}' is"
164+
f" not a Dataset or None or a tuple of such types:\n{obj!r}"
165165
)
166166

167167
return len(obj)

xarray/tests/test_datatree_mapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_return_wrong_type(self, simple_datatree):
7272
with pytest.raises(
7373
TypeError,
7474
match=re.escape(
75-
"the result of calling func on the node at position is not a "
75+
"the result of calling func on the node at position '.' is not a "
7676
"Dataset or None or a tuple of such types"
7777
),
7878
):
@@ -84,7 +84,7 @@ def test_return_tuple_of_wrong_types(self, simple_datatree):
8484
with pytest.raises(
8585
TypeError,
8686
match=re.escape(
87-
"the result of calling func on the node at position is not a "
87+
"the result of calling func on the node at position '.' is not a "
8888
"Dataset or None or a tuple of such types"
8989
),
9090
):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy