ones#
- class saiunit.math.ones(shape, dtype=None, unit=Unit('1'))#
Return a new quantity or array of given shape and type, filled with ones.
- Parameters:
shape (
int|Sequence[int]) – Shape of the new quantity or array, e.g.,(2, 3)or2.dtype (
str|type[Any] |dtype|SupportsDType|None) – The desired data-type for the array. Default isfloat.unit (saiunit.Unit) – Unit of the returned
Quantity. WhenUNITLESS(the default) a plain array is returned.
- Returns:
out – Array of ones with the given shape and dtype.
- Return type:
Array| saiunit.Quantity
Examples
>>> import saiunit as u >>> u.math.ones((3,)) Array([1., 1., 1.], dtype=float32) >>> u.math.ones((2, 2), unit=u.meter) Quantity([[1. 1.] [1. 1.]], "m")