ones
Return a SparseArray of given shape and type, filled with ones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
int or tuple of ints
|
Shape of the new array, e.g., |
required |
dtype
|
data - type
|
The desired data-type for the array, e.g., |
float
|
format
|
str
|
A format string. |
'coo'
|
compressed_axes
|
iterable
|
The axes to compress if returning a GCXS array. |
required |
Returns:
Name | Type | Description |
---|---|---|
out |
SparseArray
|
Array of ones with the given shape and dtype. |
Examples:
>>> ones(5).todense()
array([1., 1., 1., 1., 1.])
>>> ones((2, 2), dtype=int).todense()
array([[1, 1],
[1, 1]])
Source code in sparse/numba_backend/_common.py
1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 |
|