bundles / numpy 2.4.4 / numpy / ma / extras / masked_all_like
function
numpy.ma.extras:masked_all_like
source: /numpy/ma/extras.py :181
Signature
def masked_all_like ( arr ) Summary
Empty masked array with the properties of an existing array.
Extended Summary
Return an empty masked array of the same shape and dtype as the array arr, where all the data are masked.
Parameters
arr: ndarrayAn array describing the shape and dtype of the required MaskedArray.
Returns
a: MaskedArrayA masked array with all data masked.
Raises
: AttributeErrorIf
arrdoesn't have a shape attribute (i.e. not an ndarray)
Notes
Unlike other masked array creation functions (e.g. numpy.ma.zeros_like, numpy.ma.ones_like, numpy.ma.full_like), masked_all_like does not initialize the values of the array, and may therefore be marginally faster. However, the values stored in the newly allocated array are arbitrary. For reproducible behavior, be sure to set each element of the array before reading.
Examples
import numpy as np arr = np.zeros((2, 3), dtype=np.float32) arr np.ma.masked_all_like(arr)✓
arr.dtype np.ma.masked_all_like(arr).dtype✓
See also
- masked_all
Empty masked array with all elements masked.
Aliases
-
numpy.ma.masked_all_like