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/src/arrayobject.c | |
| parent | 4ac586f3122cefbbced1a890185645709d219a73 (diff) | |
| download | numpy-c4c576367acbeb9546219a8a2851bbd260d6a529.tar.gz | |
Allow resize(a,0)
Diffstat (limited to 'numpy/core/src/arrayobject.c')
| -rw-r--r-- | numpy/core/src/arrayobject.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 65c73bbd4..11ebc4d04 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -3622,15 +3622,7 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape) return NULL; } - newsize = PyArray_MultiplyList(new_dimensions, new_nd); - - if (newsize == 0) { - PyErr_SetString(PyExc_ValueError, - "newsize is zero; cannot delete an array "\ - "in this way"); - return NULL; - } oldsize = PyArray_SIZE(self); if (oldsize != newsize) { @@ -3651,10 +3643,11 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape) "resize function"); return NULL; } - + + sd = (newsize == 0 ? sizeof(intp) : \ + newsize * self->descr->elsize); /* Reallocate space if needed */ - new_data = PyDataMem_RENEW(self->data, - newsize*(self->descr->elsize)); + new_data = PyDataMem_RENEW(self->data, sd); if (new_data == NULL) { PyErr_SetString(PyExc_MemoryError, "cannot allocate memory for array"); |
