MCPcopy Index your code
hub / github.com/numpy/numpy / masked_all

Function masked_all

numpy/ma/extras.py:120–178  ·  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

118
119
120def masked_all(shape, dtype=float):
121 """
122 Empty masked array with all elements masked.
123
124 Return an empty masked array of the given shape and dtype, where all the
125 data are masked.
126
127 Parameters
128 ----------
129 shape : int or tuple of ints
130 Shape of the required MaskedArray, e.g., ``(2, 3)`` or ``2``.
131 dtype : dtype, optional
132 Data type of the output.
133
134 Returns
135 -------
136 a : MaskedArray
137 A masked array with all data masked.
138
139 See Also
140 --------
141 masked_all_like : Empty masked array modelled on an existing array.
142
143 Notes
144 -----
145 Unlike other masked array creation functions (e.g. `numpy.ma.zeros`,
146 `numpy.ma.ones`, `numpy.ma.full`), `masked_all` does not initialize the
147 values of the array, and may therefore be marginally faster. However,
148 the values stored in the newly allocated array are arbitrary. For
149 reproducible behavior, be sure to set each element of the array before
150 reading.
151
152 Examples
153 --------
154 >>> import numpy as np
155 >>> np.ma.masked_all((3, 3))
156 masked_array(
157 data=[[--, --, --],
158 [--, --, --],
159 [--, --, --]],
160 mask=[[ True, True, True],
161 [ True, True, True],
162 [ True, True, True]],
163 fill_value=1e+20,
164 dtype=float64)
165
166 The `dtype` parameter defines the underlying data type.
167
168 >>> a = np.ma.masked_all((3, 3))
169 >>> a.dtype
170 dtype('float64')
171 >>> a = np.ma.masked_all((3, 3), dtype=np.int32)
172 >>> a.dtype
173 dtype('int32')
174
175 """
176 a = masked_array(np.empty(shape, dtype),
177 mask=np.ones(shape, make_mask_descr(dtype)))

Callers 2

test_masked_allMethod · 0.90

Calls 1

make_mask_descrFunction · 0.85

Tested by 2

test_masked_allMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…