MCPcopy Create free account
hub / github.com/numpy/numpy / asarray

Function asarray

numpy/ma/core.py:8204–8250  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

8202
8203
8204def 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
8253def asanyarray(a, dtype=None):

Callers 15

as_arrayFunction · 0.90
byte_boundsFunction · 0.90
__setitem__Method · 0.90
__add__Method · 0.90
__sub__Method · 0.90
__rsub__Method · 0.90
__mul__Method · 0.90
__div__Method · 0.90
__rdiv__Method · 0.90
__pow__Method · 0.90
__rpow__Method · 0.90
_makearrayFunction · 0.90

Calls

no outgoing calls

Tested by 12

assert_almost_equalFunction · 0.72
dot_generalizedFunction · 0.72
doMethod · 0.72
doMethod · 0.72
test_asarrayMethod · 0.72
test_putMethod · 0.72
original_fftshiftMethod · 0.72
original_ifftshiftMethod · 0.72