From c4c576367acbeb9546219a8a2851bbd260d6a529 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Fri, 6 Jan 2006 05:52:23 +0000 Subject: Allow resize(a,0) --- numpy/core/oldnumeric.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'numpy/core/oldnumeric.py') 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 -- cgit v1.2.1