numpy.nested_iters()¶Create nditers for use in nested loops
Create a tuple ofnditer objects which iterate in nested loops overdifferent axes of the op argument. The first iterator is used in theoutermost loop, the last in the innermost loop. Advancing one will changethe subsequent iterators to point at its new element.
| Parameters: |
|
|---|---|
| Returns: |
|
See also
Examples
Basic usage. Note how y is the “flattened” version of[a[:, 0, :], a[:, 1, 0], a[:, 2, :]] since we specifiedthe first iter’s axes as [1]
>>>a=np.arange(12).reshape(2,3,2)>>>i,j=np.nested_iters(a,[[1],[0,2]],flags=["multi_index"])>>>forxini:...print(i.multi_index)...foryinj:...print('',j.multi_index,y)