[Numpy-svn] r3470 - trunk/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Dec 1 23:43:18 CST 2006


Author: oliphant
Date: 2006-12-01 23:43:15 -0600 (Fri, 01 Dec 2006)
New Revision: 3470

Modified:
   trunk/numpy/core/src/arrayobject.c
Log:
Allow 1-element arrays to be index arrays in Python 2.5

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-12-02 05:40:00 UTC (rev 3469)
+++ trunk/numpy/core/src/arrayobject.c	2006-12-02 05:43:15 UTC (rev 3470)
@@ -563,6 +563,7 @@
                 Py_DECREF(arr);
                 return ret;
         }
+
 #if (PY_VERSION_HEX >= 0x02050000)
 	if (PyIndex_Check(o)) {
                 PyObject* value = PyNumber_Index(o);
@@ -3880,9 +3881,9 @@
 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);



More information about the Numpy-svn mailing list