From 36dd1b36474d9a6e46c86f708b9a62efa0a7309a Mon Sep 17 00:00:00 2001 From: sgasse Date: Wed, 25 Mar 2020 22:01:47 +0100 Subject: BUG: Fix IndexError for illegal axis in np.mean Catch IndexError in _count_reduce_items used in np.mean and np.var for illegal axis and reraise as AxisError, see gh-15817. --- numpy/core/_methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/_methods.py') diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py index 6785683a3..86ddf4d17 100644 --- a/numpy/core/_methods.py +++ b/numpy/core/_methods.py @@ -63,7 +63,7 @@ def _count_reduce_items(arr, axis): axis = (axis,) items = 1 for ax in axis: - items *= arr.shape[ax] + items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)] return items # Numpy 1.17.0, 2019-02-24 -- cgit v1.2.1