ones¶
-
sparse.
ones
(shape, dtype=<class 'float'>)[source]¶ Return a COO array of given shape and type, filled with ones.
Parameters: - shape (int or tuple 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., numpy.int8. Default is numpy.float64.
Returns: out – Array of ones with the given shape and dtype.
Return type: Examples
>>> ones(5).todense() # doctest: +SKIP array([1., 1., 1., 1., 1.])
>>> ones((2, 2), dtype=int).todense() # doctest: +NORMALIZE_WHITESPACE array([[1, 1], [1, 1]])
- shape (int or tuple of ints) – Shape of the new array, e.g.,