dpnp.ones

dpnp.ones(shape, dtype=None, order='C')[source]

Return a new array of given shape and type, filled with ones.

For full documentation refer to numpy.ones.

Limitations

Parameter order is supported only with default value "C".

See also

dpnp.ones_like

Return an array of ones with shape and type of input.

dpnp.empty

Return a new uninitialized array.

dpnp.zeros

Return a new array setting values to zero.

dpnp.full

Return a new array of given shape filled with value.

Examples

>>> import dpnp as np
>>> [i for i in np.ones(5)]
[1.0, 1.0, 1.0, 1.0, 1.0]
>>> x = np.ones((2, 1))
>>> x.ndim, x.size, x.shape
(2, 2, (2, 1))
>>> [i for i in x]
[1.0, 1.0]