From 09257ce4dba8abf375c0d37278e842bd5dccda2d Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Fri, 1 Sep 2017 13:40:07 +0200 Subject: BUG: ensure consistent result dtype of count_nonzero The slowpath using apply_along_axis for size 1 axis did not ensure that the dtype is intp like all other paths. This caused inconsistent dtypes on windows where the default integer type is int32. Closes gh-9468 --- numpy/core/numeric.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/numeric.py') diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 6b4a93ce0..6b1c6e86e 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -445,7 +445,7 @@ def count_nonzero(a, axis=None): counts = np.apply_along_axis(multiarray.count_nonzero, axis[0], a) if axis.size == 1: - return counts + return counts.astype(np.intp, copy=False) else: # for subsequent axis numbers, that number decreases # by one in this new 'counts' array if it was larger -- cgit v1.2.1