from_numpy#
- class brainunit.math.from_numpy(x, unit=Unit('1'))#
Convert a NumPy array to a JAX array, optionally attaching a unit.
- Parameters:
x (
ndarray) – The NumPy array to convert.unit (saiunit.Unit) – Unit of the returned
Quantity. WhenUNITLESS(the default) a plain JAX array is returned.
- Returns:
out – JAX array (or
Quantity) created fromx.- Return type:
Array| saiunit.Quantity
Examples
>>> import saiunit as u >>> import numpy as np >>> u.math.from_numpy(np.array([1.0, 2.0]), unit=u.meter) Quantity([1. 2.], "m")