brainpy.math.asarray#

brainpy.math.asarray(a: Any, dtype: Optional[Union[Any, str, numpy.dtype, jax._src.typing.SupportsDType]] = None, order: Optional[str] = None) jax._src.basearray.Array[source]#

Convert the input to an array.

LAX-backend implementation of numpy.asarray().

This function will create arrays on JAX’s default device. For control of the device placement of data, see jax.device_put(). More information is available in the JAX FAQ at faq-data-placement (full FAQ at https://jax.readthedocs.io/en/latest/faq.html).

Original docstring below.

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) – By default, the data-type is inferred from the input data.

  • order ({'C', 'F', 'A', 'K'}, optional) – Memory layout. ‘A’ and ‘K’ depend on the order of input array a. ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’ otherwise ‘K’ (keep) preserve input order Defaults to ‘C’.

Returns

out – Array interpretation of a. No copy is performed if the input is already an ndarray with matching dtype and order. If a is a subclass of ndarray, a base class ndarray is returned.

Return type

ndarray