any¶
- any(x: array, /, *, axis: int | Tuple[int, ...] | None = None, keepdims: bool = False) array¶
Tests whether any input array element evaluates to
Truealong a specified axis.- Parameters:
x (array) – input array.
axis (Optional[Union[int, Tuple[int, ...]]]) – axis or axes along which to perform a logical OR reduction. By default, a logical OR reduction must be performed over the entire array. If a tuple of integers, logical OR reductions must be performed over multiple axes. A valid
axismust be an integer on the interval[-N, N), whereNis the number of axes inx. If anaxisis specified as a negative integer, the function must determine the axis along which to perform a reduction by counting backward from the last dimension (where-1refers to the last axis). If provided an invalidaxis, the function must raise an exception. Default:None.keepdims (bool) – If
True, the reduced axes must be included in the result as singleton dimensions, and, accordingly, the result must be broadcast-compatible with the input array (see Broadcasting). Otherwise, ifFalse, the reduced axes must not be included in the result. Default:False.
- Returns:
out (array) – if a logical OR reduction was performed over the entire array, the returned array must be a zero-dimensional array containing the test result. Otherwise, the returned array must be a non-zero-dimensional array containing the test results. The returned array must have a data type of
bool.
Notes
Positive infinity, negative infinity, and NaN must evaluate to
True.If
xhas a complex floating-point data type, elements having a non-zero component (real or imaginary) must evaluate toTrue.If
xis an empty array or the size of the axis along which to evaluate elements is zero, the test result must beFalse.
Changed in version 2022.12: Added complex data type support.