COO.all

COO.all(axis=None, keepdims=False, out=None)[source]

See if all values in an array are True. Uses all axes by default.

Parameters
  • axis (Union[int, Iterable[int]], optional) – The axes along which to minimize. Uses all axes by default.

  • keepdims (bool, optional) – Whether or not to keep the dimensions of the original array.

Returns

The reduced output sparse array.

Return type

COO

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.all(axis=1)
>>> s2.todense()  
array([False, False, False,  True])

You can also use the keepdims argument to keep the dimensions after the minimization.

>>> s3 = s.all(axis=1, keepdims=True)
>>> s3.shape
(4, 1)

By default, this reduces the array down to one boolean, minimizing along all axes.

>>> s.all()
False