MCPcopy Index your code
hub / github.com/numpy/numpy / any

Function any

numpy/_core/fromnumeric.py:2475–2578  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2473
2474@array_function_dispatch(_any_dispatcher)
2475def 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

Callers 15

covFunction · 0.90
_fix_real_lt_zeroFunction · 0.90
_fix_int_lt_zeroFunction · 0.90
_fix_real_abs_gt_1Function · 0.90
process_filesFunction · 0.85
iter_source_filesFunction · 0.85
scan_fileFunction · 0.85
fillFormatMethod · 0.85
_concatenate_shapesFunction · 0.85
_struct_dict_strFunction · 0.85

Calls 1

_wrapreduction_any_allFunction · 0.85

Tested by 10

cpu_haveMethod · 0.68
test_denormal_numbersMethod · 0.68
test_diophantine_fuzzFunction · 0.68
checkFunction · 0.68
test_ufunc_noncontiguousFunction · 0.68
test_reduceMethod · 0.68
__array_ufunc__Method · 0.68
test_ddof_too_bigMethod · 0.68