Skip to content

Commit 4a6475e

Browse files
committed
Improve error message for inconsistent types in _multimap_array_container_impl
1 parent 4ffc113 commit 4a6475e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

arraycontext/container/traversal.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,16 @@ def rec(*args_: Any) -> Any:
244244
except NotAnArrayContainerError:
245245
return f(*args_)
246246

247-
assert all(
248-
type(args_[i]) is type(template_ary) for i in container_indices[1:]
249-
), f"expected type '{type(template_ary).__name__}'"
247+
if __debug__: # noqa: SIM102
248+
if not all(
249+
type(args_[i]) is type(template_ary)
250+
for i in container_indices[1:]
251+
):
252+
arg_summary = ", ".join(
253+
f"arg{i+1}: {type(arg)}"
254+
for i, arg in enumerate(args_))
255+
raise TypeError(
256+
f"inconsistent types in multiple traversal: {arg_summary}")
250257

251258
result = []
252259
new_args = list(args_)

0 commit comments

Comments
 (0)