astype

Contents

astype#

class brainunit.math.astype(x, dtype)[source]#

Copy of the array, cast to a specified type.

Parameters:
  • x (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – Input array.

  • dtype (str | type[Any] | dtype | SupportsDType) – Typecode or data-type to which the array is cast.

Returns:

out – A copy of the array, cast to a specified type.

Return type:

Array | saiunit.Quantity

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> a = [1, 2, 3] * u.second
>>> u.math.astype(a, jnp.float32)