You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / ma / core / masked_invalid

function

numpy.ma.core:masked_invalid

source: /numpy/ma/core.py :2389

Signature

def   masked_invalid ( a copy = True )

Summary

Mask an array where invalid values occur (NaNs or infs).

Extended Summary

This function is a shortcut to masked_where, with condition = ~(np.isfinite(a)). Any pre-existing mask is conserved. Only applies to arrays with a dtype where NaNs or infs make sense (i.e. floating point types), but accepts any array_like object.

Examples

import numpy as np
import numpy.ma as ma
a = np.arange(5, dtype=float)
a[2] = np.nan
a[3] = np.inf
a
ma.masked_invalid(a)

See also

masked_where

Mask where a condition is met.

Aliases

  • numpy.ma.masked_invalid