diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2017-09-01 13:40:07 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2017-09-01 14:14:21 +0200 |
commit | 09257ce4dba8abf375c0d37278e842bd5dccda2d (patch) | |
tree | 433234492f03892efdbf65e32e841067eb2b270c /numpy/core/numeric.py | |
parent | b19fe295fd7427b03e65ed1f5212623153b792e2 (diff) | |
download | numpy-09257ce4dba8abf375c0d37278e842bd5dccda2d.tar.gz |
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
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 2 |
1 files changed, 1 insertions, 1 deletions
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 |