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)
| 2321 | |
| 2322 | @array_function_dispatch(_any_dispatcher) |
| 2323 | def any(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue): |
| 2324 | """ |
| 2325 | Test whether any array element along a given axis evaluates to True. |
| 2326 | |
| 2327 | Returns single boolean if `axis` is ``None`` |
| 2328 | |
| 2329 | Parameters |
| 2330 | ---------- |
| 2331 | a : array_like |
| 2332 | Input array or object that can be converted to an array. |
| 2333 | axis : None or int or tuple of ints, optional |
| 2334 | Axis or axes along which a logical OR reduction is performed. |
| 2335 | The default (``axis=None``) is to perform a logical OR over all |
| 2336 | the dimensions of the input array. `axis` may be negative, in |
| 2337 | which case it counts from the last to the first axis. |
| 2338 | |
| 2339 | .. versionadded:: 1.7.0 |
| 2340 | |
| 2341 | If this is a tuple of ints, a reduction is performed on multiple |
| 2342 | axes, instead of a single axis or all the axes as before. |
| 2343 | out : ndarray, optional |
| 2344 | Alternate output array in which to place the result. It must have |
| 2345 | the same shape as the expected output and its type is preserved |
| 2346 | (e.g., if it is of type float, then it will remain so, returning |
| 2347 | 1.0 for True and 0.0 for False, regardless of the type of `a`). |
| 2348 | See :ref:`ufuncs-output-type` for more details. |
| 2349 | |
| 2350 | keepdims : bool, optional |
| 2351 | If this is set to True, the axes which are reduced are left |
| 2352 | in the result as dimensions with size one. With this option, |
| 2353 | the result will broadcast correctly against the input array. |
| 2354 | |
| 2355 | If the default value is passed, then `keepdims` will not be |
| 2356 | passed through to the `any` method of sub-classes of |
| 2357 | `ndarray`, however any non-default value will be. If the |
| 2358 | sub-class' method does not implement `keepdims` any |
| 2359 | exceptions will be raised. |
| 2360 | |
| 2361 | where : array_like of bool, optional |
| 2362 | Elements to include in checking for any `True` values. |
| 2363 | See `~numpy.ufunc.reduce` for details. |
| 2364 | |
| 2365 | .. versionadded:: 1.20.0 |
| 2366 | |
| 2367 | Returns |
| 2368 | ------- |
| 2369 | any : bool or ndarray |
| 2370 | A new boolean or `ndarray` is returned unless `out` is specified, |
| 2371 | in which case a reference to `out` is returned. |
| 2372 | |
| 2373 | See Also |
| 2374 | -------- |
| 2375 | ndarray.any : equivalent method |
| 2376 | |
| 2377 | all : Test whether all elements along a given axis evaluate to True. |
| 2378 | |
| 2379 | Notes |
| 2380 | ----- |