From 91e3f408b21bde54cac134b7140d76c7ae147a20 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Sat, 2 Dec 2006 05:43:15 +0000 Subject: Allow 1-element arrays to be index arrays in Python 2.5 --- numpy/core/src/arrayobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'numpy/core/src/arrayobject.c') 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); -- cgit v1.2.1