nlcpy.asanyarray

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

Converts the input to an array, but passes ndarray subclasses through.

Parameters
aarray_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.

dtypedtype, optional

By default, the dtype is inferred from the input data.

order{‘C’, ‘F’}, optional

Whether to use row-major (C-stype) or column-major (Fortran-style) memory representation. Defaults to ‘C’.

Returns
outndarray or an ndarray subclass

Array interpretation of a. If a is a subclass of ndarray, it is returned as-is and no copy is performed.

See also

asarray

Converts the input to an array.

Examples

Convert a list into an array:

>>> import nlcpy as vp
>>> a = [1, 2]
>>> vp.asanyarray(a)
array([1, 2])