[Numpy-svn] r3032 - in trunk/numpy/core: . include/numpy src

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Aug 17 02:53:10 CDT 2006


Author: oliphant
Date: 2006-08-17 02:53:01 -0500 (Thu, 17 Aug 2006)
New Revision: 3032

Modified:
   trunk/numpy/core/include/numpy/arrayobject.h
   trunk/numpy/core/numeric.py
   trunk/numpy/core/numerictypes.py
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/scalartypes.inc.src
Log:
Fix mismatch between tp_name and pickle name so that pickles of scalar types will work.

Modified: trunk/numpy/core/include/numpy/arrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/arrayobject.h	2006-08-17 01:01:14 UTC (rev 3031)
+++ trunk/numpy/core/include/numpy/arrayobject.h	2006-08-17 07:53:01 UTC (rev 3032)
@@ -977,8 +977,8 @@
 /* Size of internal buffers used for alignment */
 /* Make BUFSIZE a multiple of sizeof(cdouble) -- ususally 16 */
 /* So that ufunc buffers are aligned */
-#define NPY_MIN_BUFSIZE sizeof(cdouble)
-#define NPY_MAX_BUFSIZE sizeof(cdouble)*1000000
+#define NPY_MIN_BUFSIZE ((int)sizeof(cdouble))
+#define NPY_MAX_BUFSIZE (((int)sizeof(cdouble))*1000000)
 #define NPY_BUFSIZE 10000 
 /* #define NPY_BUFSIZE 80*/
 

Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py	2006-08-17 01:01:14 UTC (rev 3031)
+++ trunk/numpy/core/numeric.py	2006-08-17 07:53:01 UTC (rev 3032)
@@ -328,7 +328,7 @@
     if typeless and arr.size:
         return cName + "(%s)" % lst
     else:
-        typename=arr.dtype.type.__name__[:-6]
+        typename=arr.dtype.name
         lf = ''
         if issubclass(arr.dtype.type, flexible):
             typename = str(arr.dtype)

Modified: trunk/numpy/core/numerictypes.py
===================================================================
--- trunk/numpy/core/numerictypes.py	2006-08-17 01:01:14 UTC (rev 3031)
+++ trunk/numpy/core/numerictypes.py	2006-08-17 07:53:01 UTC (rev 3032)
@@ -106,7 +106,7 @@
 
 def bitname(obj):
     """Return a bit-width name for a given type object"""
-    name = obj.__name__[:-6]
+    name = obj.__name__
     base = ''
     char = ''
     try:
@@ -323,7 +323,7 @@
     if g is None:
         return t
     t = g
-    name = t.__name__[:-6]
+    name = t.__name__
     base, bits = _evalname(name)
     if bits == 0:
         return t
@@ -334,7 +334,7 @@
                  float: 'float_',
                  complex: 'complex_',
                  bool: 'bool_',
-                 str: 'string',
+                 str: 'string_',
                  unicode: 'unicode_',
                  _types.BufferType: 'void',
                 }

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-08-17 01:01:14 UTC (rev 3031)
+++ trunk/numpy/core/src/arrayobject.c	2006-08-17 07:53:01 UTC (rev 3032)
@@ -10441,18 +10441,30 @@
         int len;
         PyTypeObject *typeobj = self->typeobj;
         PyObject *res;
-        static int suffix_len=0;
+	char *s;
+        static int prefix_len=0;
 
         if (PyTypeNum_ISUSERDEF(self->type_num)) {
-                res = PyString_FromString(typeobj->tp_name);
+		s = strrchr(typeobj->tp_name, '.');
+		if (s == NULL) {
+			res = PyString_FromString(typeobj->tp_name);
+		}
+		else {
+			res = PyString_FromStringAndSize(s+1, strlen(s)-1);
+		}
+		return res;
         }
         else {
-                if (suffix_len == 0)
-                        suffix_len = strlen("scalar");
-                len = strlen(typeobj->tp_name) - suffix_len;
-                res = PyString_FromStringAndSize(typeobj->tp_name, len);
+                if (prefix_len == 0)
+                        prefix_len = strlen("numpy.");
+		
+                len = strlen(typeobj->tp_name);
+		if (*(typeobj->tp_name + (len-1)) == '_')
+			len-=1;
+		len -= prefix_len;
+		res = PyString_FromStringAndSize(typeobj->tp_name+prefix_len, len);
         }
-        if (PyTypeNum_ISEXTENDED(self->type_num) && self->elsize != 0) {
+        if (PyTypeNum_ISFLEXIBLE(self->type_num) && self->elsize != 0) {
                 PyObject *p;
                 p = PyString_FromFormat("%d", self->elsize * 8);
                 PyString_ConcatAndDel(&res, p);

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2006-08-17 01:01:14 UTC (rev 3031)
+++ trunk/numpy/core/src/scalartypes.inc.src	2006-08-17 07:53:01 UTC (rev 3032)
@@ -23,7 +23,7 @@
 static PyTypeObject Py at NAME@ArrType_Type = {
         PyObject_HEAD_INIT(NULL)
         0,                                        /*ob_size*/
-        "@name at scalar",                   /*tp_name*/
+        "numpy. at name@",                   /*tp_name*/
         sizeof(PyObject),                         /*tp_basicsize*/
 };
 /**end repeat**/
@@ -1652,7 +1652,7 @@
 static PyTypeObject PyGenericArrType_Type = {
         PyObject_HEAD_INIT(NULL)
         0,                                        /*ob_size*/
-        "genericscalar",                         /*tp_name*/
+        "numpy.generic",                         /*tp_name*/
         sizeof(PyObject),                         /*tp_basicsize*/
 };
 
@@ -2195,7 +2195,7 @@
 static PyTypeObject PyObjectArrType_Type = {
         PyObject_HEAD_INIT(NULL)
         0,                                        /*ob_size*/
-        "objectscalar",                   /*tp_name*/
+        "numpy.object_",                           /*tp_name*/
         sizeof(PyObjectScalarObject),             /*tp_basicsize*/
         0,                                        /* tp_itemsize */
         (destructor)object_arrtype_dealloc,       /* tp_dealloc */
@@ -2219,11 +2219,12 @@
 /**begin repeat
 #name=bool, string, unicode, void#
 #NAME=Bool, String, Unicode, Void#
+#ex=_,_,_,#
 */
 static PyTypeObject Py at NAME@ArrType_Type = {
         PyObject_HEAD_INIT(NULL)
         0,                                        /*ob_size*/
-        "@name at scalar",                   /*tp_name*/
+        "numpy. at name@@ex@",                           /*tp_name*/
         sizeof(Py at NAME@ScalarObject),             /*tp_basicsize*/
 };
 /**end repeat**/
@@ -2253,7 +2254,7 @@
 static PyTypeObject Py at NAME@ArrType_Type = {
         PyObject_HEAD_INIT(NULL)
         0,                                           /*ob_size*/
-        "@name@" _THIS_SIZE "scalar", /*tp_name*/
+        "numpy. at name@" _THIS_SIZE, /*tp_name*/
         sizeof(Py at NAME@ScalarObject),                /*tp_basicsize*/
 };
 
@@ -2290,7 +2291,7 @@
 static PyTypeObject Py at NAME@ArrType_Type = {
         PyObject_HEAD_INIT(NULL)
         0,                                          /*ob_size*/
-        "@name@" _THIS_SIZE1 "scalar", /*tp_name*/
+        "numpy. at name@" _THIS_SIZE1, /*tp_name*/
         sizeof(Py at NAME@ScalarObject),             /*tp_basicsize*/
         0,                         /*tp_itemsize*/
         0,                         /*tp_dealloc*/



More information about the Numpy-svn mailing list