ndindex#

ivy.ndindex(shape)[source]#

Multidimensional index iterator.

Parameters:

shape (Tuple) – The shape of the array to iterate over.

Return type:

Generator

Returns:

ret – An iterator yielding array coordinates.

Examples

>>> a = ivy.array([[1, 2], [3, 4]])
>>> for index in ivy.ndindex(a):
>>>     print(index)
(0, 0)
(0, 1)
(1, 0)
(1, 1)