numpy.ma.masked_all_like()

numpy.ma.masked_all_like

numpy.ma.masked_all_like(arr) [source]

Empty masked array with the properties of an existing array.

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)

See also

masked_all
Empty masked array with all elements masked.

Examples

>>> import numpy.ma as ma
>>> arr = np.zeros((2, 3), dtype=np.float32)
>>> arr
array([[ 0.,  0.,  0.],
       [ 0.,  0.,  0.]], dtype=float32)
>>> ma.masked_all_like(arr)
masked_array(data =
 [[-- -- --]
 [-- -- --]],
      mask =
 [[ True  True  True]
 [ True  True  True]],
      fill_value=1e+20)

The dtype of the masked array matches the dtype of arr.

>>> arr.dtype
dtype('float32')
>>> ma.masked_all_like(arr).dtype
dtype('float32')

© 2008–2016 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.11.0/reference/generated/numpy.ma.masked_all_like.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部