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 (Union[saiunit.Quantity, Array, ndarray, number, bool]) – The shape and data-type of a define these same attributes of the returned array.

  • fill_value (Union[saiunit.Quantity, Array, ndarray, number, bool]) – Value to fill the new quantity or array with. When a is a Quantity, fill_value must have a compatible unit.

  • dtype (Union[str, type[Any], dtype, SupportsDType, None]) – Overrides the data type of the result.

  • shape (Union[int, Sequence[int], None]) – 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:

Union[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")