dpnp.dpnp_array.dpnp_array.flat

property

property dpnp_array.flat

A 1-D iterator over the array.

This is a dpnp.flatiter instance, which acts similarly to, but is not a subclass of, Python's built-in iterator object.

For full documentation refer to numpy.ndarray.flat.

See also

dpnp.flatiter

Flat iterator object to iterate over arrays.

dpnp.ndarray.flatten

Return a flattened copy of the array.

Examples

>>> import dpnp as np
>>> x = np.arange(1, 7).reshape(2, 3)
>>> x
array([[1, 2, 3],
       [4, 5, 6]])
>>> x.flat[3]
array(4)
>>> x.T.flat[3]
array(5)

An assignment example:

>>> x.flat[[1, 4]] = 1; x
array([[1, 1, 3],
       [4, 1, 6]])