loupe.asarray#
- loupe.asarray(a, dtype=None, mask=None, requires_grad=False)[source]#
Convert the input to an array.
- Parameters:
a (array_like) – Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
dtype (data-type, optional) – The desired data-type for the array. If not given, the type will be inferred from the supplied data object.
mask (array_like, optional) – Mask applied to the array where a True value indicates that the corresponding element of the array is invalid. Mask must have the same shape as the array and contain entries that are castable to bool. If None (default), the array is not masked.
requires_grad (bool, optional) – It True, gradients will be computed for this array. Default is False.
- Returns:
out – Input data packaged as an
array
. If input is already anarray
orFunction
, the original input is returned.- Return type:
Examples
Convert a list into an array:
>>> a = [1,2,3] >>> loupe.asarray(a) array([ 1.,2., 3.])
Existing arrays are not copied:
>>> a = loupe.array([1,2,3]) >>> loupe.asarray(a) is a True