Skip to content

Commit 833a3e8

Browse files
committed
Add more informative suggestion when iterating over Tensors
1 parent a8e0adc commit 833a3e8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pytensor/tensor/var.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,9 @@ def __iter__(self):
616616
except TypeError:
617617
# This prevents accidental iteration via sum(self)
618618
raise TypeError(
619-
"TensorType does not support iteration. "
620-
"Maybe you are using builtins.sum instead of "
621-
"pytensor.tensor.math.sum? (Maybe .max?)"
619+
"TensorType does not support iteration.\n"
620+
"\tDid you pass a PyTensor variable to a function that expects a list?\n"
621+
"\tMaybe you are using builtins.sum instead of pytensor.tensor.sum?"
622622
)
623623

624624
@property

0 commit comments

Comments
 (0)