COO.any¶
-
COO.
any
(axis=None, keepdims=False, out=None)[source]¶ See if any values along array are
True
. Uses all axes by default.- Parameters
- Returns
The reduced output sparse array.
- Return type
See also
numpy.all
Equivalent numpy function.
Notes
This function internally calls
COO.sum_duplicates
to bring the array into canonical form.
Examples
You can use
COO.min
to minimize an array across any dimension.>>> x = np.array([[False, False], ... [False, True ], ... [True, False], ... [True, True ]]) >>> s = COO.from_numpy(x) >>> s2 = s.any(axis=1) >>> s2.todense() array([False, True, True, True])
You can also use the
keepdims
argument to keep the dimensions after the minimization.>>> s3 = s.any(axis=1, keepdims=True) >>> s3.shape (4, 1)
By default, this reduces the array down to one number, minimizing along all axes.
>>> s.any() True