full_like#
- class brainunit.math.full_like(a, fill_value, dtype=None, shape=None)#
Return a new quantity or array with the same shape and type as a given array, filled with
fill_value.- Parameters:
a (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – The shape and data-type ofadefine these same attributes of the returned array.fill_value (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – Value to fill the new quantity or array with. Whenais aQuantity,fill_valuemust have a compatible unit.dtype (
str|type[Any] |dtype|SupportsDType|None) – Overrides the data type of the result.shape (
int|Sequence[int]) – Overrides the shape of the result. If not given,a.shapeis used.
- Returns:
out – New array with the same shape and type as
a, filled withfill_value.- Return type:
saiunit.Quantity |
Array- Raises:
TypeError – If
fill_valuecarries a unit butais a plain array (not unitless), or vice-versa.
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> u.math.full_like(jnp.array([1.0, 2.0]), 9.0) Array([9., 9.], dtype=float32) >>> u.math.full_like(jnp.array([1.0, 2.0]) * u.meter, 9.0 * u.meter) Quantity([9. 9.], "m")