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

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Jan 31 14:13:28 EST 2008


Author: oliphant
Date: 2008-01-31 13:13:26 -0600 (Thu, 31 Jan 2008)
New Revision: 4764

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
Fix type-coercion for search sorted so that it works with variable-length arrays.

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2008-01-31 12:47:01 UTC (rev 4763)
+++ trunk/numpy/core/src/multiarraymodule.c	2008-01-31 19:13:26 UTC (rev 4764)
@@ -3065,23 +3065,26 @@
     PyArrayObject *ap1=NULL;
     PyArrayObject *ap2=NULL;
     PyArrayObject *ret=NULL;
+    PyArray_Descr *dtype;
     int typenum = 0;
 
     NPY_BEGIN_THREADS_DEF
 
-        typenum = PyArray_ObjectType((PyObject *)op1, 0);
-    typenum = PyArray_ObjectType(op2, typenum);
+    dtype = PyArray_DescrFromObject((PyObject *)op2, op1->descr);
+    
+    /* need ap1 as contiguous array and of right type */
+    Py_INCREF(dtype);
+    ap1 = (PyArrayObject *)PyArray_FromAny((PyObject *)op1, dtype, 
+					   1, 1, NPY_DEFAULT, NULL);
 
-    /* need ap1 as contiguous array and of right type */
-    ap1 = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)op1,
-                                                     typenum,
-                                                     1, 1);
-    if (ap1 == NULL)
+    if (ap1 == NULL) {
+        Py_DECREF(dtype);
         return NULL;
+    }
 
     /* need ap2 as contiguous array and of right type */
-    ap2 = (PyArrayObject *)PyArray_ContiguousFromAny(op2, typenum,
-                                                     0, 0);
+    ap2 = (PyArrayObject *)PyArray_FromAny(op2, dtype, 0, 0, NPY_DEFAULT, NULL);
+
     if (ap2 == NULL)
         goto fail;
 




More information about the Numpy-svn mailing list