full_like

Contents

full_like#

class saiunit.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 of a define 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. When a is a Quantity, fill_value must 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.shape is used.

Returns:

out – New array with the same shape and type as a, filled with fill_value.

Return type:

saiunit.Quantity | Array

Raises:

TypeError – If fill_value carries a unit but a is 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")