numpy.ma.asanyarray(a,dtype=None)[source]¶Convert the input to a masked array, conserving subclasses.
Ifa is a subclass ofMaskedArray, its class is conserved.No copy is performed if the input is already anndarray.
| Parameters: |
|
|---|---|
| Returns: |
|
See also
asarrayasanyarray, but does not conserve subclass.Examples
>>>x=np.arange(10.).reshape(2,5)>>>xarray([[ 0., 1., 2., 3., 4.], [ 5., 6., 7., 8., 9.]])>>>np.ma.asanyarray(x)masked_array(data = [[ 0. 1. 2. 3. 4.] [ 5. 6. 7. 8. 9.]], mask = False, fill_value = 1e+20)>>>type(np.ma.asanyarray(x))<class 'numpy.ma.core.MaskedArray'>