COO.density

COO.density

The ratio of nonzero to all elements in this array.

Returns:The ratio of nonzero to all elements.
Return type:float

See also

COO.size
Number of elements.
COO.nnz
Number of nonzero elements.

Examples

>>> x = np.zeros((8, 8))
>>> x[0, :] = 1
>>> s = COO.from_numpy(x)
>>> s.density
0.125