full

Contents

full#

class saiunit.math.full(shape, fill_value, dtype=None)#

Return a new quantity or array of given shape, filled with fill_value.

If fill_value is a Quantity, the result is a Quantity carrying the same unit. Otherwise a plain JAX array is returned.

Parameters:
  • shape (Union[int, Sequence[int]]) – Shape of the new array, e.g., (2, 3) or 2.

  • fill_value (Union[saiunit.Quantity, int, float]) – Fill value. When a Quantity is given its unit is preserved.

  • dtype (Union[str, type[Any], dtype, SupportsDType, None]) – The desired data-type for the array. The default, None, means the dtype is inferred from fill_value.

Returns:

out – Array (or Quantity) of fill_value with the given shape and dtype.

Return type:

Union[Array, saiunit.Quantity]

Examples

>>> import saiunit as u
>>> u.math.full((2, 3), 7.0)
Array([[7., 7., 7.],
       [7., 7., 7.]], dtype=float32)
>>> u.math.full((3,), 5.0 * u.meter)
Quantity([5. 5. 5.], "m")