Test whether any array element along a given axis evaluates to True. Returns single boolean if `axis` is ``None`` Parameters ---------- a : array_like Input array or object that can be converted to an array. axis : None or int or tuple of ints, optional Axi
(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue)
| 2473 | |
| 2474 | @array_function_dispatch(_any_dispatcher) |
| 2475 | def any(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue): |
| 2476 | """ |
| 2477 | Test whether any array element along a given axis evaluates to True. |
| 2478 | |
| 2479 | Returns single boolean if `axis` is ``None`` |
| 2480 | |
| 2481 | Parameters |
| 2482 | ---------- |
| 2483 | a : array_like |
| 2484 | Input array or object that can be converted to an array. |
| 2485 | axis : None or int or tuple of ints, optional |
| 2486 | Axis or axes along which a logical OR reduction is performed. |
| 2487 | The default (``axis=None``) is to perform a logical OR over all |
| 2488 | the dimensions of the input array. `axis` may be negative, in |
| 2489 | which case it counts from the last to the first axis. If this |
| 2490 | is a tuple of ints, a reduction is performed on multiple |
| 2491 | axes, instead of a single axis or all the axes as before. |
| 2492 | out : ndarray, optional |
| 2493 | Alternate output array in which to place the result. It must have |
| 2494 | the same shape as the expected output and its type is preserved |
| 2495 | (e.g., if it is of type float, then it will remain so, returning |
| 2496 | 1.0 for True and 0.0 for False, regardless of the type of `a`). |
| 2497 | See :ref:`ufuncs-output-type` for more details. |
| 2498 | |
| 2499 | keepdims : bool, optional |
| 2500 | If this is set to True, the axes which are reduced are left |
| 2501 | in the result as dimensions with size one. With this option, |
| 2502 | the result will broadcast correctly against the input array. |
| 2503 | |
| 2504 | If the default value is passed, then `keepdims` will not be |
| 2505 | passed through to the `any` method of sub-classes of |
| 2506 | `ndarray`, however any non-default value will be. If the |
| 2507 | sub-class' method does not implement `keepdims` any |
| 2508 | exceptions will be raised. |
| 2509 | |
| 2510 | where : array_like of bool, optional |
| 2511 | Elements to include in checking for any `True` values. |
| 2512 | See `~numpy.ufunc.reduce` for details. |
| 2513 | |
| 2514 | .. versionadded:: 1.20.0 |
| 2515 | |
| 2516 | Returns |
| 2517 | ------- |
| 2518 | any : bool or ndarray |
| 2519 | A new boolean or `ndarray` is returned unless `out` is specified, |
| 2520 | in which case a reference to `out` is returned. |
| 2521 | |
| 2522 | See Also |
| 2523 | -------- |
| 2524 | ndarray.any : equivalent method |
| 2525 | |
| 2526 | all : Test whether all elements along a given axis evaluate to True. |
| 2527 | |
| 2528 | Notes |
| 2529 | ----- |
| 2530 | Not a Number (NaN), positive infinity and negative infinity evaluate |
| 2531 | to `True` because these are not equal to zero. |
| 2532 |