diff options
-rw-r--r-- | numpy/core/src/arrayobject.c | 11 | ||||
-rw-r--r-- | numpy/dual.py | 23 |
2 files changed, 23 insertions, 11 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index ec6d93892..32fd6eb4a 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -3538,7 +3538,7 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, e.g. shape=(0,) -- otherwise buffer exposure (a.data) doesn't work as it should. */ - if (sd==0) sd = sizeof(intp); + if (sd==0) sd = descr->elsize; if ((data = PyDataMem_NEW(sd))==NULL) { PyErr_NoMemory(); @@ -3642,8 +3642,8 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape) return NULL; } - sd = (newsize == 0 ? sizeof(intp) : \ - newsize * self->descr->elsize); + if (newsize == 0) sd = self->descr->elsize; + else sd = newsize * self->descr->elsize; /* Reallocate space if needed */ new_data = PyDataMem_RENEW(self->data, sd); if (new_data == NULL) { @@ -6215,6 +6215,11 @@ PyArray_IterNew(PyObject *obj) Py_INCREF(ao); it->ao = ao; it->size = PyArray_SIZE(ao); + if (it->size == 0) { + PyErr_SetString(PyExc_ValueError, + "Cannot iterate over a size-0 array"); + return NULL; + } it->nd_m1 = nd - 1; it->factors[nd-1] = 1; for (i=0; i < nd; i++) { diff --git a/numpy/dual.py b/numpy/dual.py index 32baa020e..2a5e0e101 100644 --- a/numpy/dual.py +++ b/numpy/dual.py @@ -7,19 +7,26 @@ __all__ = ['fft','ifft','fftn','ifftn','fft2','ifft2', 'inv','svd','solve','det','eig','eigvals','lstsq', 'pinv','cholesky','i0'] -try: - import scipy.linalg as linpkg -except ImportError: - import numpy.linalg as linpkg +# First check to see that scipy is "new" scipy +# Perhaps we could check to see if the functions actually work in +# the scipy that will be imported. + +have_scipy = 0 try: - import scipy.fftpack as fftpkg + import scipy + if scipy.__version__ >= '0.4.4': + have_scipy = 1 except ImportError: - import numpy.dft as fftpkg + pass -try: +if have_scipy: + import scipy.linalg as linpkg + import scipy.fftpack as fftpkg from scipy.special import i0 -except ImportError: +else: + import numpy.linalg as linpkg + import numpy.dft as fftpkg from numpy.lib import i0 fft = fftpkg.fft |