diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-12-02 05:43:15 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-12-02 05:43:15 +0000 |
commit | 91e3f408b21bde54cac134b7140d76c7ae147a20 (patch) | |
tree | 87d480b1411ba22d0347df7fb8b98b8ded3475ed | |
parent | 42655ec7108f9a1e8e684328c0058c837eaf1a61 (diff) | |
download | python-numpy-91e3f408b21bde54cac134b7140d76c7ae147a20.tar.gz python-numpy-91e3f408b21bde54cac134b7140d76c7ae147a20.tar.bz2 python-numpy-91e3f408b21bde54cac134b7140d76c7ae147a20.zip |
Allow 1-element arrays to be index arrays in Python 2.5
-rw-r--r-- | numpy/core/src/arrayobject.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 284e17901..e55b678d6 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -563,6 +563,7 @@ PyArray_PyIntAsIntp(PyObject *o) Py_DECREF(arr); return ret; } + #if (PY_VERSION_HEX >= 0x02050000) if (PyIndex_Check(o)) { PyObject* value = PyNumber_Index(o); @@ -3880,9 +3881,9 @@ _array_copy_nice(PyArrayObject *self) static PyObject * array_index(PyArrayObject *v) { - if (v->nd != 0 || !PyArray_ISINTEGER(v)) { - PyErr_SetString(PyExc_TypeError, "only 0-d integer " \ - "arrays can be converted to an index"); + if (!PyArray_ISINTEGER(v) || PyArray_SIZE(v) != 1) { + PyErr_SetString(PyExc_TypeError, "only integer arrays with " \ + "one element can be converted to an index"); return NULL; } return v->descr->f->getitem(v->data, v); |