Test whether all array elements along a given axis evaluate to True. Parameters ---------- a : array_like Input array or object that can be converted to an array. axis : None or int or tuple of ints, optional Axis or axes along which a logical AND reduction is p
(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue)
| 2585 | |
| 2586 | @array_function_dispatch(_all_dispatcher) |
| 2587 | def all(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue): |
| 2588 | """ |
| 2589 | Test whether all array elements along a given axis evaluate to True. |
| 2590 | |
| 2591 | Parameters |
| 2592 | ---------- |
| 2593 | a : array_like |
| 2594 | Input array or object that can be converted to an array. |
| 2595 | axis : None or int or tuple of ints, optional |
| 2596 | Axis or axes along which a logical AND reduction is performed. |
| 2597 | The default (``axis=None``) is to perform a logical AND over all |
| 2598 | the dimensions of the input array. `axis` may be negative, in |
| 2599 | which case it counts from the last to the first axis. If this |
| 2600 | is a tuple of ints, a reduction is performed on multiple |
| 2601 | axes, instead of a single axis or all the axes as before. |
| 2602 | out : ndarray, optional |
| 2603 | Alternate output array in which to place the result. |
| 2604 | It must have the same shape as the expected output and its |
| 2605 | type is preserved (e.g., if ``dtype(out)`` is float, the result |
| 2606 | will consist of 0.0's and 1.0's). See :ref:`ufuncs-output-type` |
| 2607 | for more details. |
| 2608 | |
| 2609 | keepdims : bool, optional |
| 2610 | If this is set to True, the axes which are reduced are left |
| 2611 | in the result as dimensions with size one. With this option, |
| 2612 | the result will broadcast correctly against the input array. |
| 2613 | |
| 2614 | If the default value is passed, then `keepdims` will not be |
| 2615 | passed through to the `all` method of sub-classes of |
| 2616 | `ndarray`, however any non-default value will be. If the |
| 2617 | sub-class' method does not implement `keepdims` any |
| 2618 | exceptions will be raised. |
| 2619 | |
| 2620 | where : array_like of bool, optional |
| 2621 | Elements to include in checking for all `True` values. |
| 2622 | See `~numpy.ufunc.reduce` for details. |
| 2623 | |
| 2624 | .. versionadded:: 1.20.0 |
| 2625 | |
| 2626 | Returns |
| 2627 | ------- |
| 2628 | all : ndarray, bool |
| 2629 | A new boolean or array is returned unless `out` is specified, |
| 2630 | in which case a reference to `out` is returned. |
| 2631 | |
| 2632 | See Also |
| 2633 | -------- |
| 2634 | ndarray.all : equivalent method |
| 2635 | |
| 2636 | any : Test whether any element along a given axis evaluates to True. |
| 2637 | |
| 2638 | Notes |
| 2639 | ----- |
| 2640 | Not a Number (NaN), positive infinity and negative infinity |
| 2641 | evaluate to `True` because these are not equal to zero. |
| 2642 | |
| 2643 | .. versionchanged:: 2.0 |
| 2644 | Before NumPy 2.0, ``all`` did not return booleans for object dtype |