cf.Data.ndindex¶

Data.
ndindex
()[source]¶ Return an iterator over the Ndimensional indices of the data array.
At each iteration a tuple of indices is returned, the last dimension is iterated over first.
 Returns
itertools.product
An iterator over tuples of indices of the data array.
Examples
>>> d = cf.Data(np.arange(6).reshape(2, 3)) >>> print(d.array) [[0 1 2] [3 4 5]] >>> for i in d.ndindex(): ... print(i, d[i]) ... (0, 0) [[0]] (0, 1) [[1]] (0, 2) [[2]] (1, 0) [[3]] (1, 1) [[4]] (1, 2) [[5]]
>>> d = cf.Data(9) >>> for i in d.ndindex(): ... print(i, d[i]) ... () 9