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

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Oct 27 16:42:30 CDT 2006


Author: oliphant
Date: 2006-10-27 16:42:27 -0500 (Fri, 27 Oct 2006)
New Revision: 3410

Modified:
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/scalartypes.inc.src
Log:
Fix to allow typeobjects in array descriptors which are not sub-types of array scalars.

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-10-27 20:44:32 UTC (rev 3409)
+++ trunk/numpy/core/src/arrayobject.c	2006-10-27 21:42:27 UTC (rev 3410)
@@ -1314,10 +1314,12 @@
         int swap;
 
         type_num = descr->type_num;
+        type = descr->typeobj;
         if (type_num == PyArray_BOOL)
                 PyArrayScalar_RETURN_BOOL_FROM_LONG(*(Bool*)data);
-        else if (type_num == PyArray_OBJECT ||          \
-                 ((type=descr->typeobj)==NULL)) {
+        else if (type_num == PyArray_OBJECT ||           
+                 (PyTypeNum_ISUSERDEF(type_num) &&
+                  !(PyType_IsSubtype(type, &PyGenericArrType_Type)))) {
                 return descr->f->getitem(data, base);
         }
         itemsize = descr->elsize;
@@ -1540,8 +1542,7 @@
 
         for (i=0; i<NPY_NUMUSERTYPES; i++) {
                 descr = userdescrs[i];
-                if (descr->typeobj && 
-                    strcmp(descr->typeobj->tp_name, str) == 0)
+                if (strcmp(descr->typeobj->tp_name, str) == 0)
                         return descr->type_num;
         }
 
@@ -1588,12 +1589,10 @@
                                 " is missing.");
                 return -1;
         }
-        /*
         if (descr->typeobj == NULL) {
                 PyErr_SetString(PyExc_ValueError, "missing typeobject");
                 return -1;
         }
-        */
         userdescrs = realloc(userdescrs,
                              (NPY_NUMUSERTYPES+1)*sizeof(void *));
         if (userdescrs == NULL) {
@@ -10662,12 +10661,6 @@
         static int prefix_len=0;
         
         if (PyTypeNum_ISUSERDEF(self->type_num)) {
-                if (typeobj == NULL) {
-                        return PyString_FromFormat("%c%d (%d)", 
-                                                   self->kind,
-                                                   self->elsize,
-                                                   self->type_num);
-                }
 		s = strrchr(typeobj->tp_name, '.');
 		if (s == NULL) {
 			res = PyString_FromString(typeobj->tp_name);
@@ -10891,10 +10884,6 @@
         Py_DECREF(mod);
         if (obj == NULL) {Py_DECREF(ret); return NULL;}
         PyTuple_SET_ITEM(ret, 0, obj);
-        if (self->typeobj == NULL) { /* Must handle this case in getitem */
-                obj = self->f->getitem(NULL, NULL);
-                if (obj == NULL) {Py_DECREF(ret); return NULL;}
-        }
         if (PyTypeNum_ISUSERDEF(self->type_num) ||              \
             ((self->type_num == PyArray_VOID &&                 \
               self->typeobj != &PyVoidArrType_Type))) {

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2006-10-27 20:44:32 UTC (rev 3409)
+++ trunk/numpy/core/src/scalartypes.inc.src	2006-10-27 21:42:27 UTC (rev 3410)
@@ -2556,6 +2556,7 @@
 
         /* Otherwise --- type is a sub-type of an array scalar
            currently only VOID allows it -- use it as the type-object.
+           This is for non-registered data-type objects. 
         */
         /* look for a dtypedescr attribute */
         if (!PyType_IsSubtype((PyTypeObject *)type, &PyVoidArrType_Type)) {



More information about the Numpy-svn mailing list