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

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Dec 7 20:54:42 CST 2006


Author: oliphant
Date: 2006-12-07 20:54:38 -0600 (Thu, 07 Dec 2006)
New Revision: 3480

Modified:
   trunk/numpy/core/src/multiarraymodule.c
   trunk/numpy/core/src/ufuncobject.c
Log:
Fix some problems with user-defined ufunc registration.

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-12-06 20:48:30 UTC (rev 3479)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-12-08 02:54:38 UTC (rev 3480)
@@ -607,9 +607,7 @@
 /* Returns a new array
    with the new shape from the data
    in the old array --- order-perspective depends on fortran argument.
-   copy-if-necessary  (currently if not contiguous or fortran-contiguous)
-   perhaps a more general-purpose strategy for determining this can
-   be worked out
+   copy-only-if-necessary 
 */
 
 /*MULTIARRAY_API

Modified: trunk/numpy/core/src/ufuncobject.c
===================================================================
--- trunk/numpy/core/src/ufuncobject.c	2006-12-06 20:48:30 UTC (rev 3479)
+++ trunk/numpy/core/src/ufuncobject.c	2006-12-08 02:54:38 UTC (rev 3480)
@@ -652,19 +652,19 @@
 _find_matching_userloop(PyObject *obj, int *arg_types, 
                         PyArray_SCALARKIND *scalars,
                         PyUFuncGenericFunction *function, void **data, 
-                        int nargs)
+                        int nargs, int nin)
 {
         PyUFunc_Loop1d *funcdata;
         int i;
         funcdata = (PyUFunc_Loop1d *)PyCObject_AsVoidPtr(obj);
         while (funcdata != NULL) {
-                for (i=0; i<nargs; i++) {
+                for (i=0; i<nin; i++) {
 			if (!PyArray_CanCoerceScalar(arg_types[i],
 						     funcdata->arg_types[i],
 						     scalars[i])) 
                                 break;
                 }
-                if (i==nargs) { /* match found */
+                if (i==nin) { /* match found */
                         *function = funcdata->func;
                         *data = funcdata->data;
                         /* Make sure actual arg_types supported
@@ -901,7 +901,8 @@
                    data and argtypes
                 */
                 ret = _find_matching_userloop(obj, arg_types, scalars,
-                                              function, data, self->nargs);
+                                              function, data, self->nargs,
+                                              self->nin);
                 Py_DECREF(obj);
                 return ret;
 	}
@@ -3493,7 +3494,7 @@
 
         /* If it's not there, then make one and return. */
         if (cobj == NULL) {
-                cobj = PyCObject_FromVoidPtr((void *)function, 
+                cobj = PyCObject_FromVoidPtr((void *)funcdata,
                                              _loop1d_list_free);
                 if (cobj == NULL) goto fail;
                 PyDict_SetItem(ufunc->userloops, key, cobj);



More information about the Numpy-svn mailing list