nums.numpy.ones
-
nums.numpy.
ones
(shape, dtype=<class 'float'>)[source] Return a new array of given shape and type, filled with ones.
This docstring was copied from numpy.ones.
Some inconsistencies with the NumS version may exist.
- Parameters
shape (int or sequence of ints) – Shape of the new array, e.g.,
(2, 3)
or2
.dtype (data-type, optional) – The desired data-type for the array, e.g., int. Default is float.
- Returns
out – Array of ones with the given shape and dtype.
- Return type
See also
Examples
The doctests shown below are copied from NumPy. They won’t show the correct result until you operate
get()
.>>> nps.ones(5).get() array([1., 1., 1., 1., 1.])
>>> nps.ones((5,), dtype=int).get() array([1, 1, 1, 1, 1])
>>> nps.ones((2, 1)).get() array([[1.], [1.]])
>>> s = (2,2) >>> nps.ones(s).get() array([[1., 1.], [1., 1.]])