zeros_like

Contents

zeros_like#

class saiunit.math.zeros_like(a, dtype=None, shape=None, unit=Unit('1'))#

Return a quantity or array of zeros with the same shape and type as a given array.

Parameters:
  • a (Union[saiunit.Quantity, Array, ndarray, number, bool]) – The shape and data-type of a define these same attributes of the returned array.

  • 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.

  • unit (saiunit.Unit) – Unit of the returned Quantity.

Returns:

out – Array of zeros with the same shape and type as a.

Return type:

Union[saiunit.Quantity, Array]

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> u.math.zeros_like(jnp.array([1.0, 2.0, 3.0]))
Array([0., 0., 0.], dtype=float32)
>>> u.math.zeros_like(jnp.array([1.0, 2.0]) * u.meter)
Quantity([0. 0.], "m")