Flat iterator object to iterate over arrays.
flatiter iterator is returned by
x.flat for any array
x. It allows iterating over the array as if it were a 1-D array, either in a for-loop or by calling its
Iteration is done in row-major, C-style order (the last index varying the fastest). The iterator can also be indexed using basic slicing or advanced indexing.
>>> x = np.arange(6).reshape(2, 3) >>> fl = x.flat >>> type(fl) <class 'numpy.flatiter'> >>> for item in fl: ... print(item) ... 0 1 2 3 4 5
>>> fl[2:4] array([2, 3])
||Get a copy of the iterator as a 1-D array.|
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.