bundles / numpy 2.4.3 / numpy / ma / extras / flatnotmasked_edges
function
numpy.ma.extras:flatnotmasked_edges
source: /numpy/ma/extras.py :1869
Signature
def flatnotmasked_edges ( a ) Summary
Find the indices of the first and last unmasked values.
Extended Summary
Expects a 1-D MaskedArray, returns None if all values are masked.
Parameters
a: array_likeInput 1-D MaskedArray
Returns
edges: ndarray or NoneThe indices of first and last non-masked value in the array. Returns None if all values are masked.
Notes
Only accepts 1-D arrays.
Examples
import numpy as np a = np.ma.arange(10) np.ma.flatnotmasked_edges(a)✓
mask = (a < 3) | (a > 8) | (a == 5) a[mask] = np.ma.masked np.array(a[~a.mask])✓
np.ma.flatnotmasked_edges(a)
✓a[:] = np.ma.masked print(np.ma.flatnotmasked_edges(a))✓
See also
Aliases
-
numpy.ma.flatnotmasked_edges