asarray#
- named_arrays.asarray(a: ArrayT, dtype: None | type | dtype | str = None, order: None | str = None, *, like: None = None) ArrayT#
- named_arrays.asarray(a: ArrayT, dtype: None | type | dtype | str = None, order: None | str = None, *, like: LikeT = None) LikeT
Converts the input to use only instances of
numpy.ndarrayas the underlying data.This function does not convert an instance of
named_arrays.AbstractArrayto an instance ofnumpy.ndarraylike you might expect from the documentation ofnumpy.asarray(). Instead, it recursively inspects the input, converting instances ofnamed_arrays.AbstractImplicitArrayto named_arrays.AbstractExplicitArray, and callingnumpy.asarray()on the underlying data.- Parameters:
a (ArrayT) – Input array to be converted
dtype (None | type | dtype | str) – Data type of output, usually inferred from the input.
order (None | str) – Memory layout. See the documentation of
numpy.asarray()for more information.like (None | LikeT) – Optional reference object. If provided, the result will be defined by this object.
- Returns:
Standardized interpretation of
a, with all the underlying data expressed as instances ofnumpy.ndarray.- Return type:
out
Examples
Standardize a
floatimport named_arrays as na na.asarray(2)
ScalarArray( ndarray=2, axes=(), )Standardize a
named_arrays.ScalarArrayoffloatna.asarray(na.ScalarArray(2))
ScalarArray( ndarray=2, axes=(), )Standardize a
named_arrays.Cartesian2dVectorArrayoffloatna.asarray(na.Cartesian2dVectorArray(2, 3))
Cartesian2dVectorArray( x=ScalarArray( ndarray=2, axes=(), ), y=ScalarArray( ndarray=3, axes=(), ), )See also
numpy.asarray()Equivalent Numpy function
named_arrays.asanyarray()Similar to this function, but allows numpy.ndarray subclasses to pass through.