numpy.ma.fix_invalid
- 
numpy.ma.fix_invalid(a, mask=False, copy=True, fill_value=None)[source] - 
Return input with invalid data masked and replaced by a fill value.
Invalid data means values of
nan,inf, etc.- Parameters
 - 
- 
aarray_like - 
Input array, a (subclass of) ndarray.
 - 
masksequence, optional - 
Mask. Must be convertible to an array of booleans with the same shape as
data. True indicates a masked (i.e. invalid) data. - 
copybool, optional - 
Whether to use a copy of
a(True) or to fixain place (False). Default is True. - 
fill_valuescalar, optional - 
Value used for fixing invalid data. Default is None, in which case the
a.fill_valueis used. 
 - 
 - Returns
 - 
- 
bMaskedArray - 
The input array with invalid entries fixed.
 
 - 
 
Notes
A copy is performed by default.
Examples
>>> x = np.ma.array([1., -1, np.nan, np.inf], mask=[1] + [0]*3) >>> x masked_array(data=[--, -1.0, nan, inf], mask=[ True, False, False, False], fill_value=1e+20) >>> np.ma.fix_invalid(x) masked_array(data=[--, -1.0, --, --], mask=[ True, False, True, True], fill_value=1e+20)>>> fixed = np.ma.fix_invalid(x) >>> fixed.data array([ 1.e+00, -1.e+00, 1.e+20, 1.e+20]) >>> x.data array([ 1., -1., nan, inf])
 
    © 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
    https://numpy.org/doc/1.18/reference/generated/numpy.ma.fix_invalid.html