diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-07-29 20:04:28 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-07-29 20:21:57 +0200 |
commit | 778af02eb7c1668e751f435cd2a4952a362a0433 (patch) | |
tree | a195ec7efd70f97e81276c49fdeffdfc8a1ba666 /numpy/core/numeric.py | |
parent | c09d0ce0e11c94a83413c1bc6c9b2f5f40008a5a (diff) | |
download | numpy-778af02eb7c1668e751f435cd2a4952a362a0433.tar.gz |
BUG: fix string type inconsistency between zeros and zeros_like
np.zeros for strings returns empty strings while np.zeros_like of a
string array creates strings containing an string 0.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index a85e8514c..57784a51f 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -131,7 +131,9 @@ def zeros_like(a, dtype=None, order='K', subok=True): """ res = empty_like(a, dtype=dtype, order=order, subok=subok) - multiarray.copyto(res, 0, casting='unsafe') + # needed instead of a 0 to get same result as zeros for for string dtypes + z = zeros(1, dtype=res.dtype) + multiarray.copyto(res, z, casting='unsafe') return res def ones(shape, dtype=None, order='C'): |