MCPcopy Create free account
hub / github.com/numpy/numpy / masked_all

Function masked_all

numpy/ma/extras.py:103–152  ·  view source on GitHub ↗

Empty masked array with all elements masked. Return an empty masked array of the given shape and dtype, where all the data are masked. Parameters ---------- shape : int or tuple of ints Shape of the required MaskedArray, e.g., ``(2, 3)`` or ``2``. dtype : dtype

(shape, dtype=float)

Source from the content-addressed store, hash-verified

101
102
103def masked_all(shape, dtype=float):
104 """
105 Empty masked array with all elements masked.
106
107 Return an empty masked array of the given shape and dtype, where all the
108 data are masked.
109
110 Parameters
111 ----------
112 shape : int or tuple of ints
113 Shape of the required MaskedArray, e.g., ``(2, 3)`` or ``2``.
114 dtype : dtype, optional
115 Data type of the output.
116
117 Returns
118 -------
119 a : MaskedArray
120 A masked array with all data masked.
121
122 See Also
123 --------
124 masked_all_like : Empty masked array modelled on an existing array.
125
126 Examples
127 --------
128 >>> import numpy.ma as ma
129 >>> ma.masked_all((3, 3))
130 masked_array(
131 data=[[--, --, --],
132 [--, --, --],
133 [--, --, --]],
134 mask=[[ True, True, True],
135 [ True, True, True],
136 [ True, True, True]],
137 fill_value=1e+20,
138 dtype=float64)
139
140 The `dtype` parameter defines the underlying data type.
141
142 >>> a = ma.masked_all((3, 3))
143 >>> a.dtype
144 dtype('float64')
145 >>> a = ma.masked_all((3, 3), dtype=np.int32)
146 >>> a.dtype
147 dtype('int32')
148
149 """
150 a = masked_array(np.empty(shape, dtype),
151 mask=np.ones(shape, make_mask_descr(dtype)))
152 return a
153
154
155def masked_all_like(arr):

Callers 2

test_masked_allMethod · 0.90

Calls 1

make_mask_descrFunction · 0.85

Tested by 2

test_masked_allMethod · 0.72