any
Tests whether any input array element evaluates to True along a specified axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
input array. |
required | |
axis
|
axis or axes along which to perform a logical OR reduction.
By default, a logical OR reduction is performed over the entire array.
If a tuple of integers, logical OR reductions are performed over multiple axes.
A valid |
None
|
|
keepdims
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
array
|
if a logical OR reduction was performed over the entire array, the returned array is a
zero-dimensional array containing the test result.
Otherwise, the returned array is a non-zero-dimensional array containing the test results.
The returned array is of type |
Special Cases
-
Positive infinity, negative infinity, and NaN evaluate to
True. -
If
xhas a complex floating-point data type, elements having a non-zero component (real or imaginary) evaluate toTrue. -
If
xis an empty array or the size of the axis (dimension) along which to evaluate elements is zero, the test result isFalse.
Examples:
>>> a = sparse.COO.from_numpy(np.array([[0, 1], [2, 0]]))
>>> o = sparse.any(a, axis=1)
>>> o.todense()
array([ True, True])
Source code in sparse/numba_backend/_common.py
2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 | |