dpnp.all

dpnp.all(a, /, axis=None, out=None, keepdims=False, *, where=True)[source]

Test whether all array elements along a given axis evaluate to True.

For full documentation refer to numpy.all.

Parameters:
  • a ({dpnp.ndarray, usm_ndarray}) -- Input array.

  • axis ({None, int, tuple of ints}, optional) -- Axis or axes along which a logical AND reduction is performed. The default is to perform a logical AND over all the dimensions of the input array.`axis` may be negative, in which case it counts from the last to the first axis. Default: None.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Alternative output array in which to place the result. It must have the same shape as the expected output but the type (of the returned values) will be cast if necessary. Default: None.

  • keepdims (bool, optional) -- If True, the reduced axes (dimensions) are included in the result as singleton dimensions, so that the returned array remains compatible with the input array according to Array Broadcasting rules. Otherwise, if False, the reduced axes are not included in the returned array. Default: False.

Returns:

out -- An array with a data type of bool containing the results of the logical AND reduction is returned unless out is specified. Otherwise, a reference to out is returned. The result has the same shape as a if axis is not None or a is a 0-d array.

Return type:

dpnp.ndarray

Limitations

Parameters where is only supported with its default value. Otherwise NotImplementedError exception will be raised.

See also

dpnp.ndarray.all

equivalent method

dpnp.any

Test whether any element along a given axis evaluates to True.

Notes

Not a Number (NaN), positive infinity and negative infinity evaluate to True because these are not equal to zero.

Examples

>>> import dpnp as np
>>> x = np.array([[True, False], [True, True]])
>>> np.all(x)
array(False)
>>> np.all(x, axis=0)
array([ True, False])
>>> x2 = np.array([-1, 4, 5])
>>> np.all(x2)
array(True)
>>> x3 = np.array([1.0, np.nan])
>>> np.all(x3)
array(True)
>>> o = np.array(False)
>>> z = np.all(x2, out=o)
>>> z, o
(array(True), array(True))
>>> # Check now that `z` is a reference to `o`
>>> z is o
True
>>> id(z), id(o) # identity of `z` and `o`
(139884456208480, 139884456208480) # may vary