diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-06 05:52:23 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-06 05:52:23 +0000 |
commit | c4c576367acbeb9546219a8a2851bbd260d6a529 (patch) | |
tree | c0accc82881675b055b73629f4aa8fd4f705a809 /numpy/core/oldnumeric.py | |
parent | 4ac586f3122cefbbced1a890185645709d219a73 (diff) | |
download | numpy-c4c576367acbeb9546219a8a2851bbd260d6a529.tar.gz |
Allow resize(a,0)
Diffstat (limited to 'numpy/core/oldnumeric.py')
-rw-r--r-- | numpy/core/oldnumeric.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/numpy/core/oldnumeric.py b/numpy/core/oldnumeric.py index 3773af6cc..e7c45ccc1 100644 --- a/numpy/core/oldnumeric.py +++ b/numpy/core/oldnumeric.py @@ -248,6 +248,8 @@ def resize(a, new_shape): beyond current definition of a. """ + if isinstance(new_shape, (int, nt.integer)): + new_shape = (new_shape,) a = ravel(a) Na = len(a) if not Na: return mu.zeros(new_shape, a.dtypechar) @@ -255,6 +257,9 @@ def resize(a, new_shape): 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 |