diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py index a239e2c87eb7..eda00147d053 100644 --- a/numpy/core/_methods.py +++ b/numpy/core/_methods.py @@ -71,9 +71,10 @@ def _count_reduce_items(arr, axis, keepdims=False, where=True): axis = tuple(range(arr.ndim)) elif not isinstance(axis, tuple): axis = (axis,) - items = nt.intp(1) + items = 1 for ax in axis: items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)] + items = nt.intp(items) else: # TODO: Optimize case when `where` is broadcast along a non-reduction # axis and full sum is more excessive than needed.