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)
| 8624 | |
| 8625 | |
| 8626 | def asarray(a, dtype=None, order=None): |
| 8627 | """ |
| 8628 | Convert the input to a masked array of the given data-type. |
| 8629 | |
| 8630 | No copy is performed if the input is already an `ndarray`. If `a` is |
| 8631 | a subclass of `MaskedArray`, a base class `MaskedArray` is returned. |
| 8632 | |
| 8633 | Parameters |
| 8634 | ---------- |
| 8635 | a : array_like |
| 8636 | Input data, in any form that can be converted to a masked array. This |
| 8637 | includes lists, lists of tuples, tuples, tuples of tuples, tuples |
| 8638 | of lists, ndarrays and masked arrays. |
| 8639 | dtype : dtype, optional |
| 8640 | By default, the data-type is inferred from the input data. |
| 8641 | order : {'C', 'F'}, optional |
| 8642 | Whether to use row-major ('C') or column-major ('FORTRAN') memory |
| 8643 | representation. Default is 'C'. |
| 8644 | |
| 8645 | Returns |
| 8646 | ------- |
| 8647 | out : MaskedArray |
| 8648 | Masked array interpretation of `a`. |
| 8649 | |
| 8650 | See Also |
| 8651 | -------- |
| 8652 | asanyarray : Similar to `asarray`, but conserves subclasses. |
| 8653 | |
| 8654 | Examples |
| 8655 | -------- |
| 8656 | >>> import numpy as np |
| 8657 | >>> x = np.arange(10.).reshape(2, 5) |
| 8658 | >>> x |
| 8659 | array([[0., 1., 2., 3., 4.], |
| 8660 | [5., 6., 7., 8., 9.]]) |
| 8661 | >>> np.ma.asarray(x) |
| 8662 | masked_array( |
| 8663 | data=[[0., 1., 2., 3., 4.], |
| 8664 | [5., 6., 7., 8., 9.]], |
| 8665 | mask=False, |
| 8666 | fill_value=1e+20) |
| 8667 | >>> type(np.ma.asarray(x)) |
| 8668 | <class 'numpy.ma.MaskedArray'> |
| 8669 | |
| 8670 | """ |
| 8671 | order = order or 'C' |
| 8672 | return masked_array(a, dtype=dtype, copy=False, keep_mask=True, |
| 8673 | subok=False, order=order) |
| 8674 | |
| 8675 | |
| 8676 | def asanyarray(a, dtype=None, order=None): |
no outgoing calls
searching dependent graphs…