This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / ma / extras / notmasked_contiguous

function

numpy.ma.extras:notmasked_contiguous

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

Signature

def   notmasked_contiguous ( a axis = None )

Summary

Find contiguous unmasked data in a masked array along the given axis.

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, and this is the same as flatnotmasked_contiguous.

Returns

endpoints : list

A list of slices (start and end indexes) of unmasked indexes in the array.

If the input is 2d and axis is specified, the result is a list of lists.

Notes

Only accepts 2-D arrays at most.

Examples

import numpy as np
a = np.arange(12).reshape((3, 4))
mask = np.zeros_like(a)
mask[1:, :-1] = 1; mask[0, 1] = 1; mask[-1, 0] = 0
ma = np.ma.array(a, mask=mask)
ma
np.array(ma[~ma.mask])
np.ma.notmasked_contiguous(ma)
np.ma.notmasked_contiguous(ma, axis=0)
np.ma.notmasked_contiguous(ma, axis=1)

See also

clump_masked
clump_unmasked
flatnotmasked_contiguous
flatnotmasked_edges
notmasked_edges

Aliases

  • numpy.ma.notmasked_contiguous