bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / core / fix_invalid
function
numpy.ma.core:fix_invalid
source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py :763
Signature
def fix_invalid ( a , mask = False , copy = True , fill_value = None ) Summary
Return input with invalid data masked and replaced by a fill value.
Extended Summary
Invalid data means values of nan, inf, etc.
Parameters
a: array_likeInput array, a (subclass of) ndarray.
mask: sequence, optionalMask. Must be convertible to an array of booleans with the same shape as
data. True indicates a masked (i.e. invalid) data.copy: bool, optionalWhether to use a copy of
a(True) or to fixain place (False). Default is True.fill_value: scalar, optionalValue used for fixing invalid data. Default is None, in which case the
a.fill_valueis used.
Returns
b: MaskedArrayThe input array with invalid entries fixed.
Notes
A copy is performed by default.
Examples
import numpy as np x = np.ma.array([1., -1, np.nan, np.inf], mask=[1] + [0]*3) x np.ma.fix_invalid(x)
fixed = np.ma.fix_invalid(x) fixed.data x.data
Aliases
-
numpy.ma.fix_invalid