Skip to content

Commit d4aea9f

Browse files
committed
Allow size with each element castable to Py_ssize_t
1 parent 2dc3f6d commit d4aea9f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,14 @@ cpdef inline tuple _object_to_tuple(object obj):
391391
return ()
392392

393393
if cpython.PySequence_Check(obj):
394-
return tuple(obj)
394+
nd = len(obj)
395+
shape = []
396+
397+
for i in range(0, nd):
398+
# Assumes each item is castable to Py_ssize_t,
399+
# otherwise TypeError will be raised
400+
shape.append(<Py_ssize_t> obj[i])
401+
return tuple(shape)
395402

396403
if dpnp.isscalar(obj):
397404
return (obj, )

0 commit comments

Comments
 (0)