[Numpy-svn] r5690 - in trunk/numpy/core: src tests

numpy-svn at scipy.org numpy-svn at scipy.org
Sun Aug 24 05:01:26 EDT 2008


Author: oliphant
Date: 2008-08-24 04:01:21 -0500 (Sun, 24 Aug 2008)
New Revision: 5690

Modified:
   trunk/numpy/core/src/scalartypes.inc.src
   trunk/numpy/core/tests/test_regression.py
Log:
Fix the test and fix the arrtype_new code for scalars a little bit.

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2008-08-24 06:53:22 UTC (rev 5689)
+++ trunk/numpy/core/src/scalartypes.inc.src	2008-08-24 09:01:21 UTC (rev 5690)
@@ -1923,10 +1923,8 @@
 #elif @default@ == 1
         robj = PyArray_Scalar(NULL, typecode, NULL);
 #elif @default@ == 2
-	obj = Py_None;
-	robj = type->tp_alloc(type, 0);
 	Py_INCREF(Py_None);
-	((PyObjectScalarObject *)robj)->obval = obj;
+	robj = Py_None;
 #endif
 	Py_DECREF(typecode);
         goto finish;
@@ -1942,14 +1940,15 @@
     /* 0-d array */
     robj = PyArray_ToScalar(PyArray_DATA(arr), (NPY_AO *)arr);
     Py_DECREF(arr);  
+
+finish:
+
 #if @default@ == 2  /* In OBJECT case, robj is no longer a
 			  PyArrayScalar at this point but the
 			  remaining code assumes it is 
 		       */
     return robj;
-#endif
-
-finish:
+#else
     /* Normal return */
     if ((robj == NULL) || (robj->ob_type == type)) {
         return robj;
@@ -1983,12 +1982,11 @@
 	itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE);
     }
     memcpy(dest, src, itemsize);
-#elif @default@ == 2 /* Object arrays */    
-    memcpy(dest, src, sizeof(void *));
-    Py_INCREF(*((PyObject **)dest));
+    /* @default@ == 2 won't get here */
 #endif
     Py_DECREF(robj);
     return obj;
+#endif
 }
 /**end repeat**/
 

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2008-08-24 06:53:22 UTC (rev 5689)
+++ trunk/numpy/core/tests/test_regression.py	2008-08-24 09:01:21 UTC (rev 5690)
@@ -1196,7 +1196,7 @@
         assert type(b2) is float
         assert type(c) is np.ndarray
         assert c.dtype == object
-        assert d.type == object
+        assert d.dtype == object
 
 if __name__ == "__main__":
     run_module_suite()




More information about the Numpy-svn mailing list