numpy.any

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

Test whether any elements of an array evaluate to True along an axis.

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

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

See also

ndarray.any
equivalent method

Notes

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

Examples

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

Previous topic

numpy.all

Next topic

numpy.isfinite

This Page

Quick search