[Numpy-svn] r4785 - trunk/numpy/lib/src

numpy-svn@scip... numpy-svn@scip...
Sun Feb 10 00:38:39 CST 2008


Author: charris
Date: 2008-02-10 00:38:37 -0600 (Sun, 10 Feb 2008)
New Revision: 4785

Modified:
   trunk/numpy/lib/src/_compiled_base.c
Log:
Fix whitespace and compiler warning. _compiled_base.c is full of ugly code and
is in terrific need of reformating.


Modified: trunk/numpy/lib/src/_compiled_base.c
===================================================================
--- trunk/numpy/lib/src/_compiled_base.c	2008-02-10 06:19:42 UTC (rev 4784)
+++ trunk/numpy/lib/src/_compiled_base.c	2008-02-10 06:38:37 UTC (rev 4785)
@@ -344,12 +344,14 @@
 static npy_intp
 binary_search(double dval, double dlist [], npy_intp len)
 {
-    /* binary_search accepts three arguments: a numeric value and
+    /*
+     * binary_search accepts three arguments: a numeric value and
      * a numeric array and its length. It assumes that the array is sorted in
      * increasing order. It returns the index of the array's
      * largest element which is <= the value. It will return -1 if
-     * the value is less than the least element of the array. */
-    /* self is not used */
+     * the value is less than the least element of the array.
+     * self is not used
+     */
     npy_intp bottom , top , middle, result;
 
     if (dval < dlist [0])
@@ -530,12 +532,12 @@
 }
 
 
-static char packbits_doc[] = 
+static char packbits_doc[] =
   "out = numpy.packbits(myarray, axis=None)\n\n"
   "  myarray : an integer type array whose elements should be packed to bits\n\n"
   "   This routine packs the elements of a binary-valued dataset into a\n"
   "   NumPy array of type uint8 ('B') whose bits correspond to\n"
-  "   the logical (0 or nonzero) value of the input elements.\n" 
+  "   the logical (0 or nonzero) value of the input elements.\n"
   "   The dimension over-which bit-packing is done is given by axis.\n"
   "   The shape of the output has the same number of dimensions as the input\n"
   "   (unless axis is None, in which case the output is 1-d).\n"
@@ -551,7 +553,7 @@
   "     Note that 160 = 128 + 32\n"
   "               192 = 128 + 64\n";
 
-static char unpackbits_doc[] = 
+static char unpackbits_doc[] =
   "out = numpy.unpackbits(myarray, axis=None)\n\n"
   "     myarray - array of uint8 type where each element represents a bit-field\n"
   "        that should be unpacked into a boolean output array\n\n"
@@ -566,7 +568,7 @@
 
 */
 
-static void 
+static void
 _packbits(
 	      void 	*In,
               int       element_size,  /* in bytes */
@@ -586,11 +588,13 @@
   outptr = Out;                          /* pointer to output buffer */
   inptr  = In;                           /* pointer to input buffer */
 
-  /* Loop through the elements of In */
-  /* Determine whether or not it is nonzero.
-     Yes: set correspdoning bit (and adjust build value)
-     No:  move on     
-  /* Every 8th value, set the value of build and increment the outptr */
+  /*
+   * Loop through the elements of In
+   * Determine whether or not it is nonzero.
+   *  Yes: set correspdoning bit (and adjust build value)
+   *  No:  move on
+   * Every 8th value, set the value of build and increment the outptr
+   */
 
   remain = in_N % 8;                      /* uneven bits */
   if (remain == 0) remain = 8;
@@ -607,7 +611,7 @@
       build += (nonzero != 0);             /* add to this bit if the input value is non-zero */
     }
     if (index == out_Nm1) build <<= (8-remain);
-    /*      printf("Here: %d %d %d %d\n",build,slice,index,maxi); 
+    /*      printf("Here: %d %d %d %d\n",build,slice,index,maxi);
      */
     *outptr = build;
     outptr += out_stride;
@@ -616,7 +620,7 @@
 }
 
 
-static void 
+static void
 _unpackbits(
 		void      *In,
 		int       el_size,  /* unused */
@@ -670,7 +674,7 @@
     if (!PyArray_ISINTEGER(inp))
       PYSETERROR("Expecting an input array of integer data type");
   }
- 
+
   new = PyArray_CheckAxis(inp, &axis, 0);
   Py_DECREF(inp);
   if (new == NULL) return NULL;
@@ -680,7 +684,7 @@
     return PyArray_Copy((PyArrayObject *)new);
   }
 
-  if (PyArray_NDIM(new) == 0) {    
+  if (PyArray_NDIM(new) == 0) {
     if (unpack) {
       /* Handle 0-d array by converting it to a 1-d array */
       PyObject *temp;
@@ -733,7 +737,7 @@
   out = PyArray_New(new->ob_type, PyArray_NDIM(new), outdims, PyArray_UBYTE,
 		    NULL, NULL, 0, PyArray_ISFORTRAN(new), NULL);
   if (out == NULL) goto fail;
-  
+
   /* Setup iterators to iterate over all but given axis */
   it = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)new, &axis);
   ot = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)out, &axis);
@@ -744,12 +748,12 @@
   }
 
   while(PyArray_ITER_NOTDONE(it)) {
-    thefunc(PyArray_ITER_DATA(it), PyArray_ITEMSIZE(new), 
+    thefunc(PyArray_ITER_DATA(it), PyArray_ITEMSIZE(new),
 	    PyArray_DIM(new, axis), PyArray_STRIDE(new, axis),
-	    PyArray_ITER_DATA(ot), PyArray_DIM(out, axis), 
+	    PyArray_ITER_DATA(ot), PyArray_DIM(out, axis),
 	    PyArray_STRIDE(out, axis));
     PyArray_ITER_NEXT(it);
-    PyArray_ITER_NEXT(ot);	      
+    PyArray_ITER_NEXT(ot);
   }
   Py_DECREF(it);
   Py_DECREF(ot);
@@ -761,26 +765,26 @@
  fail:
   Py_XDECREF(new);
   Py_XDECREF(out);
-  return NULL;  
+  return NULL;
 }
 
 
 
 static PyObject *
-io_pack(PyObject *self, PyObject *args, PyObject *kwds)  
+io_pack(PyObject *self, PyObject *args, PyObject *kwds)
 {
   PyObject *obj;
   int axis=NPY_MAXDIMS;
   static char *kwlist[] = {"in", "axis", NULL};
 
-  if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|O&" , kwlist, 
+  if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|O&" , kwlist,
 				    &obj, PyArray_AxisConverter, &axis))
     return NULL;
-  return pack_or_unpack_bits(obj, axis, 0);  
+  return pack_or_unpack_bits(obj, axis, 0);
 }
 
 static PyObject *
-io_unpack(PyObject *self, PyObject *args, PyObject *kwds)  
+io_unpack(PyObject *self, PyObject *args, PyObject *kwds)
 {
   PyObject *obj;
   int axis=NPY_MAXDIMS;
@@ -789,7 +793,7 @@
   if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|O&" , kwlist,
 				    &obj, PyArray_AxisConverter, &axis))
     return NULL;
-  return pack_or_unpack_bits(obj, axis, 1);  
+  return pack_or_unpack_bits(obj, axis, 1);
 }
 
 static struct PyMethodDef methods[] = {
@@ -803,9 +807,9 @@
      NULL},
     {"add_docstring", (PyCFunction)arr_add_docstring, METH_VARARGS,
      NULL},
-    {"packbits",  (PyCFunction)io_pack,       METH_VARARGS | METH_KEYWORDS, 
+    {"packbits",  (PyCFunction)io_pack,       METH_VARARGS | METH_KEYWORDS,
      packbits_doc},
-    {"unpackbits", (PyCFunction)io_unpack,     METH_VARARGS | METH_KEYWORDS, 
+    {"unpackbits", (PyCFunction)io_unpack,     METH_VARARGS | METH_KEYWORDS,
      unpackbits_doc},
     {NULL, NULL}    /* sentinel */
 };



More information about the Numpy-svn mailing list