Convert the input to a masked array of the given data-type. No copy is performed if the input is already an `ndarray`. If `a` is a subclass of `MaskedArray`, a base class `MaskedArray` is returned. Parameters ---------- a : array_like Input data, in any form that c
(a, dtype=None, order=None)
| 8202 | |
| 8203 | |
| 8204 | def asarray(a, dtype=None, order=None): |
| 8205 | """ |
| 8206 | Convert the input to a masked array of the given data-type. |
| 8207 | |
| 8208 | No copy is performed if the input is already an `ndarray`. If `a` is |
| 8209 | a subclass of `MaskedArray`, a base class `MaskedArray` is returned. |
| 8210 | |
| 8211 | Parameters |
| 8212 | ---------- |
| 8213 | a : array_like |
| 8214 | Input data, in any form that can be converted to a masked array. This |
| 8215 | includes lists, lists of tuples, tuples, tuples of tuples, tuples |
| 8216 | of lists, ndarrays and masked arrays. |
| 8217 | dtype : dtype, optional |
| 8218 | By default, the data-type is inferred from the input data. |
| 8219 | order : {'C', 'F'}, optional |
| 8220 | Whether to use row-major ('C') or column-major ('FORTRAN') memory |
| 8221 | representation. Default is 'C'. |
| 8222 | |
| 8223 | Returns |
| 8224 | ------- |
| 8225 | out : MaskedArray |
| 8226 | Masked array interpretation of `a`. |
| 8227 | |
| 8228 | See Also |
| 8229 | -------- |
| 8230 | asanyarray : Similar to `asarray`, but conserves subclasses. |
| 8231 | |
| 8232 | Examples |
| 8233 | -------- |
| 8234 | >>> x = np.arange(10.).reshape(2, 5) |
| 8235 | >>> x |
| 8236 | array([[0., 1., 2., 3., 4.], |
| 8237 | [5., 6., 7., 8., 9.]]) |
| 8238 | >>> np.ma.asarray(x) |
| 8239 | masked_array( |
| 8240 | data=[[0., 1., 2., 3., 4.], |
| 8241 | [5., 6., 7., 8., 9.]], |
| 8242 | mask=False, |
| 8243 | fill_value=1e+20) |
| 8244 | >>> type(np.ma.asarray(x)) |
| 8245 | <class 'numpy.ma.core.MaskedArray'> |
| 8246 | |
| 8247 | """ |
| 8248 | order = order or 'C' |
| 8249 | return masked_array(a, dtype=dtype, copy=False, keep_mask=True, |
| 8250 | subok=False, order=order) |
| 8251 | |
| 8252 | |
| 8253 | def asanyarray(a, dtype=None): |
no outgoing calls