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 / extras / notmasked_edges

function

numpy.ma.extras:notmasked_edges

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

Signature

def   notmasked_edges ( a axis = None )

Summary

Find the indices of the first and last unmasked values along an axis.

Extended Summary

If all values are masked, return None. Otherwise, return a list of two tuples, corresponding to the indices of the first and last unmasked values respectively.

Parameters

a : array_like

The input array.

axis : int, optional

Axis along which to perform the operation. If None (default), applies to a flattened version of the array.

Returns

edges : ndarray or list

An array of start and end indexes if there are any masked data in the array. If there are no masked data in the array, edges is a list of the first and last index.

Examples

import numpy as np
a = np.arange(9).reshape((3, 3))
m = np.zeros_like(a)
m[1:, 1:] = 1
am = np.ma.array(a, mask=m)
np.array(am[~am.mask])
np.ma.notmasked_edges(am)

See also

clump_masked
clump_unmasked
flatnotmasked_contiguous
flatnotmasked_edges
notmasked_contiguous

Aliases

  • numpy.ma.notmasked_edges