This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / core / MaskedIterator

class

numpy.ma.core:MaskedIterator

source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py :2649

Signature

class   MaskedIterator ( ma )

Members

Summary

Flat iterator object to iterate over masked arrays.

Extended Summary

A MaskedIterator iterator is returned by x.flat for any masked 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 next method.

Iteration is done in C-contiguous style, with the last index varying the fastest. The iterator can also be indexed using basic slicing or advanced indexing.

Notes

MaskedIterator is not exported by the ma module. Instead of instantiating a MaskedIterator directly, use MaskedArray.flat.

Examples

import numpy as np
x = np.ma.array(arange(6).reshape(2, 3))
fl = x.flat
type(fl)
for item in fl:
    print(item)
Extracting more than a single element b indexing the `MaskedIterator` returns a masked array:
fl[2:4]

See also

MaskedArray.flat

Return a flat iterator over an array.

MaskedArray.flatten

Returns a flattened copy of an array.

Aliases

  • numpy.ma.core.MaskedIterator