This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / extras / masked_all_like

function

numpy.ma.extras:masked_all_like

source: build-install/usr/lib/python3.14/site-packages/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 : ndarray

An array describing the shape and dtype of the required MaskedArray.

Returns

a : MaskedArray

A masked array with all data masked.

Raises

: AttributeError

If arr doesn'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)
The dtype of the masked array matches the dtype of `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