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