numpy.all

numpy.all(a, axis=None, out=None)

Returns True if all elements evaluate to True.

Parameters:

a : array_like

Input array.

axis : int, optional

Axis over which to perform the operation. If None, use a flattened input array and return a bool.

out : ndarray, optional

Array into which the result is placed. Its type is preserved and it must be of the right shape to hold the output.

Returns:

out : ndarray, bool

A logical AND is performed along axis, and the result placed in out. If out was not specified, a new output array is created.

See also

ndarray.all
equivalent method

Notes

Since NaN is not equal to zero, NaN evaluates to True.

Examples

>>> np.all([[True,False],[True,True]])
False
>>> np.all([[True,False],[True,True]], axis=0)
array([ True, False], dtype=bool)
>>> np.all([-1, 4, 5])
True
>>> np.all([1.0, np.nan])
True

Previous topic

Logic functions

Next topic

numpy.any

This Page

Quick search