nums.numpy.ones
nums.numpy.ones#
- nums.numpy.ones(shape, dtype=<class 'float'>)#
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.
- shapeint or sequence of ints
Shape of the new array, e.g.,
(2, 3)or2.- dtypedata-type, optional
The desired data-type for the array, e.g., int. Default is float.
- outBlockArray
Array of ones with the given shape and dtype.
ones_like : Return an array of ones with shape and type of input. empty : Return a new uninitialized array. zeros : Return a new array setting values to zero. full : Return a new array of given shape filled with value.
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.]])