(arr, axis, keepdims=False, where=True)
| 71 | return umr_all(a, axis, dtype, out, keepdims, where=where) |
| 72 | |
| 73 | def _count_reduce_items(arr, axis, keepdims=False, where=True): |
| 74 | # fast-path for the default case |
| 75 | if where is True: |
| 76 | # no boolean mask given, calculate items according to axis |
| 77 | if axis is None: |
| 78 | axis = tuple(range(arr.ndim)) |
| 79 | elif not isinstance(axis, tuple): |
| 80 | axis = (axis,) |
| 81 | items = 1 |
| 82 | for ax in axis: |
| 83 | items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)] |
| 84 | items = nt.intp(items) |
| 85 | else: |
| 86 | # TODO: Optimize case when `where` is broadcast along a non-reduction |
| 87 | # axis and full sum is more excessive than needed. |
| 88 | |
| 89 | # guarded to protect circular imports |
| 90 | from numpy.lib._stride_tricks_impl import broadcast_to |
| 91 | # count True values in (potentially broadcasted) boolean mask |
| 92 | items = umr_sum(broadcast_to(where, arr.shape), axis, nt.intp, None, |
| 93 | keepdims) |
| 94 | return items |
| 95 | |
| 96 | def _clip(a, min=None, max=None, out=None, **kwargs): |
| 97 | if a.dtype.kind in "iu": |
no test coverage detected
searching dependent graphs…