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

numpy-svn@scip... numpy-svn@scip...
Sat Apr 26 13:57:07 CDT 2008


Author: charris
Date: 2008-04-26 13:57:06 -0500 (Sat, 26 Apr 2008)
New Revision: 5094

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
Add semicolons to end of macros. This helps editors and such get the
formatting right. Do some small code cleanup.


Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2008-04-26 18:36:35 UTC (rev 5093)
+++ trunk/numpy/core/src/multiarraymodule.c	2008-04-26 18:57:06 UTC (rev 5094)
@@ -2423,14 +2423,15 @@
     int elsize;
     intp astride;
     PyArray_SortFunc *sort;
-    BEGIN_THREADS_DEF
+    BEGIN_THREADS_DEF;
 
     it = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, &axis);
     swap = !PyArray_ISNOTSWAPPED(op);
-    if (it == NULL) return -1;
+    if (it == NULL) {
+        return -1;
+    }
 
-    NPY_BEGIN_THREADS_DESCR(op->descr)
-
+    NPY_BEGIN_THREADS_DESCR(op->descr);
     sort = op->descr->f->sort[which];
     size = it->size;
     N = op->dimensions[axis];
@@ -2446,12 +2447,16 @@
         while (size--) {
             _unaligned_strided_byte_copy(buffer, (intp) elsize, it->dataptr,
                                          astride, N, elsize);
-            if (swap) _strided_byte_swap(buffer, (intp) elsize, N, elsize);
+            if (swap) {
+                _strided_byte_swap(buffer, (intp) elsize, N, elsize);
+            }
             if (sort(buffer, N, op) < 0) {
-                PyDataMem_FREE(buffer); goto fail;
+                PyDataMem_FREE(buffer);
+                goto fail;
             }
-            if (swap) _strided_byte_swap(buffer, (intp) elsize, N, elsize);
-
+            if (swap) {
+                _strided_byte_swap(buffer, (intp) elsize, N, elsize);
+            }
             _unaligned_strided_byte_copy(it->dataptr, astride, buffer,
                                          (intp) elsize, N, elsize);
             PyArray_ITER_NEXT(it);
@@ -2460,20 +2465,20 @@
     }
     else {
         while (size--) {
-            if (sort(it->dataptr, N, op) < 0) goto fail;
+            if (sort(it->dataptr, N, op) < 0) {
+                goto fail;
+            }
             PyArray_ITER_NEXT(it);
         }
     }
 
-    NPY_END_THREADS_DESCR(op->descr)
-
-        Py_DECREF(it);
+    NPY_END_THREADS_DESCR(op->descr);
+    Py_DECREF(it);
     return 0;
 
  fail:
-    END_THREADS
-
-        Py_DECREF(it);
+    NPY_END_THREADS;
+    Py_DECREF(it);
     return 0;
 }
 
@@ -2489,7 +2494,7 @@
     int elsize, swap;
     intp astride, rstride, *iptr;
     PyArray_ArgSortFunc *argsort;
-    BEGIN_THREADS_DEF
+    BEGIN_THREADS_DEF;
 
     ret = PyArray_New(op->ob_type, op->nd,
                           op->dimensions, PyArray_INTP,
@@ -2502,7 +2507,7 @@
 
     swap = !PyArray_ISNOTSWAPPED(op);
 
-    NPY_BEGIN_THREADS_DESCR(op->descr)
+    NPY_BEGIN_THREADS_DESCR(op->descr);
 
     argsort = op->descr->f->argsort[which];
     size = it->size;
@@ -2548,17 +2553,17 @@
         }
     }
 
-    NPY_END_THREADS_DESCR(op->descr)
+    NPY_END_THREADS_DESCR(op->descr);
 
-        Py_DECREF(it);
+    Py_DECREF(it);
     Py_DECREF(rit);
     return ret;
 
  fail:
 
-    END_THREADS
+    NPY_END_THREADS;
 
-        Py_DECREF(ret);
+    Py_DECREF(ret);
     Py_XDECREF(it);
     Py_XDECREF(rit);
     return NULL;
@@ -2825,7 +2830,7 @@
     int object=0;
     PyArray_ArgSortFunc *argsort;
 
-    NPY_BEGIN_THREADS_DEF
+    NPY_BEGIN_THREADS_DEF;
 
         if (!PySequence_Check(sort_keys) || \
             ((n=PySequence_Size(sort_keys)) <= 0)) {
@@ -2897,7 +2902,9 @@
         PyArray_IterAllButAxis((PyObject *)ret, &axis);
     if (rit == NULL) goto fail;
 
-    if (!object) {NPY_BEGIN_THREADS}
+    if (!object) {
+        NPY_BEGIN_THREADS;
+    }
 
     size = rit->size;
     N = mps[0]->dimensions[axis];
@@ -2961,7 +2968,9 @@
         }
     }
 
-    if (!object) {NPY_END_THREADS}
+    if (!object) {
+        NPY_END_THREADS;
+    }
 
  finish:
     for (i=0; i<n; i++) {Py_XDECREF(mps[i]); Py_XDECREF(its[i]);}
@@ -2971,7 +2980,7 @@
     return (PyObject *)ret;
 
  fail:
-    NPY_END_THREADS
+    NPY_END_THREADS;
 
         Py_XDECREF(rit);
     Py_XDECREF(ret);
@@ -3103,9 +3112,8 @@
     PyArrayObject *ap2=NULL;
     PyArrayObject *ret=NULL;
     PyArray_Descr *dtype;
+    NPY_BEGIN_THREADS_DEF;
 
-    NPY_BEGIN_THREADS_DEF
-
     dtype = PyArray_DescrFromObject((PyObject *)op2, op1->descr);
 
     /* need ap1 as contiguous array and of right type */
@@ -3139,15 +3147,15 @@
     }
 
     if (side == NPY_SEARCHLEFT) {
-        NPY_BEGIN_THREADS_DESCR(ap2->descr)
-            local_search_left(ap1, ap2, ret);
-        NPY_END_THREADS_DESCR(ap2->descr)
-            }
+        NPY_BEGIN_THREADS_DESCR(ap2->descr);
+        local_search_left(ap1, ap2, ret);
+        NPY_END_THREADS_DESCR(ap2->descr);
+    }
     else if (side == NPY_SEARCHRIGHT) {
-        NPY_BEGIN_THREADS_DESCR(ap2->descr)
-            local_search_right(ap1, ap2, ret);
-        NPY_END_THREADS_DESCR(ap2->descr)
-            }
+        NPY_BEGIN_THREADS_DESCR(ap2->descr);
+        local_search_right(ap1, ap2, ret);
+        NPY_END_THREADS_DESCR(ap2->descr);
+    }
     Py_DECREF(ap1);
     Py_DECREF(ap2);
     return (PyObject *)ret;
@@ -3209,7 +3217,7 @@
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
 
-    NPY_BEGIN_THREADS_DEF
+    NPY_BEGIN_THREADS_DEF;
 
         typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
@@ -3274,7 +3282,7 @@
     it2 = (PyArrayIterObject *)\
         PyArray_IterAllButAxis((PyObject *)ap2, &axis);
 
-    NPY_BEGIN_THREADS_DESCR(ap2->descr)
+    NPY_BEGIN_THREADS_DESCR(ap2->descr);
         while(1) {
             while(it2->index < it2->size) {
                 dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
@@ -3285,7 +3293,7 @@
             if (it1->index >= it1->size) break;
             PyArray_ITER_RESET(it2);
         }
-    NPY_END_THREADS_DESCR(ap2->descr)
+    NPY_END_THREADS_DESCR(ap2->descr);
         Py_DECREF(it1);
     Py_DECREF(it2);
 
@@ -3320,9 +3328,8 @@
     intp dimensions[MAX_DIMS];
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
+    NPY_BEGIN_THREADS_DEF;
 
-    NPY_BEGIN_THREADS_DEF
-
         typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
 
@@ -3410,7 +3417,7 @@
     it2 = (PyArrayIterObject *)\
         PyArray_IterAllButAxis((PyObject *)ap2, &matchDim);
 
-    NPY_BEGIN_THREADS_DESCR(ap2->descr)
+    NPY_BEGIN_THREADS_DESCR(ap2->descr);
         while(1) {
             while(it2->index < it2->size) {
                 dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
@@ -3421,7 +3428,7 @@
             if (it1->index >= it1->size) break;
             PyArray_ITER_RESET(it2);
         }
-    NPY_END_THREADS_DESCR(ap2->descr)
+    NPY_END_THREADS_DESCR(ap2->descr);
         Py_DECREF(it1);
     Py_DECREF(it2);
     if (PyErr_Occurred()) goto fail;  /* only for OBJECT arrays */
@@ -3482,7 +3489,7 @@
         return NULL;
     }
     /* do 2-d loop */
-    NPY_BEGIN_ALLOW_THREADS
+    NPY_BEGIN_ALLOW_THREADS;
         optr = PyArray_DATA(ret);
     str2 = elsize*dims[0];
     for (i=0; i<dims[0]; i++) {
@@ -3494,7 +3501,7 @@
             iptr += str2;
         }
     }
-    NPY_END_ALLOW_THREADS
+    NPY_END_ALLOW_THREADS;
         Py_DECREF(arr);
     return ret;
 }
@@ -3514,7 +3521,7 @@
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
 
-    NPY_BEGIN_THREADS_DEF
+    NPY_BEGIN_THREADS_DEF;
 
         typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
@@ -3570,7 +3577,7 @@
         goto fail;
     }
 
-    NPY_BEGIN_THREADS_DESCR(ret->descr)
+    NPY_BEGIN_THREADS_DESCR(ret->descr);
 
         is1 = ap1->strides[0]; is2 = ap2->strides[0];
     op = ret->data; os = ret->descr->elsize;
@@ -3594,7 +3601,7 @@
         ip1 += is1;
         op += os;
     }
-    NPY_END_THREADS_DESCR(ret->descr)
+    NPY_END_THREADS_DESCR(ret->descr);
 
         if (PyErr_Occurred()) goto fail;
     Py_DECREF(ap1);
@@ -3722,7 +3729,7 @@
     int elsize;
     int copyret=0;
 
-    NPY_BEGIN_THREADS_DEF
+    NPY_BEGIN_THREADS_DEF;
 
         if ((ap=(PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;
 
@@ -3791,14 +3798,14 @@
         if (rp != out) copyret = 1;
     }
 
-    NPY_BEGIN_THREADS_DESCR(ap->descr)
+    NPY_BEGIN_THREADS_DESCR(ap->descr);
     n = PyArray_SIZE(ap)/m;
     rptr = (intp *)rp->data;
     for (ip = ap->data, i=0; i<n; i++, ip+=elsize*m) {
         arg_func(ip, m, rptr, ap);
         rptr += 1;
     }
-    NPY_END_THREADS_DESCR(ap->descr)
+    NPY_END_THREADS_DESCR(ap->descr);
 
     Py_DECREF(ap);
     if (copyret) {
@@ -7393,14 +7400,16 @@
     if (!PyArg_ParseTuple(args, "|i", &kind)) return NULL;
 
     if (kind) {
-        Py_BEGIN_ALLOW_THREADS
-            while (a>=0) {
-                if ((a % 1000 == 0) &&
-                    PyOS_InterruptOccurred()) break;
-                a+=1;
+        NPY_BEGIN_ALLOW_THREADS;
+        while (a>=0) {
+            if ((a % 1000 == 0) &&
+                 PyOS_InterruptOccurred()) {
+                break;
             }
-        Py_END_ALLOW_THREADS
-            }
+            a+=1;
+        }
+        NPY_END_ALLOW_THREADS;
+    }
     else {
 
         NPY_SIGINT_ON



More information about the Numpy-svn mailing list