Skip to content

Commit fe9011d

Browse files
ev-brhonno
andauthored
MAINT: better error message for wrong axis arguments
Co-authored-by: Matthew Barber <[email protected]>
1 parent 16c5aed commit fe9011d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

torch_np/_detail/_reductions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def wrapped(tensor, axis, *args, **kwds):
2525

2626
if axis is not None:
2727
if not isinstance(axis, (list, tuple)):
28+
if not isinstance(axis, typing.SupportsIndex):
29+
raise TypeError(f"{type(axis)=}, but should be a list/tuple or support operator.index()")
2830
axis = (axis,)
2931
axis = _util.normalize_axis_tuple(axis, tensor.ndim)
3032

0 commit comments

Comments
 (0)