diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-07-01 11:40:29 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-07-01 11:44:57 +0100 |
commit | 1b3e6f1d8dad0b3b7d8a0891dcb2050cdc023075 (patch) | |
tree | 55bf419ca20f87564a5678c4212bc38dc472f25f /numpy/core/fromnumeric.py | |
parent | 4bbbca2dda4099f689a8fb195696062ed783e4ce (diff) | |
download | numpy-1b3e6f1d8dad0b3b7d8a0891dcb2050cdc023075.tar.gz |
BUG: np.resize discards empty shapes
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index a8c2fd2fb..4922fc3e4 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1120,18 +1120,16 @@ def resize(a, new_shape): new_shape = (new_shape,) a = ravel(a) Na = len(a) - if not Na: - return mu.zeros(new_shape, a.dtype) total_size = um.multiply.reduce(new_shape) + if Na == 0 or total_size == 0: + return mu.zeros(new_shape, a.dtype) + n_copies = int(total_size / Na) extra = total_size % Na - if total_size == 0: - return a[:0] - if extra != 0: - n_copies = n_copies+1 - extra = Na-extra + n_copies = n_copies + 1 + extra = Na - extra a = concatenate((a,)*n_copies) if extra > 0: |