diff options
author | Hrvoje Niksic <hrvoje.niksic@avl.com> | 2011-09-19 14:31:03 +0200 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-10-01 10:15:57 -0600 |
commit | dadf7ed8b3bfb10ee3249918a9d48e4a3e3f0e7c (patch) | |
tree | 19a883c4eff3e9fa35675a10115c98f8f96b5a91 | |
parent | 10ed90c3424a7621188f5b4736c08692836cdf5a (diff) | |
download | numpy-dadf7ed8b3bfb10ee3249918a9d48e4a3e3f0e7c.tar.gz |
PyArray_FromBuffer: Allow creating arrays from empty buffers or empty slices.
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 6 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index c37ce5ad6..d7c17e8ad 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -3610,10 +3610,10 @@ PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, } } - if ((offset < 0) || (offset >= ts)) { + if ((offset < 0) || (offset > ts)) { PyErr_Format(PyExc_ValueError, - "offset must be non-negative and smaller than buffer "\ - "lenth (%" INTP_FMT ")", (npy_intp)ts); + "offset must be non-negative and no greater than buffer "\ + "length (%" INTP_FMT ")", (npy_intp)ts); Py_DECREF(buf); Py_DECREF(type); return NULL; diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index f1a7a2b65..e478de7e0 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -1350,6 +1350,9 @@ class TestFromBuffer(object): buf = x.tostring() yield self.tst_basic,buf,x.flat,{'dtype':dt} + def test_empty(self): + yield self.tst_basic, '', np.array([]), {} + class TestResize(TestCase): def test_basic(self): |