numpy.asanyarray(a, dtype=None, order=None)[source]
Convert the input to an ndarray, but pass ndarray subclasses through.
Parameters: |
a : array_like Input data, in any form that can be converted to an array. This includes scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays. dtype : data-type, optional By default, the data-type is inferred from the input data. order : {‘C’, ‘F’}, optional Whether to use row-major (C-style) or column-major (Fortran-style) memory representation. Defaults to ‘C’. |
---|---|
Returns: |
out : ndarray or an ndarray subclass Array interpretation of |
See also
asarray
ascontiguousarray
asfarray
asfortranarray
asarray_chkfinite
fromiter
fromfunction
Convert a list into an array:
>>> a = [1, 2] >>> np.asanyarray(a) array([1, 2])
Instances of ndarray
subclasses are passed through as-is:
>>> a = np.matrix([1, 2]) >>> np.asanyarray(a) is a True
© 2008–2016 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.asanyarray.html