[ Web Proxy ]
URL:
Viewing: https://numpy.org/doc/stable/reference/generated/../random/../generated/numpy.ma.asanyarray.html [Back]  [Original]

numpy.ma.asanyarray — NumPy v2.5 Manual
Back to top
Search the docs ...:

numpy.ma.asanyarray#

ma.asanyarray(a, dtype=None, order=None)[source]#

Convert the input to a masked array, conserving subclasses.

If a is a subclass of MaskedArray, its class is conserved. No copy is performed if the input is already an ndarray.

Parameters:
aarray_like

Input data, in any form that can be converted to an array.

dtypedtype, optional

By default, the data-type is inferred from the input data.

order{C, F, A, K}, optional

Memory layout. A and K depend on the order of input array a. C row-major (C-style), F column-major (Fortran-style) memory representation. A (any) means F if a is Fortran contiguous, C otherwise K (keep) preserve input order Defaults to K.

Returns:
outMaskedArray

MaskedArray interpretation of a.

See also

asarray

Similar to asanyarray, but does not conserve subclass.

Examples

Try it in your browser!
>>> import numpy as np
>>> x = np.arange(10.).reshape(2, 5)
>>> x
array([[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.MaskedArray'>

Web Proxy Viewer  |  New URL  |  Original Page