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
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 | |