numpy / 1.23 / reference / generated / numpy.lib.arrayterator.flat.html

numpy.lib.Arrayterator.flat

property

propertylib.Arrayterator.flat

A 1-D flat iterator for Arrayterator objects.

This iterator returns elements of the array to be iterated over in Arrayterator one by one. It is similar to flatiter.

See also

Arrayterator
flatiter

Examples

>>> a = np.arange(3 * 4 * 5 * 6).reshape(3, 4, 5, 6)
>>> a_itor = np.lib.Arrayterator(a, 2)
>>> for subarr in a_itor.flat:
...     if not subarr:
...         print(subarr, type(subarr))
...
0 <class 'numpy.int64'>

© 2005–2022 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.23/reference/generated/numpy.lib.Arrayterator.flat.html