asanyarray#
- named_arrays.asanyarray(a: ArrayT, dtype: None | type | dtype | str = None, order: None | str = None, *, like: None = None) ArrayT#
- named_arrays.asanyarray(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.ndarraysubclasses as the underlying data.This function does not convert an instance of
named_arrays.AbstractArrayto an instance of anumpy.ndarraysubclass like you might expect from the documentation ofnumpy.asanyarray(). Instead, it recursively inspects the input, converting instances ofnamed_arrays.AbstractImplicitArrayto named_arrays.AbstractExplicitArray, and callingnumpy.asanyarray()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.asanyarray()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.ndarraysubclasses.- Return type:
out
Examples
Standardize an instance of
astropy.units.Quantityimport astropy.units as u import named_arrays as na na.asanyarray(2 * u.mm)
ScalarArray( ndarray=2. mm, axes=(), )See also
numpy.asanyarray()Equivalent Numpy function
named_arrays.asarray()Similar to this function but converts instances of
numpy.ndarraysubclasses back to instances ofnumpy.ndarray.