MCPcopy Create free account
hub / github.com/numpy/numpy / any

Function any

numpy/core/fromnumeric.py:2323–2413  ·  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

2321
2322@array_function_dispatch(_any_dispatcher)
2323def 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 -----

Callers 15

covFunction · 0.90
_fix_real_lt_zeroFunction · 0.90
_fix_int_lt_zeroFunction · 0.90
_fix_real_abs_gt_1Function · 0.90
fillFormatMethod · 0.70
_do_initMethod · 0.70
_concatenate_shapesFunction · 0.70
_struct_dict_strFunction · 0.70
sometrueFunction · 0.70
check_outputMethod · 0.50
_run_doctestsFunction · 0.50
check_doctests_testfileFunction · 0.50

Calls 1

_wrapreductionFunction · 0.85

Tested by 8

test_denormal_numbersMethod · 0.40
test_diophantine_fuzzFunction · 0.40
checkFunction · 0.40
test_ufunc_noncontiguousFunction · 0.40
test_reduceMethod · 0.40
__array_ufunc__Method · 0.40
test_in1d_mixed_dtypeMethod · 0.40
test_ddof_too_bigMethod · 0.40