[Numpy-svn] r6445 - in branches/coremath: . numpy/core/include/numpy numpy/core/src numpy/distutils numpy/distutils/command numpy/distutils/fcompiler numpy/lib/tests

numpy-svn@scip... numpy-svn@scip...
Sat Feb 21 21:42:03 CST 2009


Author: cdavid
Date: 2009-02-21 21:41:06 -0600 (Sat, 21 Feb 2009)
New Revision: 6445

Modified:
   branches/coremath/
   branches/coremath/numpy/core/include/numpy/ndarrayobject.h
   branches/coremath/numpy/core/src/arrayobject.c
   branches/coremath/numpy/core/src/multiarraymodule.c
   branches/coremath/numpy/core/src/scalarmathmodule.c.src
   branches/coremath/numpy/core/src/scalartypes.inc.src
   branches/coremath/numpy/distutils/command/build_ext.py
   branches/coremath/numpy/distutils/fcompiler/compaq.py
   branches/coremath/numpy/distutils/mingw32ccompiler.py
   branches/coremath/numpy/lib/tests/test_io.py
Log:
Merged revisions 6398-6400,6410,6421-6424,6426-6428,6431,6433,6441-6442 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk

................
  r6398 | charris | 2009-02-19 05:54:52 +0900 (Thu, 19 Feb 2009) | 2 lines
  
  Coding style cleanups.
................
  r6399 | charris | 2009-02-19 09:45:14 +0900 (Thu, 19 Feb 2009) | 2 lines
  
  Coding style cleanups.
................
  r6400 | charris | 2009-02-19 13:58:23 +0900 (Thu, 19 Feb 2009) | 1 line
  
  Coding style cleanups.
................
  r6410 | cdavid | 2009-02-19 19:05:28 +0900 (Thu, 19 Feb 2009) | 1 line
  
  Tag known failure on win32.
................
  r6421 | stefan | 2009-02-20 04:28:08 +0900 (Fri, 20 Feb 2009) | 1 line
  
  Fix tests using strptime to be Python 2.4 compatible.
................
  r6422 | charris | 2009-02-20 08:25:01 +0900 (Fri, 20 Feb 2009) | 2 lines
  
  Coding style cleanups.
................
  r6423 | charris | 2009-02-20 12:40:53 +0900 (Fri, 20 Feb 2009) | 1 line
  
  Coding style cleanups.
................
  r6424 | cdavid | 2009-02-20 22:30:20 +0900 (Fri, 20 Feb 2009) | 1 line
  
  Unhelpful message for compaq fortran compiler.
................
  r6426 | charris | 2009-02-21 07:28:05 +0900 (Sat, 21 Feb 2009) | 2 lines
  
  Change indentation of switch statements.
................
  r6427 | charris | 2009-02-21 13:21:50 +0900 (Sat, 21 Feb 2009) | 1 line
  
  Coding style cleanups.
................
  r6428 | cdavid | 2009-02-21 13:35:57 +0900 (Sat, 21 Feb 2009) | 3 lines
  
  Removed merge tracking for "svnmerge" for 
  http://svn.scipy.org/svn/numpy/branches/fix_float_format
................
  r6431 | charris | 2009-02-21 13:41:17 +0900 (Sat, 21 Feb 2009) | 1 line
  
  Remove terminating ";" from macro to fix ticket #918.
................
  r6433 | cdavid | 2009-02-21 14:38:29 +0900 (Sat, 21 Feb 2009) | 3 lines
  
  Removed merge tracking for "svnmerge" for 
  http://svn.scipy.org/svn/numpy/branches/visualstudio_manifest
................
  r6441 | cdavid | 2009-02-22 02:25:09 +0900 (Sun, 22 Feb 2009) | 105 lines
  
  Merged revisions 6153-6173,6176-6178,6184 via svnmerge from 
  http://svn.scipy.org/svn/numpy/branches/numpy-mingw-w64
  
  ........
    r6153 | cdavid | 2008-12-19 17:06:06 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Add a function to find python dll on windows.
  ........
    r6154 | cdavid | 2008-12-19 17:28:49 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Fix typo when getting system32 location.
  ........
    r6155 | cdavid | 2008-12-19 17:37:19 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Add a function to get a dump of private headers from dll.
  ........
    r6156 | cdavid | 2008-12-19 17:41:39 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Add a function to generate a .def file from a dll.
  ........
    r6157 | cdavid | 2008-12-19 17:43:56 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Forgot to add the regex for the generate_def function.
  ........
    r6158 | cdavid | 2008-12-19 17:53:49 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Fix .def file generation.
  ........
    r6159 | cdavid | 2008-12-19 17:56:54 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Add a warning if no symbols found in the dll (if stripped, for example).
  ........
    r6160 | cdavid | 2008-12-19 18:02:24 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Refactor build_import_library to take into account multi arch.
  ........
    r6161 | cdavid | 2008-12-19 18:10:03 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Do not generate manifest when built with msver 8.*, it does not look like it is needed, and we dont support it anyway ATM.
  ........
    r6162 | cdavid | 2008-12-19 18:18:08 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Show arch in the log when building import library.
  ........
    r6163 | cdavid | 2008-12-19 18:22:18 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Fix missing out filename.
  ........
    r6164 | cdavid | 2008-12-19 18:32:46 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Actually build the import library for mingw on amd64.
  ........
    r6165 | cdavid | 2008-12-19 18:46:30 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Do not generate ordinal, and use the basename of the dll instead of the full path in the def.file.
  ........
    r6166 | cdavid | 2008-12-19 18:48:01 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Trailing spaces.
  ........
    r6167 | cdavid | 2008-12-19 18:55:16 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Add MS_WIN64 macro when built on amd64 + mingw.
  ........
    r6168 | cdavid | 2008-12-19 18:57:06 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Forgot to import get_build_architecture.
  ........
    r6169 | cdavid | 2008-12-19 18:57:52 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Use a tuple when defining the MS_WIN64 macro.
  ........
    r6170 | cdavid | 2008-12-19 19:05:03 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Fix macro def.
  ........
    r6171 | cdavid | 2008-12-19 19:21:54 +0900 (Fri, 19 Dec 2008) | 2 lines
    
    Do not use g++ for linking on amd64.
  ........
    r6172 | cdavid | 2008-12-19 19:25:18 +0900 (Fri, 19 Dec 2008) | 1 line
    
    do not regenerate the import library if already there.
  ........
    r6173 | cdavid | 2008-12-19 19:28:39 +0900 (Fri, 19 Dec 2008) | 1 line
    
    Add one full msvcrt version for 80 (for manifest generation).
  ........
    r6176 | cdavid | 2008-12-21 02:31:48 +0900 (Sun, 21 Dec 2008) | 1 line
    
    Remove optimization flags for now, to speed up builds.
  ........
    r6177 | cdavid | 2008-12-21 02:32:11 +0900 (Sun, 21 Dec 2008) | 1 line
    
    Add MS_WIN64 for every compile command.
  ........
    r6178 | cdavid | 2008-12-21 02:32:33 +0900 (Sun, 21 Dec 2008) | 1 line
    
    Remove handling of MS_WIN64 in commands: deal with it in mingw tool only.
  ........
    r6184 | cdavid | 2008-12-21 16:46:28 +0900 (Sun, 21 Dec 2008) | 1 line
    
    Hardcode size of long double, because it is broken with mingw.
  ........
................
  r6442 | cdavid | 2009-02-22 02:36:15 +0900 (Sun, 22 Feb 2009) | 1 line
  
  Re-enable real check for long double size.
................



Property changes on: branches/coremath
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/distutils-revamp:1-2752 /branches/dynamic_cpu_configuration:1-6101 /branches/fix_float_format:1-6359 /branches/multicore:1-3687 /branches/numpy-mingw-w64:1-6150 /branches/visualstudio_manifest:1-6077 /trunk:1-6373
   + /branches/distutils-revamp:1-2752 /branches/dynamic_cpu_configuration:1-6101 /branches/fix_float_format:1-6359 /branches/multicore:1-3687 /branches/numpy-mingw-w64:1-6150 /branches/visualstudio_manifest:1-6077 /trunk:1-6443

Modified: branches/coremath/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- branches/coremath/numpy/core/include/numpy/ndarrayobject.h	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/core/include/numpy/ndarrayobject.h	2009-02-22 03:41:06 UTC (rev 6445)
@@ -1627,12 +1627,12 @@
 
 #define PyArray_GETITEM(obj,itemptr)                                          \
         ((PyArrayObject *)(obj))->descr->f->getitem((char *)(itemptr),        \
-                                                 (PyArrayObject *)(obj));
+                                                 (PyArrayObject *)(obj))
 
 #define PyArray_SETITEM(obj,itemptr,v)                                        \
         ((PyArrayObject *)(obj))->descr->f->setitem((PyObject *)(v),          \
                                                     (char *)(itemptr),        \
-                                                    (PyArrayObject *)(obj));
+                                                    (PyArrayObject *)(obj))
 
 
 #define PyTypeNum_ISBOOL(type) ((type) == NPY_BOOL)

Modified: branches/coremath/numpy/core/src/arrayobject.c
===================================================================
--- branches/coremath/numpy/core/src/arrayobject.c	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/core/src/arrayobject.c	2009-02-22 03:41:06 UTC (rev 6445)
@@ -5099,157 +5099,157 @@
     int typenum;
 
     switch (cmp_op) {
-        case Py_LT:
-            result = PyArray_GenericBinaryFunction(self, other,
-                    n_ops.less);
-            break;
-        case Py_LE:
-            result = PyArray_GenericBinaryFunction(self, other,
-                    n_ops.less_equal);
-            break;
-        case Py_EQ:
-            if (other == Py_None) {
+    case Py_LT:
+        result = PyArray_GenericBinaryFunction(self, other,
+                n_ops.less);
+        break;
+    case Py_LE:
+        result = PyArray_GenericBinaryFunction(self, other,
+                n_ops.less_equal);
+        break;
+    case Py_EQ:
+        if (other == Py_None) {
+            Py_INCREF(Py_False);
+            return Py_False;
+        }
+        /* Try to convert other to an array */
+        if (!PyArray_Check(other)) {
+            typenum = self->descr->type_num;
+            if (typenum != PyArray_OBJECT) {
+                typenum = PyArray_NOTYPE;
+            }
+            array_other = PyArray_FromObject(other,
+                    typenum, 0, 0);
+            /*
+             * If not successful, then return False. This fixes code
+             * that used to allow equality comparisons between arrays
+             * and other objects which would give a result of False.
+             */
+            if ((array_other == NULL) ||
+                    (array_other == Py_None)) {
+                Py_XDECREF(array_other);
+                PyErr_Clear();
                 Py_INCREF(Py_False);
                 return Py_False;
             }
-            /* Try to convert other to an array */
-            if (!PyArray_Check(other)) {
-                typenum = self->descr->type_num;
-                if (typenum != PyArray_OBJECT) {
-                    typenum = PyArray_NOTYPE;
-                }
-                array_other = PyArray_FromObject(other,
-                        typenum, 0, 0);
-                /*
-                 * If not successful, then return False. This fixes code
-                 * that used to allow equality comparisons between arrays
-                 * and other objects which would give a result of False.
-                 */
-                if ((array_other == NULL) ||
-                        (array_other == Py_None)) {
-                    Py_XDECREF(array_other);
-                    PyErr_Clear();
-                    Py_INCREF(Py_False);
-                    return Py_False;
-                }
+        }
+        else {
+            Py_INCREF(other);
+            array_other = other;
+        }
+        result = PyArray_GenericBinaryFunction(self,
+                array_other,
+                n_ops.equal);
+        if ((result == Py_NotImplemented) &&
+                (self->descr->type_num == PyArray_VOID)) {
+            int _res;
+
+            _res = PyObject_RichCompareBool
+                ((PyObject *)self->descr,
+                 (PyObject *)\
+                 PyArray_DESCR(array_other),
+                 Py_EQ);
+            if (_res < 0) {
+                Py_DECREF(result);
+                Py_DECREF(array_other);
+                return NULL;
             }
-            else {
-                Py_INCREF(other);
-                array_other = other;
+            if (_res) {
+                Py_DECREF(result);
+                result = _void_compare
+                    (self,
+                     (PyArrayObject *)array_other,
+                     cmp_op);
+                Py_DECREF(array_other);
             }
-            result = PyArray_GenericBinaryFunction(self,
-                    array_other,
-                    n_ops.equal);
-            if ((result == Py_NotImplemented) &&
-                    (self->descr->type_num == PyArray_VOID)) {
-                int _res;
-
-                _res = PyObject_RichCompareBool
-                       ((PyObject *)self->descr,
-                        (PyObject *)\
-                        PyArray_DESCR(array_other),
-                        Py_EQ);
-                if (_res < 0) {
-                    Py_DECREF(result);
-                    Py_DECREF(array_other);
-                    return NULL;
-                }
-                if (_res) {
-                    Py_DECREF(result);
-                    result = _void_compare
-                             (self,
-                              (PyArrayObject *)array_other,
-                              cmp_op);
-                    Py_DECREF(array_other);
-                }
-                return result;
+            return result;
+        }
+        /*
+         * If the comparison results in NULL, then the
+         * two array objects can not be compared together so
+         * return zero
+         */
+        Py_DECREF(array_other);
+        if (result == NULL) {
+            PyErr_Clear();
+            Py_INCREF(Py_False);
+            return Py_False;
+        }
+        break;
+    case Py_NE:
+        if (other == Py_None) {
+            Py_INCREF(Py_True);
+            return Py_True;
+        }
+        /* Try to convert other to an array */
+        if (!PyArray_Check(other)) {
+            typenum = self->descr->type_num;
+            if (typenum != PyArray_OBJECT) {
+                typenum = PyArray_NOTYPE;
             }
+            array_other = PyArray_FromObject(other, typenum, 0, 0);
             /*
-             * If the comparison results in NULL, then the
-             * two array objects can not be compared together so
-             * return zero
+             * If not successful, then objects cannot be
+             * compared and cannot be equal, therefore,
+             * return True;
              */
-            Py_DECREF(array_other);
-            if (result == NULL) {
+            if ((array_other == NULL) || (array_other == Py_None)) {
+                Py_XDECREF(array_other);
                 PyErr_Clear();
-                Py_INCREF(Py_False);
-                return Py_False;
-            }
-            break;
-        case Py_NE:
-            if (other == Py_None) {
                 Py_INCREF(Py_True);
                 return Py_True;
             }
-            /* Try to convert other to an array */
-            if (!PyArray_Check(other)) {
-                typenum = self->descr->type_num;
-                if (typenum != PyArray_OBJECT) {
-                    typenum = PyArray_NOTYPE;
-                }
-                array_other = PyArray_FromObject(other, typenum, 0, 0);
-                /*
-                 * If not successful, then objects cannot be
-                 * compared and cannot be equal, therefore,
-                 * return True;
-                 */
-                if ((array_other == NULL) || (array_other == Py_None)) {
-                    Py_XDECREF(array_other);
-                    PyErr_Clear();
-                    Py_INCREF(Py_True);
-                    return Py_True;
-                }
+        }
+        else {
+            Py_INCREF(other);
+            array_other = other;
+        }
+        result = PyArray_GenericBinaryFunction(self,
+                array_other,
+                n_ops.not_equal);
+        if ((result == Py_NotImplemented) &&
+                (self->descr->type_num == PyArray_VOID)) {
+            int _res;
+
+            _res = PyObject_RichCompareBool(
+                    (PyObject *)self->descr,
+                    (PyObject *)
+                    PyArray_DESCR(array_other),
+                    Py_EQ);
+            if (_res < 0) {
+                Py_DECREF(result);
+                Py_DECREF(array_other);
+                return NULL;
             }
-            else {
-                Py_INCREF(other);
-                array_other = other;
+            if (_res) {
+                Py_DECREF(result);
+                result = _void_compare(
+                        self,
+                        (PyArrayObject *)array_other,
+                        cmp_op);
+                Py_DECREF(array_other);
             }
-            result = PyArray_GenericBinaryFunction(self,
-                    array_other,
-                    n_ops.not_equal);
-            if ((result == Py_NotImplemented) &&
-                    (self->descr->type_num == PyArray_VOID)) {
-                int _res;
+            return result;
+        }
 
-                _res = PyObject_RichCompareBool(
-                        (PyObject *)self->descr,
-                        (PyObject *)
-                        PyArray_DESCR(array_other),
-                        Py_EQ);
-                if (_res < 0) {
-                    Py_DECREF(result);
-                    Py_DECREF(array_other);
-                    return NULL;
-                }
-                if (_res) {
-                    Py_DECREF(result);
-                    result = _void_compare(
-                              self,
-                              (PyArrayObject *)array_other,
-                              cmp_op);
-                    Py_DECREF(array_other);
-                }
-                return result;
-            }
-
-            Py_DECREF(array_other);
-            if (result == NULL) {
-                PyErr_Clear();
-                Py_INCREF(Py_True);
-                return Py_True;
-            }
-            break;
-        case Py_GT:
-            result = PyArray_GenericBinaryFunction(self, other,
-                    n_ops.greater);
-            break;
-        case Py_GE:
-            result = PyArray_GenericBinaryFunction(self, other,
-                    n_ops.greater_equal);
-            break;
-        default:
-            result = Py_NotImplemented;
-            Py_INCREF(result);
+        Py_DECREF(array_other);
+        if (result == NULL) {
+            PyErr_Clear();
+            Py_INCREF(Py_True);
+            return Py_True;
+        }
+        break;
+    case Py_GT:
+        result = PyArray_GenericBinaryFunction(self, other,
+                n_ops.greater);
+        break;
+    case Py_GE:
+        result = PyArray_GenericBinaryFunction(self, other,
+                n_ops.greater_equal);
+        break;
+    default:
+        result = Py_NotImplemented;
+        Py_INCREF(result);
     }
     if (result == Py_NotImplemented) {
         /* Try to handle string comparisons */
@@ -5612,22 +5612,23 @@
     return;
 }
 
-/* This routine checks to see if newstrides (of length nd) will not
-   ever be able to walk outside of the memory implied numbytes and offset.
+/*
+ * This routine checks to see if newstrides (of length nd) will not
+ * ever be able to walk outside of the memory implied numbytes and offset.
+ *
+ * The available memory is assumed to start at -offset and proceed
+ * to numbytes-offset.  The strides are checked to ensure
+ * that accessing memory using striding will not try to reach beyond
+ * this memory for any of the axes.
+ *
+ * If numbytes is 0 it will be calculated using the dimensions and
+ * element-size.
+ *
+ * This function checks for walking beyond the beginning and right-end
+ * of the buffer and therefore works for any integer stride (positive
+ * or negative).
+ */
 
-   The available memory is assumed to start at -offset and proceed
-   to numbytes-offset.  The strides are checked to ensure
-   that accessing memory using striding will not try to reach beyond
-   this memory for any of the axes.
-
-   If numbytes is 0 it will be calculated using the dimensions and
-   element-size.
-
-   This function checks for walking beyond the beginning and right-end
-   of the buffer and therefore works for any integer stride (positive
-   or negative).
-*/
-
 /*NUMPY_API*/
 static Bool
 PyArray_CheckStrides(int elsize, int nd, intp numbytes, intp offset,
@@ -5638,37 +5639,38 @@
     intp begin;
     intp end;
 
-    if (numbytes == 0)
+    if (numbytes == 0) {
         numbytes = PyArray_MultiplyList(dims, nd) * elsize;
-
+    }
     begin = -offset;
     end = numbytes - offset - elsize;
-    for(i=0; i<nd; i++) {
-        byte_begin = newstrides[i]*(dims[i]-1);
-        if ((byte_begin < begin) || (byte_begin > end))
+    for (i = 0; i < nd; i++) {
+        byte_begin = newstrides[i]*(dims[i] - 1);
+        if ((byte_begin < begin) || (byte_begin > end)) {
             return FALSE;
+        }
     }
     return TRUE;
-
 }
 
 
-/* This is the main array creation routine. */
+/*
+ * This is the main array creation routine.
+ *
+ * Flags argument has multiple related meanings
+ * depending on data and strides:
+ *
+ * If data is given, then flags is flags associated with data.
+ * If strides is not given, then a contiguous strides array will be created
+ * and the CONTIGUOUS bit will be set.  If the flags argument
+ * has the FORTRAN bit set, then a FORTRAN-style strides array will be
+ * created (and of course the FORTRAN flag bit will be set).
+ *
+ * If data is not given but created here, then flags will be DEFAULT
+ * and a non-zero flags argument can be used to indicate a FORTRAN style
+ * array is desired.
+ */
 
-/* Flags argument has multiple related meanings
-   depending on data and strides:
-
-   If data is given, then flags is flags associated with data.
-   If strides is not given, then a contiguous strides array will be created
-   and the CONTIGUOUS bit will be set.  If the flags argument
-   has the FORTRAN bit set, then a FORTRAN-style strides array will be
-   created (and of course the FORTRAN flag bit will be set).
-
-   If data is not given but created here, then flags will be DEFAULT
-   and a non-zero flags argument can be used to indicate a FORTRAN style
-   array is desired.
-*/
-
 static size_t
 _array_fill_strides(intp *strides, intp *dims, int nd, size_t itemsize,
                     int inflag, int *objflags)
@@ -5676,29 +5678,37 @@
     int i;
     /* Only make Fortran strides if not contiguous as well */
     if ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {
-        for(i=0; i<nd; i++) {
+        for (i = 0; i < nd; i++) {
             strides[i] = itemsize;
             itemsize *= dims[i] ? dims[i] : 1;
         }
         *objflags |= FORTRAN;
-        if (nd > 1) *objflags &= ~CONTIGUOUS;
-        else *objflags |= CONTIGUOUS;
+        if (nd > 1) {
+            *objflags &= ~CONTIGUOUS;
+        }
+        else {
+            *objflags |= CONTIGUOUS;
+        }
     }
     else {
-        for(i=nd-1;i>=0;i--) {
+        for (i = nd - 1; i >= 0; i--) {
             strides[i] = itemsize;
             itemsize *= dims[i] ? dims[i] : 1;
         }
         *objflags |= CONTIGUOUS;
-        if (nd > 1) *objflags &= ~FORTRAN;
-        else *objflags |= FORTRAN;
+        if (nd > 1) {
+            *objflags &= ~FORTRAN;
+        }
+        else {
+            *objflags |= FORTRAN;
+        }
     }
     return itemsize;
 }
 
 /*NUMPY_API
-  Generic new array creation routine.
-*/
+ * Generic new array creation routine.
+ */
 static PyObject *
 PyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,
             intp *strides, void *data, int itemsize, int flags,
@@ -5708,7 +5718,9 @@
     PyObject *new;
 
     descr = PyArray_DescrFromType(type_num);
-    if (descr == NULL) return NULL;
+    if (descr == NULL) {
+        return NULL;
+    }
     if (descr->elsize == 0) {
         if (itemsize < 1) {
             PyErr_SetString(PyExc_ValueError,
@@ -5724,14 +5736,16 @@
     return new;
 }
 
-/* Change a sub-array field to the base descriptor */
-/*  and update the dimensions and strides
-    appropriately.  Dimensions and strides are added
-    to the end unless we have a FORTRAN array
-    and then they are added to the beginning
-
-    Strides are only added if given (because data is given).
-*/
+/*
+ * Change a sub-array field to the base descriptor
+ *
+ * and update the dimensions and strides
+ * appropriately.  Dimensions and strides are added
+ * to the end unless we have a FORTRAN array
+ * and then they are added to the beginning
+ *
+ * Strides are only added if given (because data is given).
+ */
 static int
 _update_descr_and_dimensions(PyArray_Descr **des, intp *newdims,
                              intp *newstrides, int oldnd, int isfortran)
@@ -5758,16 +5772,17 @@
 
 
     newnd = oldnd + numnew;
-    if (newnd > MAX_DIMS) goto finish;
+    if (newnd > MAX_DIMS) {
+        goto finish;
+    }
     if (isfortran) {
         memmove(newdims+numnew, newdims, oldnd*sizeof(intp));
         mydim = newdims;
     }
-
     if (tuple) {
-        for(i=0; i<numnew; i++) {
-            mydim[i] = (intp) PyInt_AsLong                  \
-                (PyTuple_GET_ITEM(old->subarray->shape, i));
+        for (i = 0; i < numnew; i++) {
+            mydim[i] = (intp) PyInt_AsLong(
+                    PyTuple_GET_ITEM(old->subarray->shape, i));
         }
     }
     else {
@@ -5777,15 +5792,15 @@
     if (newstrides) {
         intp tempsize;
         intp *mystrides;
+
         mystrides = newstrides + oldnd;
         if (isfortran) {
-            memmove(newstrides+numnew, newstrides,
-                    oldnd*sizeof(intp));
+            memmove(newstrides+numnew, newstrides, oldnd*sizeof(intp));
             mystrides = newstrides;
         }
         /* Make new strides -- alwasy C-contiguous */
         tempsize = (*des)->elsize;
-        for(i=numnew-1; i>=0; i--) {
+        for (i = numnew - 1; i >= 0; i--) {
             mystrides[i] = tempsize;
             tempsize *= mydim[i] ? mydim[i] : 1;
         }
@@ -5798,10 +5813,11 @@
 }
 
 
-/* steals a reference to descr (even on failure) */
 /*NUMPY_API
-  Generic new array creation routine.
-*/
+ * Generic new array creation routine.
+ *
+ * steals a reference to descr (even on failure)
+ */
 static PyObject *
 PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd,
                      intp *dims, intp *strides, void *data,
@@ -5816,9 +5832,9 @@
     if (descr->subarray) {
         PyObject *ret;
         intp newdims[2*MAX_DIMS];
-        intp *newstrides=NULL;
-        int isfortran=0;
-        isfortran = (data && (flags & FORTRAN) && !(flags & CONTIGUOUS)) || \
+        intp *newstrides = NULL;
+        int isfortran = 0;
+        isfortran = (data && (flags & FORTRAN) && !(flags & CONTIGUOUS)) ||
             (!data && flags);
         memcpy(newdims, dims, nd*sizeof(intp));
         if (strides) {
@@ -5832,7 +5848,6 @@
                                    data, flags, obj);
         return ret;
     }
-
     if (nd < 0) {
         PyErr_SetString(PyExc_ValueError,
                         "number of dimensions must be >=0");
@@ -5856,13 +5871,19 @@
             return NULL;
         }
         PyArray_DESCR_REPLACE(descr);
-        if (descr->type_num == NPY_STRING) descr->elsize = 1;
-        else descr->elsize = sizeof(PyArray_UCS4);
+        if (descr->type_num == NPY_STRING) {
+            descr->elsize = 1;
+        }
+        else {
+            descr->elsize = sizeof(PyArray_UCS4);
+        }
         sd = (size_t) descr->elsize;
     }
     largest = MAX_INTP / sd;
-    for(i=0;i<nd;i++) {
-        if (dims[i] == 0) continue;
+    for (i = 0; i < nd; i++) {
+        if (dims[i] == 0) {
+            continue;
+        }
         if (dims[i] < 0) {
             PyErr_SetString(PyExc_ValueError,
                             "negative dimensions "  \
@@ -5891,12 +5912,15 @@
         self->flags = DEFAULT;
         if (flags) {
             self->flags |= FORTRAN;
-            if (nd > 1) self->flags &= ~CONTIGUOUS;
+            if (nd > 1) {
+                self->flags &= ~CONTIGUOUS;
+            }
             flags = FORTRAN;
         }
     }
-    else self->flags = (flags & ~UPDATEIFCOPY);
-
+    else {
+        self->flags = (flags & ~UPDATEIFCOPY);
+    }
     self->descr = descr;
     self->base = (PyObject *)NULL;
     self->weakreflist = (PyObject *)NULL;
@@ -5913,84 +5937,102 @@
             sd = _array_fill_strides(self->strides, dims, nd, sd,
                                      flags, &(self->flags));
         }
-        else { /* we allow strides even when we create
-                  the memory, but be careful with this...
-               */
+        else {
+            /*
+             * we allow strides even when we create
+             * the memory, but be careful with this...
+             */
             memcpy(self->strides, strides, sizeof(intp)*nd);
             sd *= size;
         }
     }
-    else { self->dimensions = self->strides = NULL; }
+    else {
+        self->dimensions = self->strides = NULL;
+    }
 
     if (data == NULL) {
+        /*
+         * Allocate something even for zero-space arrays
+         * e.g. shape=(0,) -- otherwise buffer exposure
+         * (a.data) doesn't work as it should.
+         */
 
-        /* Allocate something even for zero-space arrays
-           e.g. shape=(0,) -- otherwise buffer exposure
-           (a.data) doesn't work as it should. */
-
-        if (sd==0) sd = descr->elsize;
-
-        if ((data = PyDataMem_NEW(sd))==NULL) {
+        if (sd == 0) {
+            sd = descr->elsize;
+        }
+        if ((data = PyDataMem_NEW(sd)) == NULL) {
             PyErr_NoMemory();
             goto fail;
         }
         self->flags |= OWNDATA;
 
-        /* It is bad to have unitialized OBJECT pointers */
-        /* which could also be sub-fields of a VOID array */
+        /*
+         * It is bad to have unitialized OBJECT pointers
+         * which could also be sub-fields of a VOID array
+         */
         if (PyDataType_FLAGCHK(descr, NPY_NEEDS_INIT)) {
             memset(data, 0, sd);
         }
     }
     else {
-        self->flags &= ~OWNDATA;  /* If data is passed in,
-                                     this object won't own it
-                                     by default.
-                                     Caller must arrange for
-                                     this to be reset if truly
-                                     desired */
+        /*
+         * If data is passed in, this object won't own it by default.
+         * Caller must arrange for this to be reset if truly desired
+         */
+        self->flags &= ~OWNDATA;
     }
     self->data = data;
 
-    /* call the __array_finalize__
-       method if a subtype.
-       If obj is NULL, then call method with Py_None
-    */
+    /*
+     * call the __array_finalize__
+     * method if a subtype.
+     * If obj is NULL, then call method with Py_None
+     */
     if ((subtype != &PyArray_Type)) {
         PyObject *res, *func, *args;
-        static PyObject *str=NULL;
+        static PyObject *str = NULL;
 
         if (str == NULL) {
             str = PyString_InternFromString("__array_finalize__");
         }
         func = PyObject_GetAttr((PyObject *)self, str);
         if (func && func != Py_None) {
-            if (strides != NULL) { /* did not allocate own data
-                                      or funny strides */
-                /* update flags before finalize function */
+            if (strides != NULL) {
+                /*
+                 * did not allocate own data or funny strides
+                 * update flags before finalize function
+                 */
                 PyArray_UpdateFlags(self, UPDATE_ALL);
             }
-            if PyCObject_Check(func) { /* A C-function is stored here */
-                    PyArray_FinalizeFunc *cfunc;
-                    cfunc = PyCObject_AsVoidPtr(func);
-                    Py_DECREF(func);
-                    if (cfunc(self, obj) < 0) goto fail;
+            if PyCObject_Check(func) {
+                /* A C-function is stored here */
+                PyArray_FinalizeFunc *cfunc;
+                cfunc = PyCObject_AsVoidPtr(func);
+                Py_DECREF(func);
+                if (cfunc(self, obj) < 0) {
+                    goto fail;
                 }
+            }
             else {
                 args = PyTuple_New(1);
-                if (obj == NULL) obj=Py_None;
+                if (obj == NULL) {
+                    obj=Py_None;
+                }
                 Py_INCREF(obj);
                 PyTuple_SET_ITEM(args, 0, obj);
                 res = PyObject_Call(func, args, NULL);
                 Py_DECREF(args);
                 Py_DECREF(func);
-                if (res == NULL) goto fail;
-                else Py_DECREF(res);
+                if (res == NULL) {
+                    goto fail;
+                }
+                else {
+                    Py_DECREF(res);
+                }
             }
         }
         else Py_XDECREF(func);
     }
-
     return (PyObject *)self;
 
  fail:
@@ -6005,14 +6047,17 @@
         memset(optr, 0, dtype->elsize);
     }
     else if (PyDescr_HASFIELDS(dtype)) {
-        PyObject *key, *value, *title=NULL;
+        PyObject *key, *value, *title = NULL;
         PyArray_Descr *new;
         int offset;
-        Py_ssize_t pos=0;
+        Py_ssize_t pos = 0;
         while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
-	    if NPY_TITLE_KEY(key, value) continue;
-            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
-                                  &title)) return;
+	    if NPY_TITLE_KEY(key, value) {
+                continue;
+            }
+            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset, &title)) {
+                return;
+            }
             _putzero(optr + offset, zero, new);
         }
     }
@@ -6027,13 +6072,11 @@
 
 
 /*NUMPY_API
-  Resize (reallocate data).  Only works if nothing else is referencing
-  this array and it is contiguous.
-  If refcheck is 0, then the reference count is not checked
-  and assumed to be 1.
-  You still must own this data and have no weak-references and no base
-  object.
-*/
+ * Resize (reallocate data).  Only works if nothing else is referencing this
+ * array and it is contiguous.  If refcheck is 0, then the reference count is
+ * not checked and assumed to be 1.  You still must own this data and have no
+ * weak-references and no base object.
+ */
 static PyObject *
 PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
                NPY_ORDER fortran)
@@ -6054,9 +6097,9 @@
         return NULL;
     }
 
-    if (fortran == PyArray_ANYORDER)
+    if (fortran == PyArray_ANYORDER) {
         fortran = PyArray_CORDER;
-
+    }
     if (self->descr->elsize == 0) {
         PyErr_SetString(PyExc_ValueError, "Bad data-type size.");
         return NULL;
@@ -6064,7 +6107,9 @@
     newsize = 1;
     largest = MAX_INTP / self->descr->elsize;
     for(k=0; k<new_nd; k++) {
-        if (new_dimensions[k]==0) break;
+        if (new_dimensions[k]==0) {
+            break;
+        }
         if (new_dimensions[k] < 0) {
             PyErr_SetString(PyExc_ValueError,
                             "negative dimensions not allowed");
@@ -6085,9 +6130,13 @@
             return NULL;
         }
 
-        if (refcheck) refcnt = REFCOUNT(self);
-        else refcnt = 1;
-        if ((refcnt > 2) || (self->base != NULL) ||     \
+        if (refcheck) {
+            refcnt = REFCOUNT(self);
+        }
+        else {
+            refcnt = 1;
+        }
+        if ((refcnt > 2) || (self->base != NULL) ||
             (self->weakreflist != NULL)) {
             PyErr_SetString(PyExc_ValueError,
                             "cannot resize an array that has "\
@@ -6097,8 +6146,12 @@
             return NULL;
         }
 
-        if (newsize == 0) sd = self->descr->elsize;
-        else sd = newsize * self->descr->elsize;
+        if (newsize == 0) {
+            sd = self->descr->elsize;
+        }
+        else {
+            sd = newsize*self->descr->elsize;
+        }
         /* Reallocate space if needed */
         new_data = PyDataMem_RENEW(self->data, sd);
         if (new_data == NULL) {
@@ -6117,21 +6170,20 @@
             char *optr;
             optr = self->data + oldsize*elsize;
             n = newsize - oldsize;
-            for(k=0; k<n; k++) {
+            for (k = 0; k < n; k++) {
                 _putzero((char *)optr, zero, self->descr);
                 optr += elsize;
             }
             Py_DECREF(zero);
         }
         else{
-            memset(self->data+oldsize*elsize, 0,
-                   (newsize-oldsize)*elsize);
+            memset(self->data+oldsize*elsize, 0, (newsize-oldsize)*elsize);
         }
     }
 
-    if (self->nd != new_nd) {  /* Different number of dimensions. */
+    if (self->nd != new_nd) {
+        /* Different number of dimensions. */
         self->nd = new_nd;
-
         /* Need new dimensions and strides arrays */
         dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);
         if (dimptr == NULL) {
@@ -6148,42 +6200,44 @@
     sd = (size_t) self->descr->elsize;
     sd = (size_t) _array_fill_strides(new_strides, new_dimensions, new_nd, sd,
                                       self->flags, &(self->flags));
-
     memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));
     memmove(self->strides, new_strides, new_nd*sizeof(intp));
-
     Py_INCREF(Py_None);
     return Py_None;
-
 }
 
 static void
 _fillobject(char *optr, PyObject *obj, PyArray_Descr *dtype)
 {
     if (!PyDataType_FLAGCHK(dtype, NPY_ITEM_REFCOUNT)) {
-        if ((obj == Py_None) ||
-            (PyInt_Check(obj) && PyInt_AsLong(obj)==0))
+        if ((obj == Py_None) || (PyInt_Check(obj) && PyInt_AsLong(obj)==0)) {
             return;
+        }
         else {
             PyObject *arr;
             Py_INCREF(dtype);
             arr = PyArray_NewFromDescr(&PyArray_Type, dtype,
                                        0, NULL, NULL, NULL,
                                        0, NULL);
-            if (arr!=NULL)
+            if (arr!=NULL) {
                 dtype->f->setitem(obj, optr, arr);
+            }
             Py_XDECREF(arr);
         }
     }
     else if (PyDescr_HASFIELDS(dtype)) {
-        PyObject *key, *value, *title=NULL;
+        PyObject *key, *value, *title = NULL;
         PyArray_Descr *new;
         int offset;
-        Py_ssize_t pos=0;
+        Py_ssize_t pos = 0;
+
         while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
-	    if NPY_TITLE_KEY(key, value) continue;
-            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
-                                  &title)) return;
+	    if NPY_TITLE_KEY(key, value) {
+                continue;
+            }
+            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset, &title)) {
+                return;
+            }
             _fillobject(optr + offset, obj, new);
         }
     }
@@ -6196,8 +6250,9 @@
     }
 }
 
-/* Assumes contiguous */
-/*NUMPY_API*/
+/*NUMPY_API
+ * Assumes contiguous
+ */
 static void
 PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)
 {
@@ -6208,12 +6263,12 @@
         optr = (PyObject **)(arr->data);
         n = PyArray_SIZE(arr);
         if (obj == NULL) {
-            for(i=0; i<n; i++) {
+            for (i = 0; i < n; i++) {
                 *optr++ = NULL;
             }
         }
         else {
-            for(i=0; i<n; i++) {
+            for (i = 0; i < n; i++) {
                 Py_INCREF(obj);
                 *optr++ = obj;
             }
@@ -6222,7 +6277,7 @@
     else {
         char *optr;
         optr = arr->data;
-        for(i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             _fillobject(optr, obj, arr->descr);
             optr += arr->descr->elsize;
         }
@@ -6250,7 +6305,9 @@
         descr = PyArray_DESCR(arr);
         Py_INCREF(descr);
         newarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED, NULL);
-        if (newarr == NULL) return -1;
+        if (newarr == NULL) {
+            return -1;
+        }
         fromptr = PyArray_DATA(newarr);
         swap = (PyArray_ISNOTSWAPPED(arr) != PyArray_ISNOTSWAPPED(newarr));
     }
@@ -6280,7 +6337,7 @@
             Py_XDECREF(newarr);
             return -1;
         }
-        while(size--) {
+        while (size--) {
             copyswap(iter->dataptr, fromptr, swap, arr);
             PyArray_ITER_NEXT(iter);
         }
@@ -6307,14 +6364,11 @@
     PyArrayObject *ret;
 
     buffer.ptr = NULL;
-    /* Usually called with shape and type
-       but can also be called with buffer, strides, and swapped info
-    */
-
-    /* For now, let's just use this to create an empty, contiguous
-       array of a specific type and shape.
-    */
-
+    /*
+     * Usually called with shape and type but can also be called with buffer,
+     * strides, and swapped info For now, let's just use this to create an
+     * empty, contiguous array of a specific type and shape.
+     */
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&O&LO&O&",
                                      kwlist, PyArray_IntpConverter,
                                      &dims,
@@ -6326,16 +6380,17 @@
                                      &PyArray_IntpConverter,
                                      &strides,
                                      &PyArray_OrderConverter,
-                                     &order))
+                                     &order)) {
         goto fail;
-
-    if (order == PyArray_FORTRANORDER) fortran = 1;
-
-    if (descr == NULL)
+    }
+    if (order == PyArray_FORTRANORDER) {
+        fortran = 1;
+    }
+    if (descr == NULL) {
         descr = PyArray_DescrFromType(PyArray_DEFAULT);
+    }
 
     itemsize = descr->elsize;
-
     if (itemsize == 0) {
         PyErr_SetString(PyExc_ValueError,
                         "data-type with unspecified variable length");
@@ -6373,27 +6428,31 @@
     }
 
     if (buffer.ptr == NULL) {
-        ret = (PyArrayObject *)                         \
+        ret = (PyArrayObject *)
             PyArray_NewFromDescr(subtype, descr,
                                  (int)dims.len,
                                  dims.ptr,
                                  strides.ptr, NULL, fortran, NULL);
-        if (ret == NULL) {descr=NULL;goto fail;}
+        if (ret == NULL) {
+            descr = NULL;
+            goto fail;
+        }
         if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT)) {
             /* place Py_None in object positions */
             PyArray_FillObjectArray(ret, Py_None);
             if (PyErr_Occurred()) {
-                descr=NULL;
+                descr = NULL;
                 goto fail;
             }
         }
     }
-    else {  /* buffer given -- use it */
+    else {
+        /* buffer given -- use it */
         if (dims.len == 1 && dims.ptr[0] == -1) {
             dims.ptr[0] = (buffer.len-(intp)offset) / itemsize;
         }
-        else if ((strides.ptr == NULL) && \
-                 (buffer.len < ((intp)itemsize)*                \
+        else if ((strides.ptr == NULL) &&
+                 (buffer.len < ((intp)itemsize)*
                   PyArray_MultiplyList(dims.ptr, dims.len))) {
             PyErr_SetString(PyExc_TypeError,
                             "buffer is too small for "      \
@@ -6401,27 +6460,38 @@
             goto fail;
         }
         /* get writeable and aligned */
-        if (fortran) buffer.flags |= FORTRAN;
+        if (fortran) {
+            buffer.flags |= FORTRAN;
+        }
         ret = (PyArrayObject *)\
             PyArray_NewFromDescr(subtype, descr,
                                  dims.len, dims.ptr,
                                  strides.ptr,
                                  offset + (char *)buffer.ptr,
                                  buffer.flags, NULL);
-        if (ret == NULL) {descr=NULL; goto fail;}
+        if (ret == NULL) {
+            descr = NULL;
+            goto fail;
+        }
         PyArray_UpdateFlags(ret, UPDATE_ALL);
         ret->base = buffer.base;
         Py_INCREF(buffer.base);
     }
 
     PyDimMem_FREE(dims.ptr);
-    if (strides.ptr) PyDimMem_FREE(strides.ptr);
+    if (strides.ptr) {
+        PyDimMem_FREE(strides.ptr);
+    }
     return (PyObject *)ret;
 
  fail:
     Py_XDECREF(descr);
-    if (dims.ptr) PyDimMem_FREE(dims.ptr);
-    if (strides.ptr) PyDimMem_FREE(strides.ptr);
+    if (dims.ptr) {
+        PyDimMem_FREE(dims.ptr);
+    }
+    if (strides.ptr) {
+        PyDimMem_FREE(strides.ptr);
+    }
     return NULL;
 }
 
@@ -6467,7 +6537,9 @@
 
     /* Assumes C-order */
     ret = PyArray_Reshape(self, val);
-    if (ret == NULL) return -1;
+    if (ret == NULL) {
+        return -1;
+    }
     if (PyArray_DATA(ret) != PyArray_DATA(self)) {
         Py_DECREF(ret);
         PyErr_SetString(PyExc_AttributeError,
@@ -6480,7 +6552,8 @@
     PyDimMem_FREE(self->dimensions);
     nd = PyArray_NDIM(ret);
     self->nd = nd;
-    if (nd > 0) {  /* create new dimensions and strides */
+    if (nd > 0) {
+        /* create new dimensions and strides */
         self->dimensions = PyDimMem_NEW(2*nd);
         if (self->dimensions == NULL) {
             Py_DECREF(ret);
@@ -6488,12 +6561,13 @@
             return -1;
         }
         self->strides = self->dimensions + nd;
-        memcpy(self->dimensions, PyArray_DIMS(ret),
-               nd*sizeof(intp));
-        memcpy(self->strides, PyArray_STRIDES(ret),
-               nd*sizeof(intp));
+        memcpy(self->dimensions, PyArray_DIMS(ret), nd*sizeof(intp));
+        memcpy(self->strides, PyArray_STRIDES(ret), nd*sizeof(intp));
     }
-    else {self->dimensions=NULL; self->strides=NULL;}
+    else {
+        self->dimensions = NULL;
+        self->strides = NULL;
+    }
     Py_DECREF(ret);
     PyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);
     return 0;
@@ -6511,12 +6585,12 @@
 {
     PyArray_Dims newstrides = {NULL, 0};
     PyArrayObject *new;
-    intp numbytes=0;
-    intp offset=0;
+    intp numbytes = 0;
+    intp offset = 0;
     Py_ssize_t buf_len;
     char *buf;
 
-    if (!PyArray_IntpConverter(obj, &newstrides) || \
+    if (!PyArray_IntpConverter(obj, &newstrides) ||
         newstrides.ptr == NULL) {
         PyErr_SetString(PyExc_TypeError, "invalid strides");
         return -1;
@@ -6530,9 +6604,10 @@
     while(new->base && PyArray_Check(new->base)) {
         new = (PyArrayObject *)(new->base);
     }
-    /* Get the available memory through the buffer
-       interface on new->base or if that fails
-       from the current new */
+    /*
+     * Get the available memory through the buffer interface on
+     * new->base or if that fails from the current new
+     */
     if (new->base && PyObject_AsReadBuffer(new->base,
                                            (const void **)&buf,
                                            &buf_len) >= 0) {
@@ -6568,10 +6643,12 @@
 static PyObject *
 array_priority_get(PyArrayObject *self)
 {
-    if (PyArray_CheckExact(self))
+    if (PyArray_CheckExact(self)) {
         return PyFloat_FromDouble(PyArray_PRIORITY);
-    else
+    }
+    else {
         return PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);
+    }
 }
 
 static PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);
@@ -6598,16 +6675,23 @@
     PyObject *dobj;
 
     res = arraydescr_protocol_descr_get(self->descr);
-    if (res) return res;
+    if (res) {
+        return res;
+    }
     PyErr_Clear();
 
     /* get default */
     dobj = PyTuple_New(2);
-    if (dobj == NULL) return NULL;
+    if (dobj == NULL) {
+        return NULL;
+    }
     PyTuple_SET_ITEM(dobj, 0, PyString_FromString(""));
     PyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));
     res = PyList_New(1);
-    if (res == NULL) {Py_DECREF(dobj); return NULL;}
+    if (res == NULL) {
+        Py_DECREF(dobj);
+        return NULL;
+    }
     PyList_SET_ITEM(res, 0, dobj);
     return res;
 }
@@ -6616,9 +6700,9 @@
 array_protocol_strides_get(PyArrayObject *self)
 {
     if PyArray_ISCONTIGUOUS(self) {
-            Py_INCREF(Py_None);
-            return Py_None;
-        }
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
     return PyArray_IntTupleFromIntp(self->nd, self->strides);
 }
 
@@ -6639,9 +6723,10 @@
     PyObject *_numpy_internal;
     PyObject *ret;
     _numpy_internal = PyImport_ImportModule("numpy.core._internal");
-    if (_numpy_internal == NULL) return NULL;
-    ret = PyObject_CallMethod(_numpy_internal, "_ctypes",
-                              "ON", self,
+    if (_numpy_internal == NULL) {
+        return NULL;
+    }
+    ret = PyObject_CallMethod(_numpy_internal, "_ctypes", "ON", self,
                               PyLong_FromVoidPtr(self->data));
     Py_DECREF(_numpy_internal);
     return ret;
@@ -6652,8 +6737,11 @@
 {
     PyObject *dict;
     PyObject *obj;
+
     dict = PyDict_New();
-    if (dict == NULL) return NULL;
+    if (dict == NULL) {
+        return NULL;
+    }
 
     /* dataptr */
     obj = array_dataptr_get(self);
@@ -6693,11 +6781,12 @@
         return NULL;
     }
     nbytes = PyArray_NBYTES(self);
-    if PyArray_ISWRITEABLE(self)
-                              return PyBuffer_FromReadWriteObject((PyObject *)self, 0,
-                                                                  (int) nbytes);
-    else
+    if PyArray_ISWRITEABLE(self) {
+        return PyBuffer_FromReadWriteObject((PyObject *)self, 0, (int) nbytes);
+    }
+    else {
         return PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);
+    }
 }
 
 static int
@@ -6709,8 +6798,7 @@
 
     if (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {
         writeable = 0;
-        if (PyObject_AsReadBuffer(op, (const void **)&buf,
-                                  &buf_len) < 0) {
+        if (PyObject_AsReadBuffer(op, (const void **)&buf, &buf_len) < 0) {
             PyErr_SetString(PyExc_AttributeError,
                             "object does not have single-segment " \
                             "buffer interface");
@@ -6723,8 +6811,7 @@
         return -1;
     }
     if (PyArray_NBYTES(self) > buf_len) {
-        PyErr_SetString(PyExc_AttributeError,
-                        "not enough data for array");
+        PyErr_SetString(PyExc_AttributeError, "not enough data for array");
         return -1;
     }
     if (self->flags & OWNDATA) {
@@ -6742,8 +6829,9 @@
     self->base = op;
     self->data = buf;
     self->flags = CARRAY;
-    if (!writeable)
+    if (!writeable) {
         self->flags &= ~WRITEABLE;
+    }
     return 0;
 }
 
@@ -6761,10 +6849,12 @@
 #if SIZEOF_INTP <= SIZEOF_LONG
     return PyInt_FromLong((long) size);
 #else
-    if (size > MAX_LONG || size < MIN_LONG)
+    if (size > MAX_LONG || size < MIN_LONG) {
         return PyLong_FromLongLong(size);
-    else
+    }
+    else {
         return PyInt_FromLong((long) size);
+    }
 #endif
 }
 
@@ -6775,28 +6865,29 @@
 #if SIZEOF_INTP <= SIZEOF_LONG
     return PyInt_FromLong((long) nbytes);
 #else
-    if (nbytes > MAX_LONG || nbytes < MIN_LONG)
+    if (nbytes > MAX_LONG || nbytes < MIN_LONG) {
         return PyLong_FromLongLong(nbytes);
-    else
+    }
+    else {
         return PyInt_FromLong((long) nbytes);
+    }
 #endif
 }
 
 
-/* If the type is changed.
-   Also needing change: strides, itemsize
+/*
+ * If the type is changed.
+ * Also needing change: strides, itemsize
+ *
+ * Either itemsize is exactly the same or the array is single-segment
+ * (contiguous or fortran) with compatibile dimensions The shape and strides
+ * will be adjusted in that case as well.
+ */
 
-   Either itemsize is exactly the same
-   or the array is single-segment (contiguous or fortran) with
-   compatibile dimensions
-
-   The shape and strides will be adjusted in that case as well.
-*/
-
 static int
 array_descr_set(PyArrayObject *self, PyObject *arg)
 {
-    PyArray_Descr *newtype=NULL;
+    PyArray_Descr *newtype = NULL;
     intp newdim;
     int index;
     char *msg = "new type not compatible with array.";
@@ -6825,51 +6916,61 @@
     }
 
 
-    if ((newtype->elsize != self->descr->elsize) &&         \
-        (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \
-         newtype->subarray)) goto fail;
-
-    if (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;
-    else index = 0;
-
+    if ((newtype->elsize != self->descr->elsize) &&
+        (self->nd == 0 || !PyArray_ISONESEGMENT(self) ||
+         newtype->subarray)) {
+        goto fail;
+    }
+    if (PyArray_ISCONTIGUOUS(self)) {
+        index = self->nd - 1;
+    }
+    else {
+        index = 0;
+    }
     if (newtype->elsize < self->descr->elsize) {
-        /* if it is compatible increase the size of the
-           dimension at end (or at the front for FORTRAN)
-        */
-        if (self->descr->elsize % newtype->elsize != 0)
+        /*
+         * if it is compatible increase the size of the
+         * dimension at end (or at the front for FORTRAN)
+         */
+        if (self->descr->elsize % newtype->elsize != 0) {
             goto fail;
+        }
         newdim = self->descr->elsize / newtype->elsize;
         self->dimensions[index] *= newdim;
         self->strides[index] = newtype->elsize;
     }
-
     else if (newtype->elsize > self->descr->elsize) {
-
-        /* Determine if last (or first if FORTRAN) dimension
-           is compatible */
-
+        /*
+         * Determine if last (or first if FORTRAN) dimension
+         * is compatible
+         */
         newdim = self->dimensions[index] * self->descr->elsize;
-        if ((newdim % newtype->elsize) != 0) goto fail;
-
+        if ((newdim % newtype->elsize) != 0) {
+            goto fail;
+        }
         self->dimensions[index] = newdim / newtype->elsize;
         self->strides[index] = newtype->elsize;
     }
 
     /* fall through -- adjust type*/
-
     Py_DECREF(self->descr);
     if (newtype->subarray) {
-        /* create new array object from data and update
-           dimensions, strides and descr from it */
+        /*
+         * create new array object from data and update
+         * dimensions, strides and descr from it
+         */
         PyArrayObject *temp;
-
-        /* We would decref newtype here --- temp will
-           steal a reference to it */
-        temp = (PyArrayObject *)                                \
+        /*
+         * We would decref newtype here.
+         * temp will steal a reference to it
+         */
+        temp = (PyArrayObject *)
             PyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,
                                  self->dimensions, self->strides,
                                  self->data, self->flags, NULL);
-        if (temp == NULL) return -1;
+        if (temp == NULL) {
+            return -1;
+        }
         PyDimMem_FREE(self->dimensions);
         self->dimensions = temp->dimensions;
         self->nd = temp->nd;
@@ -6884,7 +6985,6 @@
 
     self->descr = newtype;
     PyArray_UpdateFlags(self, UPDATE_ALL);
-
     return 0;
 
  fail:
@@ -6899,7 +6999,9 @@
     PyArrayInterface *inter;
 
     inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));
-    if (inter==NULL) return PyErr_NoMemory();
+    if (inter==NULL) {
+        return PyErr_NoMemory();
+    }
     inter->two = 2;
     inter->nd = self->nd;
     inter->typekind = self->descr->kind;
@@ -6908,9 +7010,10 @@
     /* reset unused flags */
     inter->flags &= ~(UPDATEIFCOPY | OWNDATA);
     if (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;
-    /* Copy shape and strides over since these can be reset
-       when the array is "reshaped".
-    */
+    /*
+     * Copy shape and strides over since these can be reset
+     *when the array is "reshaped".
+     */
     if (self->nd > 0) {
         inter->shape = (intp *)_pya_malloc(2*sizeof(intp)*self->nd);
         if (inter->shape == NULL) {
@@ -6928,10 +7031,16 @@
     inter->data = self->data;
     if (self->descr->names) {
         inter->descr = arraydescr_protocol_descr_get(self->descr);
-        if (inter->descr == NULL) PyErr_Clear();
-        else inter->flags &= ARR_HAS_DESCR;
+        if (inter->descr == NULL) {
+            PyErr_Clear();
+        }
+        else {
+            inter->flags &= ARR_HAS_DESCR;
+        }
     }
-    else inter->descr = NULL;
+    else {
+        inter->descr = NULL;
+    }
     Py_INCREF(self);
     return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);
 }
@@ -6958,7 +7067,7 @@
         PyArray_FillObjectArray(ret, zero);
         Py_DECREF(zero);
         if (PyErr_Occurred()) {
-            Py_DECREF(ret); 
+            Py_DECREF(ret);
             return -1;
         }
     }
@@ -6966,14 +7075,14 @@
         intp n = PyArray_NBYTES(ret);
         memset(ret->data, 0, n);
     }
-    return 0;  
+    return 0;
 }
 
 
-/* Create a view of a complex array with an equivalent data-type
-   except it is real instead of complex.
-*/
-
+/*
+ * Create a view of a complex array with an equivalent data-type
+ * except it is real instead of complex.
+ */
 static PyArrayObject *
 _get_part(PyArrayObject *self, int imag)
 {
@@ -6992,7 +7101,7 @@
         Py_DECREF(type);
         type = new;
     }
-    ret = (PyArrayObject *)                                 \
+    ret = (PyArrayObject *)
         PyArray_NewFromDescr(self->ob_type,
                              type,
                              self->nd,
@@ -7000,7 +7109,9 @@
                              self->strides,
                              self->data + offset,
                              self->flags, (PyObject *)self);
-    if (ret == NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     ret->flags &= ~CONTIGUOUS;
     ret->flags &= ~FORTRAN;
     Py_INCREF(self);
@@ -7033,14 +7144,19 @@
 
     if (PyArray_ISCOMPLEX(self)) {
         ret = _get_part(self, 0);
-        if (ret == NULL) return -1;
+        if (ret == NULL) {
+            return -1;
+        }
     }
     else {
         Py_INCREF(self);
         ret = self;
     }
     new = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);
-    if (new == NULL) {Py_DECREF(ret); return -1;}
+    if (new == NULL) {
+        Py_DECREF(ret);
+        return -1;
+    }
     rint = PyArray_MoveInto(ret, new);
     Py_DECREF(ret);
     Py_DECREF(new);
@@ -7059,15 +7175,17 @@
         Py_INCREF(self->descr);
 	ret = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type,
 						    self->descr,
-						    self->nd, 
+						    self->nd,
 						    self->dimensions,
 						    NULL, NULL,
 						    PyArray_ISFORTRAN(self),
 						    (PyObject *)self);
-	if (ret == NULL) return NULL;
-
-	if (_zerofill(ret) < 0) return NULL;
-
+	if (ret == NULL) {
+            return NULL;
+        }
+	if (_zerofill(ret) < 0) {
+            return NULL;
+        }
         ret->flags &= ~WRITEABLE;
     }
     return (PyObject *) ret;
@@ -7082,9 +7200,14 @@
         int rint;
 
         ret = _get_part(self, 1);
-        if (ret == NULL) return -1;
+        if (ret == NULL) {
+            return -1;
+        }
         new = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);
-        if (new == NULL) {Py_DECREF(ret); return -1;}
+        if (new == NULL) {
+            Py_DECREF(ret);
+            return -1;
+        }
         rint = PyArray_MoveInto(ret, new);
         Py_DECREF(ret);
         Py_DECREF(new);
@@ -7106,9 +7229,9 @@
 static int
 array_flat_set(PyArrayObject *self, PyObject *val)
 {
-    PyObject *arr=NULL;
+    PyObject *arr = NULL;
     int retval = -1;
-    PyArrayIterObject *selfit=NULL, *arrit=NULL;
+    PyArrayIterObject *selfit = NULL, *arrit = NULL;
     PyArray_Descr *typecode;
     int swap;
     PyArray_CopySwapFunc *copyswap;
@@ -7117,28 +7240,36 @@
     Py_INCREF(typecode);
     arr = PyArray_FromAny(val, typecode,
                           0, 0, FORCECAST | FORTRAN_IF(self), NULL);
-    if (arr == NULL) return -1;
+    if (arr == NULL) {
+        return -1;
+    }
     arrit = (PyArrayIterObject *)PyArray_IterNew(arr);
-    if (arrit == NULL) goto exit;
+    if (arrit == NULL) {
+        goto exit;
+    }
     selfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);
-    if (selfit == NULL) goto exit;
-
-    if (arrit->size == 0) {retval = 0; goto exit;}
-
+    if (selfit == NULL) {
+        goto exit;
+    }
+    if (arrit->size == 0) {
+        retval = 0;
+        goto exit;
+    }
     swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);
     copyswap = self->descr->f->copyswap;
     if (PyDataType_REFCHK(self->descr)) {
-        while(selfit->index < selfit->size) {
+        while (selfit->index < selfit->size) {
             PyArray_Item_XDECREF(selfit->dataptr, self->descr);
             PyArray_Item_INCREF(arrit->dataptr, PyArray_DESCR(arr));
-            memmove(selfit->dataptr, arrit->dataptr,
-                    sizeof(PyObject **));
-            if (swap)
+            memmove(selfit->dataptr, arrit->dataptr, sizeof(PyObject **));
+            if (swap) {
                 copyswap(selfit->dataptr, NULL, swap, self);
+            }
             PyArray_ITER_NEXT(selfit);
             PyArray_ITER_NEXT(arrit);
-            if (arrit->index == arrit->size)
+            if (arrit->index == arrit->size) {
                 PyArray_ITER_RESET(arrit);
+            }
         }
         retval = 0;
         goto exit;
@@ -7146,14 +7277,17 @@
 
     while(selfit->index < selfit->size) {
         memmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);
-        if (swap)
+        if (swap) {
             copyswap(selfit->dataptr, NULL, swap, self);
+        }
         PyArray_ITER_NEXT(selfit);
         PyArray_ITER_NEXT(arrit);
-        if (arrit->index == arrit->size)
+        if (arrit->index == arrit->size) {
             PyArray_ITER_RESET(arrit);
+        }
     }
     retval = 0;
+
  exit:
     Py_XDECREF(selfit);
     Py_XDECREF(arrit);
@@ -7261,77 +7395,78 @@
 
 static PyTypeObject PyArray_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                          /*ob_size*/
-    "numpy.ndarray",                            /*tp_name*/
-    sizeof(PyArrayObject),                      /*tp_basicsize*/
-    0,                                          /*tp_itemsize*/
+    0,                                           /* ob_size */
+    "numpy.ndarray",                             /* tp_name */
+    sizeof(PyArrayObject),                       /* tp_basicsize */
+    0,                                           /* tp_itemsize */
     /* methods */
-    (destructor)array_dealloc,                  /*tp_dealloc  */
-    (printfunc)NULL,                            /*tp_print*/
-    0,                                          /*tp_getattr*/
-    0,                                          /*tp_setattr*/
-    (cmpfunc)0,                                 /*tp_compare*/
-    (reprfunc)array_repr,                       /*tp_repr*/
-    &array_as_number,                           /*tp_as_number*/
-    &array_as_sequence,                         /*tp_as_sequence*/
-    &array_as_mapping,                          /*tp_as_mapping*/
-    (hashfunc)0,                                /*tp_hash*/
-    (ternaryfunc)0,                             /*tp_call*/
-    (reprfunc)array_str,                        /*tp_str*/
-
-    (getattrofunc)0,                            /*tp_getattro*/
-    (setattrofunc)0,                            /*tp_setattro*/
-    &array_as_buffer,                           /*tp_as_buffer*/
+    (destructor)array_dealloc,                   /* tp_dealloc */
+    (printfunc)NULL,                             /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    (cmpfunc)0,                                  /* tp_compare */
+    (reprfunc)array_repr,                        /* tp_repr */
+    &array_as_number,                            /* tp_as_number */
+    &array_as_sequence,                          /* tp_as_sequence */
+    &array_as_mapping,                           /* tp_as_mapping */
+    (hashfunc)0,                                 /* tp_hash */
+    (ternaryfunc)0,                              /* tp_call */
+    (reprfunc)array_str,                         /* tp_str */
+    (getattrofunc)0,                             /* tp_getattro */
+    (setattrofunc)0,                             /* tp_setattro */
+    &array_as_buffer,                            /* tp_as_buffer */
     (Py_TPFLAGS_DEFAULT
      | Py_TPFLAGS_BASETYPE
-     | Py_TPFLAGS_CHECKTYPES),                  /*tp_flags*/
+     | Py_TPFLAGS_CHECKTYPES),                   /* tp_flags */
     /*Documentation string */
-    0,                                          /*tp_doc*/
+    0,                                           /* tp_doc */
 
-    (traverseproc)0,                            /*tp_traverse */
-    (inquiry)0,                                 /*tp_clear */
-    (richcmpfunc)array_richcompare,             /*tp_richcompare */
-    offsetof(PyArrayObject, weakreflist),       /*tp_weaklistoffset */
+    (traverseproc)0,                             /* tp_traverse */
+    (inquiry)0,                                  /* tp_clear */
+    (richcmpfunc)array_richcompare,              /* tp_richcompare */
+    offsetof(PyArrayObject, weakreflist),        /* tp_weaklistoffset */
 
     /* Iterator support (use standard) */
 
-    (getiterfunc)array_iter,                    /* tp_iter */
-    (iternextfunc)0,                            /* tp_iternext */
+    (getiterfunc)array_iter,                     /* tp_iter */
+    (iternextfunc)0,                             /* tp_iternext */
 
     /* Sub-classing (new-style object) support */
 
-    array_methods,                              /* tp_methods */
-    0,                                          /* tp_members */
-    array_getsetlist,                           /* tp_getset */
-    0,                                          /* tp_base */
-    0,                                          /* tp_dict */
-    0,                                          /* tp_descr_get */
-    0,                                          /* tp_descr_set */
-    0,                                          /* tp_dictoffset */
-    (initproc)0,                                /* tp_init */
-    array_alloc,                                /* tp_alloc */
-    (newfunc)array_new,                         /* tp_new */
-    0,                                          /* tp_free */
-    0,                                          /* tp_is_gc */
-    0,                                          /* tp_bases */
-    0,                                          /* tp_mro */
-    0,                                          /* tp_cache */
-    0,                                          /* tp_subclasses */
-    0,                                          /* tp_weaklist */
-    0,   /* tp_del */
+    array_methods,                               /* tp_methods */
+    0,                                           /* tp_members */
+    array_getsetlist,                            /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    (initproc)0,                                 /* tp_init */
+    array_alloc,                                 /* tp_alloc */
+    (newfunc)array_new,                          /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 
-/* The rest of this code is to build the right kind of array from a python */
-/* object. */
+/*
+ * The rest of this code is to build the right kind of array
+ * from a python object.
+ */
 
 static int
 discover_depth(PyObject *s, int max, int stop_at_string, int stop_at_tuple)
@@ -7420,13 +7555,12 @@
     }
 
     n = PyObject_Length(s);
-
     if ((nd == 0) || PyString_Check(s) ||
             PyUnicode_Check(s) || PyBuffer_Check(s)) {
         *itemsize = MAX(*itemsize, n);
         return 0;
     }
-    for(i = 0; i < n; i++) {
+    for (i = 0; i < n; i++) {
         if ((e = PySequence_GetItem(s,i))==NULL) {
             return -1;
         }
@@ -7456,8 +7590,7 @@
 	}
 	return 0;
     }
-    
-    n=PyObject_Length(s);
+    n = PyObject_Length(s);
     *d = n;
     if (*d < 0) {
         return -1;
@@ -7507,10 +7640,11 @@
     }
 
 
-    if (chktype->type_num > mintype->type_num)
+    if (chktype->type_num > mintype->type_num) {
         outtype_num = chktype->type_num;
+    }
     else {
-        if (PyDataType_ISOBJECT(chktype) && \
+        if (PyDataType_ISOBJECT(chktype) &&
             PyDataType_ISSTRING(mintype)) {
             return PyArray_DescrFromType(NPY_OBJECT);
         }
@@ -7520,10 +7654,11 @@
     }
 
     save_num = outtype_num;
-    while(outtype_num < PyArray_NTYPES &&
+    while (outtype_num < PyArray_NTYPES &&
           !(PyArray_CanCastSafely(chktype->type_num, outtype_num)
-            && PyArray_CanCastSafely(mintype->type_num, outtype_num)))
+            && PyArray_CanCastSafely(mintype->type_num, outtype_num))) {
         outtype_num++;
+    }
     if (outtype_num == PyArray_NTYPES) {
         outtype = PyArray_DescrFromType(save_num);
     }
@@ -7532,11 +7667,13 @@
     }
     if (PyTypeNum_ISEXTENDED(outtype->type_num)) {
         int testsize = outtype->elsize;
-        register int chksize, minsize;
+        int chksize, minsize;
         chksize = chktype->elsize;
         minsize = mintype->elsize;
-        /* Handle string->unicode case separately
-           because string itemsize is 4* as large */
+        /*
+         * Handle string->unicode case separately
+         * because string itemsize is 4* as large
+         */
         if (outtype->type_num == PyArray_UNICODE &&
             mintype->type_num == PyArray_STRING) {
             testsize = MAX(chksize, 4*minsize);
@@ -7569,7 +7706,8 @@
         /* bools are a subclass of int */
         if (PyBool_Check(op)) {
             return PyArray_DescrFromType(PyArray_BOOL);
-        } else {
+        }
+        else {
             return  PyArray_DescrFromType(PyArray_LONG);
         }
     }
@@ -7607,39 +7745,42 @@
 }
 
 
-/* op is an object to be converted to an ndarray.
-
-   minitype is the minimum type-descriptor needed.
-
-   max is the maximum number of dimensions -- used for recursive call
-   to avoid infinite recursion...
-
-*/
-
+/*
+ * op is an object to be converted to an ndarray.
+ *
+ * minitype is the minimum type-descriptor needed.
+ *
+ * max is the maximum number of dimensions -- used for recursive call
+ * to avoid infinite recursion...
+ */
 static PyArray_Descr *
 _array_find_type(PyObject *op, PyArray_Descr *minitype, int max)
 {
     int l;
     PyObject *ip;
-    PyArray_Descr *chktype=NULL;
+    PyArray_Descr *chktype = NULL;
     PyArray_Descr *outtype;
 
-    /* These need to come first because if op already carries
-       a descr structure, then we want it to be the result if minitype
-       is NULL.
-    */
-
+    /*
+     * These need to come first because if op already carries
+     * a descr structure, then we want it to be the result if minitype
+     * is NULL.
+     */
     if (PyArray_Check(op)) {
         chktype = PyArray_DESCR(op);
         Py_INCREF(chktype);
-        if (minitype == NULL) return chktype;
+        if (minitype == NULL) {
+            return chktype;
+        }
         Py_INCREF(minitype);
         goto finish;
     }
 
     if (PyArray_IsScalar(op, Generic)) {
         chktype = PyArray_DescrFromScalar(op);
-        if (minitype == NULL) return chktype;
+        if (minitype == NULL) {
+            return chktype;
+        }
         Py_INCREF(minitype);
         goto finish;
     }
@@ -7647,10 +7788,12 @@
     if (minitype == NULL) {
         minitype = PyArray_DescrFromType(PyArray_BOOL);
     }
-    else Py_INCREF(minitype);
-
-    if (max < 0) goto deflt;
-
+    else {
+        Py_INCREF(minitype);
+    }
+    if (max < 0) {
+        goto deflt;
+    }
     chktype = _array_find_python_scalar_type(op);
     if (chktype) {
         goto finish;
@@ -7661,15 +7804,17 @@
             PyObject *new;
             new = PyDict_GetItemString(ip, "typestr");
             if (new && PyString_Check(new)) {
-                chktype =_array_typedescr_fromstr       \
-                    (PyString_AS_STRING(new));
+                chktype =_array_typedescr_fromstr(PyString_AS_STRING(new));
             }
         }
         Py_DECREF(ip);
-        if (chktype) goto finish;
+        if (chktype) {
+            goto finish;
+        }
     }
-    else PyErr_Clear();
-
+    else {
+        PyErr_Clear();
+    }
     if ((ip=PyObject_GetAttrString(op, "__array_struct__")) != NULL) {
         PyArrayInterface *inter;
         char buf[40];
@@ -7682,9 +7827,13 @@
             }
         }
         Py_DECREF(ip);
-        if (chktype) goto finish;
+        if (chktype) {
+            goto finish;
+        }
     }
-    else PyErr_Clear();
+    else {
+        PyErr_Clear();
+    }
 
     if (PyString_Check(op)) {
         chktype = PyArray_DescrNewFromType(PyArray_STRING);
@@ -7720,10 +7869,10 @@
         if (PyErr_Occurred()) PyErr_Clear();
     }
 
-    if (PyInstance_Check(op)) goto deflt;
-
+    if (PyInstance_Check(op)) {
+        goto deflt;
+    }
     if (PySequence_Check(op)) {
-
         l = PyObject_Length(op);
         if (l < 0 && PyErr_Occurred()) {
             PyErr_Clear();
@@ -7757,13 +7906,14 @@
     chktype = _use_default_type(op);
 
  finish:
-
     outtype = _array_small_type(chktype, minitype);
     Py_DECREF(chktype);
     Py_DECREF(minitype);
-    /* VOID Arrays should not occur by "default"
-       unless input was already a VOID */
-    if (outtype->type_num == PyArray_VOID && \
+    /*
+     * VOID Arrays should not occur by "default"
+     * unless input was already a VOID
+     */
+    if (outtype->type_num == PyArray_VOID &&
         minitype->type_num != PyArray_VOID) {
         Py_DECREF(outtype);
         return PyArray_DescrFromType(PyArray_OBJECT);
@@ -7778,15 +7928,15 @@
     Py_ssize_t i, slen;
     int res = 0;
 
-    /* This code is to ensure that the sequence access below will 
-       return a lower-dimensional sequence.
+    /*
+     * This code is to ensure that the sequence access below will
+     * return a lower-dimensional sequence.
      */
     if (PyArray_Check(s) && !(PyArray_CheckExact(s))) {
-      /* FIXME:  This could probably copy the entire subarray
-	 at once here using a faster algorithm.
-	 Right now, just make sure a base-class array
-	 is used so that the dimensionality reduction assumption
-	 is correct. 
+      /*
+       * FIXME:  This could probably copy the entire subarray at once here using
+       * a faster algorithm.  Right now, just make sure a base-class array is
+       * used so that the dimensionality reduction assumption is correct.
        */
 	s = PyArray_EnsureArray(s);
     }
@@ -7798,14 +7948,13 @@
     }
 
     slen = PySequence_Length(s);
-
     if (slen != a->dimensions[dim]) {
         PyErr_Format(PyExc_ValueError,
                      "setArrayFromSequence: sequence/array shape mismatch.");
         return -1;
     }
 
-    for(i=0; i<slen; i++) {
+    for (i = 0; i < slen; i++) {
         PyObject *o = PySequence_GetItem(s, i);
         if ((a->nd - dim) > 1) {
             res = setArrayFromSequence(a, o, dim+1, offset);
@@ -7814,7 +7963,9 @@
             res = a->descr->f->setitem(o, (a->data + offset), a);
         }
         Py_DECREF(o);
-        if (res < 0) return res;
+        if (res < 0) {
+            return res;
+        }
         offset += a->strides[dim];
     }
     return 0;
@@ -7834,12 +7985,13 @@
                         "assignment to 0-d array");
         return -1;
     }
-
     return setArrayFromSequence(self, v, 0, 0);
 }
 
-/* "Array Scalars don't call this code" */
-/* steals reference to typecode -- no NULL*/
+/*
+ * "Array Scalars don't call this code"
+ * steals reference to typecode -- no NULL
+ */
 static PyObject *
 Array_FromPyScalar(PyObject *op, PyArray_Descr *typecode)
 {
@@ -7852,7 +8004,6 @@
 
     if (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {
         itemsize = PyObject_Length(op);
-
         if (type == PyArray_UNICODE) {
             itemsize *= 4;
         }
@@ -7879,21 +8030,21 @@
     if (PyErr_Occurred()) {
         Py_DECREF(ret);
         return NULL;
-    } 
+    }
     else {
         return (PyObject *)ret;
     }
 }
 
 
-/* If s is not a list, return 0
-   Otherwise:
-
-   run object_depth_and_dimension on all the elements
-   and make sure the returned shape and size
-   is the same for each element
-
-*/
+/*
+ * If s is not a list, return 0
+ * Otherwise:
+ *
+ * run object_depth_and_dimension on all the elements
+ * and make sure the returned shape and size is the
+ * same for each element
+ */
 static int
 object_depth_and_dimension(PyObject *s, int max, intp *dims)
 {
@@ -7931,7 +8082,7 @@
     }
     nd = object_depth_and_dimension(obj, max - 1, newdims);
 
-    for(i = 1; i < size; i++) {
+    for (i = 1; i < size; i++) {
         if (islist) {
             obj = PyList_GET_ITEM(s, i);
         }
@@ -7947,7 +8098,7 @@
         }
     }
 
-    for(i = 1; i <= nd; i++) {
+    for (i = 1; i <= nd; i++) {
         dims[i] = newdims[i-1];
     }
     dims[0] = size;
@@ -7970,12 +8121,10 @@
     if (nd == 0) {
         return Array_FromPyScalar(s, typecode);
     }
-
     r = (PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,
                                              nd, d,
                                              NULL, NULL,
                                              fortran, NULL);
-
     if (!r) {
         return NULL;
     }
@@ -7986,12 +8135,12 @@
     return (PyObject*)r;
 }
 
-/* 
+/*
  * isobject means that we are constructing an
  * object array on-purpose with a nested list.
  * Only a list is interpreted as a sequence with these rules
+ * steals reference to typecode
  */
-/* steals reference to typecode */
 static PyObject *
 Array_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran,
                    int min_depth, int max_depth)
@@ -8007,11 +8156,9 @@
     int itemsize = typecode->elsize;
 
     check_it = (typecode->type != PyArray_CHARLTR);
-
     stop_at_string = (type != PyArray_STRING) ||
                      (typecode->type == PyArray_STRINGLTR);
-
-    stop_at_tuple = (type == PyArray_VOID && (typecode->names       \
+    stop_at_tuple = (type == PyArray_VOID && (typecode->names
                                               || typecode->subarray));
 
     nd = discover_depth(s, MAX_DIMS + 1, stop_at_string, stop_at_tuple);
@@ -8076,8 +8223,8 @@
 
 
 /*NUMPY_API
-  Is the typenum valid?
-*/
+ * Is the typenum valid?
+ */
 static int
 PyArray_ValidType(int type)
 {
@@ -8092,11 +8239,11 @@
     return res;
 }
 
-/* For backward compatibility */
-
-/* steals reference to at --- cannot be NULL*/
 /*NUMPY_API
- *Cast an array using typecode structure.
+ * For backward compatibility
+ *
+ * Cast an array using typecode structure.
+ * steals reference to at --- cannot be NULL
  */
 static PyObject *
 PyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)
@@ -8107,12 +8254,11 @@
 
     mpd = mp->descr;
 
-    if (((mpd == at) || ((mpd->type_num == at->type_num) &&         \
-                         PyArray_EquivByteorders(mpd->byteorder,\
-                                                 at->byteorder) &&  \
-                         ((mpd->elsize == at->elsize) ||            \
-                          (at->elsize==0)))) &&                     \
-        PyArray_ISBEHAVED_RO(mp)) {
+    if (((mpd == at) ||
+                ((mpd->type_num == at->type_num) &&
+                 PyArray_EquivByteorders(mpd->byteorder, at->byteorder) &&
+                 ((mpd->elsize == at->elsize) || (at->elsize==0)))) &&
+                 PyArray_ISBEHAVED_RO(mp)) {
         Py_DECREF(at);
         Py_INCREF(mp);
         return (PyObject *)mp;
@@ -8123,7 +8269,7 @@
         if (at == NULL) {
             return NULL;
         }
-        if (mpd->type_num == PyArray_STRING && 
+        if (mpd->type_num == PyArray_STRING &&
             at->type_num == PyArray_UNICODE) {
             at->elsize = mpd->elsize << 2;
         }
@@ -8157,14 +8303,15 @@
 }
 
 /*NUMPY_API
-  Get a cast function to cast from the input descriptor to the
-  output type_number (must be a registered data-type).
-  Returns NULL if un-successful.
-*/
+ * Get a cast function to cast from the input descriptor to the
+ * output type_number (must be a registered data-type).
+ * Returns NULL if un-successful.
+ */
 static PyArray_VectorUnaryFunc *
 PyArray_GetCastFunc(PyArray_Descr *descr, int type_num)
 {
-    PyArray_VectorUnaryFunc *castfunc=NULL;
+    PyArray_VectorUnaryFunc *castfunc = NULL;
+
     if (type_num < PyArray_NTYPES) {
         castfunc = descr->f->cast[type_num];
     }
@@ -8189,19 +8336,19 @@
         return castfunc;
     }
 
-    PyErr_SetString(PyExc_ValueError,
-                    "No cast function available.");
+    PyErr_SetString(PyExc_ValueError, "No cast function available.");
     return NULL;
 }
 
-/* Reference counts:
-   copyswapn is used which increases and decreases reference counts for OBJECT arrays.
-   All that needs to happen is for any reference counts in the buffers to be
-   decreased when completely finished with the buffers.
-
-   buffers[0] is the destination
-   buffers[1] is the source
-*/
+/*
+ * Reference counts:
+ * copyswapn is used which increases and decreases reference counts for OBJECT arrays.
+ * All that needs to happen is for any reference counts in the buffers to be
+ * decreased when completely finished with the buffers.
+ *
+ * buffers[0] is the destination
+ * buffers[1] is the source
+ */
 static void
 _strided_buffered_cast(char *dptr, intp dstride, int delsize, int dswap,
                        PyArray_CopySwapNFunc *dcopyfunc,
@@ -8213,10 +8360,11 @@
 {
     int i;
     if (N <= bufsize) {
-        /* 1. copy input to buffer and swap
-           2. cast input to output
-           3. swap output if necessary and copy from output buffer
-        */
+        /*
+         * 1. copy input to buffer and swap
+         * 2. cast input to output
+         * 3. swap output if necessary and copy from output buffer
+         */
         scopyfunc(buffers[1], selsize, sptr, sstride, N, sswap, src);
         castfunc(buffers[1], buffers[0], N, src, dest);
         dcopyfunc(dptr, dstride, buffers[0], delsize, N, dswap, dest);
@@ -8225,9 +8373,9 @@
 
     /* otherwise we need to divide up into bufsize pieces */
     i = 0;
-    while(N > 0) {
-        int newN;
-        newN = MIN(N, bufsize);
+    while (N > 0) {
+        int newN = MIN(N, bufsize);
+
         _strided_buffered_cast(dptr+i*dstride, dstride, delsize,
                                dswap, dcopyfunc,
                                sptr+i*sstride, sstride, selsize,
@@ -8307,7 +8455,7 @@
     }
 #endif
 
-    while(multi->index < multi->size) {
+    while (multi->index < multi->size) {
         _strided_buffered_cast(multi->iters[0]->dataptr,
                 ostrides,
                 delsize, oswap, ocopyfunc,
@@ -8326,13 +8474,13 @@
     Py_DECREF(multi);
     if (PyDataType_REFCHK(in->descr)) {
         obptr = buffers[1];
-        for(i = 0; i < N; i++, obptr+=selsize) {
+        for (i = 0; i < N; i++, obptr+=selsize) {
             PyArray_Item_XDECREF(obptr, out->descr);
         }
     }
     if (PyDataType_REFCHK(out->descr)) {
         obptr = buffers[0];
-        for(i = 0; i < N; i++, obptr+=delsize) {
+        for (i = 0; i < N; i++, obptr+=delsize) {
             PyArray_Item_XDECREF(obptr, out->descr);
         }
     }
@@ -8362,7 +8510,7 @@
 {
     int simple;
     int same;
-    PyArray_VectorUnaryFunc *castfunc=NULL;
+    PyArray_VectorUnaryFunc *castfunc = NULL;
     int mpsize = PyArray_SIZE(mp);
     int iswap, oswap;
     NPY_BEGIN_THREADS_DEF;
@@ -8371,8 +8519,7 @@
         return 0;
     }
     if (!PyArray_ISWRITEABLE(out)) {
-        PyErr_SetString(PyExc_ValueError,
-                "output array is not writeable");
+        PyErr_SetString(PyExc_ValueError, "output array is not writeable");
         return -1;
     }
 
@@ -8427,13 +8574,13 @@
 {
     char *inbuffer, *bptr, *optr;
     char *outbuffer=NULL;
-    PyArrayIterObject *it_in=NULL, *it_out=NULL;
+    PyArrayIterObject *it_in = NULL, *it_out = NULL;
     register intp i, index;
     intp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);
     int elsize=in->descr->elsize;
     int nels = PyArray_BUFSIZE;
     int el;
-    int inswap, outswap=0;
+    int inswap, outswap = 0;
     int obuf=!PyArray_ISCARRAY(out);
     int oelsize = out->descr->elsize;
     PyArray_CopySwapFunc *in_csn;
@@ -8452,45 +8599,50 @@
     inswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));
 
     inbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);
-    if (inbuffer == NULL) return -1;
-    if (PyArray_ISOBJECT(in))
+    if (inbuffer == NULL) {
+        return -1;
+    }
+    if (PyArray_ISOBJECT(in)) {
         memset(inbuffer, 0, PyArray_BUFSIZE*elsize);
+    }
     it_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);
-    if (it_in == NULL) goto exit;
-
+    if (it_in == NULL) {
+        goto exit;
+    }
     if (obuf) {
-        outswap = !(PyArray_ISFLEXIBLE(out) || \
+        outswap = !(PyArray_ISFLEXIBLE(out) ||
                     PyArray_ISNOTSWAPPED(out));
         outbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);
-        if (outbuffer == NULL) goto exit;
-        if (PyArray_ISOBJECT(out))
+        if (outbuffer == NULL) {
+            goto exit;
+        }
+        if (PyArray_ISOBJECT(out)) {
             memset(outbuffer, 0, PyArray_BUFSIZE*oelsize);
-
+        }
         it_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);
-        if (it_out == NULL) goto exit;
-
+        if (it_out == NULL) {
+            goto exit;
+        }
         nels = MIN(nels, PyArray_BUFSIZE);
     }
 
     optr = (obuf) ? outbuffer: out->data;
     bptr = inbuffer;
     el = 0;
-    while(ncopies--) {
+    while (ncopies--) {
         index = it_in->size;
         PyArray_ITER_RESET(it_in);
-        while(index--) {
+        while (index--) {
             in_csn(bptr, it_in->dataptr, inswap, in);
             bptr += elsize;
             PyArray_ITER_NEXT(it_in);
             el += 1;
             if ((el == nels) || (index == 0)) {
                 /* buffer filled, do cast */
-
                 castfunc(inbuffer, optr, el, in, out);
-
                 if (obuf) {
                     /* Copy from outbuffer to array */
-                    for(i=0; i<el; i++) {
+                    for (i = 0; i < el; i++) {
                         out_csn(it_out->dataptr,
                                 optr, outswap,
                                 out);
@@ -8508,6 +8660,7 @@
         }
     }
     retval = 0;
+
  exit:
     Py_XDECREF(it_in);
     PyDataMem_FREE(inbuffer);
@@ -8519,20 +8672,21 @@
 }
 
 /*NUMPY_API
-  Cast to an already created array.  Arrays don't have to be "broadcastable"
-  Only requirement is they have the same number of elements.
-*/
+ * Cast to an already created array.  Arrays don't have to be "broadcastable"
+ * Only requirement is they have the same number of elements.
+ */
 static int
 PyArray_CastAnyTo(PyArrayObject *out, PyArrayObject *mp)
 {
     int simple;
-    PyArray_VectorUnaryFunc *castfunc=NULL;
+    PyArray_VectorUnaryFunc *castfunc = NULL;
     int mpsize = PyArray_SIZE(mp);
 
-    if (mpsize == 0) return 0;
+    if (mpsize == 0) {
+        return 0;
+    }
     if (!PyArray_ISWRITEABLE(out)) {
-        PyErr_SetString(PyExc_ValueError,
-                        "output array is not writeable");
+        PyErr_SetString(PyExc_ValueError, "output array is not writeable");
         return -1;
     }
 
@@ -8544,36 +8698,34 @@
     }
 
     castfunc = PyArray_GetCastFunc(mp->descr, out->descr->type_num);
-    if (castfunc == NULL) return -1;
-
-
+    if (castfunc == NULL) {
+        return -1;
+    }
     simple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) ||
               (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));
-
     if (simple) {
         castfunc(mp->data, out->data, mpsize, mp, out);
         return 0;
     }
-
     if (PyArray_SAMESHAPE(out, mp)) {
         int iswap, oswap;
         iswap = PyArray_ISBYTESWAPPED(mp) && !PyArray_ISFLEXIBLE(mp);
         oswap = PyArray_ISBYTESWAPPED(out) && !PyArray_ISFLEXIBLE(out);
         return _broadcast_cast(out, mp, castfunc, iswap, oswap);
     }
-
     return _bufferedcast(out, mp, castfunc);
 }
 
 
 
-/* steals reference to newtype --- acc. NULL */
-/*NUMPY_API*/
+/*NUMPY_API
+ * steals reference to newtype --- acc. NULL
+ */
 static PyObject *
 PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags)
 {
 
-    PyArrayObject *ret=NULL;
+    PyArrayObject *ret = NULL;
     int itemsize;
     int copy = 0;
     int arrflags;
@@ -8582,9 +8734,7 @@
     PyTypeObject *subtype;
 
     oldtype = PyArray_DESCR(arr);
-
     subtype = arr->ob_type;
-
     if (newtype == NULL) {
         newtype = oldtype; Py_INCREF(oldtype);
     }
@@ -8598,10 +8748,11 @@
         itemsize = newtype->elsize;
     }
 
-    /* Can't cast unless ndim-0 array, FORCECAST is specified
-       or the cast is safe.
-    */
-    if (!(flags & FORCECAST) && !PyArray_NDIM(arr)==0 &&
+    /*
+     * Can't cast unless ndim-0 array, FORCECAST is specified
+     * or the cast is safe.
+     */
+    if (!(flags & FORCECAST) && !PyArray_NDIM(arr) == 0 &&
         !PyArray_CanCastTo(oldtype, newtype)) {
         Py_DECREF(newtype);
         PyErr_SetString(PyExc_TypeError,
@@ -8613,16 +8764,15 @@
     /* Don't copy if sizes are compatible */
     if ((flags & ENSURECOPY) || PyArray_EquivTypes(oldtype, newtype)) {
         arrflags = arr->flags;
-
-        copy = (flags & ENSURECOPY) || \
-            ((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \
-            || ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \
-            || (arr->nd > 1 &&                              \
-                ((flags & FORTRAN) && (!(arrflags & FORTRAN)))) \
+        copy = (flags & ENSURECOPY) ||
+            ((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS)))
+            || ((flags & ALIGNED) && (!(arrflags & ALIGNED)))
+            || (arr->nd > 1 &&
+                ((flags & FORTRAN) && (!(arrflags & FORTRAN))))
             || ((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));
 
         if (copy) {
-            if ((flags & UPDATEIFCOPY) && \
+            if ((flags & UPDATEIFCOPY) &&
                 (!PyArray_ISWRITEABLE(arr))) {
                 Py_DECREF(newtype);
                 PyErr_SetString(PyExc_ValueError, msg);
@@ -8631,7 +8781,7 @@
             if ((flags & ENSUREARRAY)) {
                 subtype = &PyArray_Type;
             }
-            ret = (PyArrayObject *)         \
+            ret = (PyArrayObject *)
                 PyArray_NewFromDescr(subtype, newtype,
                                      arr->nd,
                                      arr->dimensions,
@@ -8652,14 +8802,16 @@
                 Py_INCREF(arr);
             }
         }
-        /* If no copy then just increase the reference
-           count and return the input */
+        /*
+         * If no copy then just increase the reference
+         * count and return the input
+         */
         else {
             Py_DECREF(newtype);
             if ((flags & ENSUREARRAY) &&
                 !PyArray_CheckExact(arr)) {
                 Py_INCREF(arr->descr);
-                ret = (PyArrayObject *)                 \
+                ret = (PyArrayObject *)
                     PyArray_NewFromDescr(&PyArray_Type,
                                          arr->descr,
                                          arr->nd,
@@ -8679,10 +8831,12 @@
         }
     }
 
-    /* The desired output type is different than the input
-       array type and copy was not specified */
+    /*
+     * The desired output type is different than the input
+     * array type and copy was not specified
+     */
     else {
-        if ((flags & UPDATEIFCOPY) &&                   \
+        if ((flags & UPDATEIFCOPY) &&
             (!PyArray_ISWRITEABLE(arr))) {
             Py_DECREF(newtype);
             PyErr_SetString(PyExc_ValueError, msg);
@@ -8691,7 +8845,7 @@
         if ((flags & ENSUREARRAY)) {
             subtype = &PyArray_Type;
         }
-        ret = (PyArrayObject *)                         \
+        ret = (PyArrayObject *)
             PyArray_NewFromDescr(subtype, newtype,
                                  arr->nd, arr->dimensions,
                                  NULL, NULL,
@@ -8729,72 +8883,105 @@
     swapchar = str[0];
     str += 1;
 
-#define _MY_FAIL {                              \
-        PyErr_SetString(PyExc_ValueError, msg); \
-        return NULL;                            \
-    }
-
     typechar = str[0];
     size = atoi(str + 1);
     switch (typechar) {
     case 'b':
-        if (size == sizeof(Bool))
+        if (size == sizeof(Bool)) {
             type_num = PyArray_BOOL;
-        else _MY_FAIL
-                 break;
+        }
+        else {
+            PyErr_SetString(PyExc_ValueError, msg);
+            return NULL;
+        }
+        break;
     case 'u':
-        if (size == sizeof(uintp))
+        if (size == sizeof(uintp)) {
             type_num = PyArray_UINTP;
-        else if (size == sizeof(char))
+        }
+        else if (size == sizeof(char)) {
             type_num = PyArray_UBYTE;
-        else if (size == sizeof(short))
+        }
+        else if (size == sizeof(short)) {
             type_num = PyArray_USHORT;
-        else if (size == sizeof(ulong))
+        }
+        else if (size == sizeof(ulong)) {
             type_num = PyArray_ULONG;
-        else if (size == sizeof(int))
+        }
+        else if (size == sizeof(int)) {
             type_num = PyArray_UINT;
-        else if (size == sizeof(ulonglong))
+        }
+        else if (size == sizeof(ulonglong)) {
             type_num = PyArray_ULONGLONG;
-        else _MY_FAIL
-                 break;
+        }
+        else {
+            PyErr_SetString(PyExc_ValueError, msg);
+            return NULL;
+        }
+        break;
     case 'i':
-        if (size == sizeof(intp))
+        if (size == sizeof(intp)) {
             type_num = PyArray_INTP;
-        else if (size == sizeof(char))
+        }
+        else if (size == sizeof(char)) {
             type_num = PyArray_BYTE;
-        else if (size == sizeof(short))
+        }
+        else if (size == sizeof(short)) {
             type_num = PyArray_SHORT;
-        else if (size == sizeof(long))
+        }
+        else if (size == sizeof(long)) {
             type_num = PyArray_LONG;
-        else if (size == sizeof(int))
+        }
+        else if (size == sizeof(int)) {
             type_num = PyArray_INT;
-        else if (size == sizeof(longlong))
+        }
+        else if (size == sizeof(longlong)) {
             type_num = PyArray_LONGLONG;
-        else _MY_FAIL
-                 break;
+        }
+        else {
+            PyErr_SetString(PyExc_ValueError, msg);
+            return NULL;
+        }
+        break;
     case 'f':
-        if (size == sizeof(float))
+        if (size == sizeof(float)) {
             type_num = PyArray_FLOAT;
-        else if (size == sizeof(double))
+        }
+        else if (size == sizeof(double)) {
             type_num = PyArray_DOUBLE;
-        else if (size == sizeof(longdouble))
+        }
+        else if (size == sizeof(longdouble)) {
             type_num = PyArray_LONGDOUBLE;
-        else _MY_FAIL
-                 break;
+        }
+        else {
+            PyErr_SetString(PyExc_ValueError, msg);
+            return NULL;
+        }
+        break;
     case 'c':
-        if (size == sizeof(float)*2)
+        if (size == sizeof(float)*2) {
             type_num = PyArray_CFLOAT;
-        else if (size == sizeof(double)*2)
+        }
+        else if (size == sizeof(double)*2) {
             type_num = PyArray_CDOUBLE;
-        else if (size == sizeof(longdouble)*2)
+        }
+        else if (size == sizeof(longdouble)*2) {
             type_num = PyArray_CLONGDOUBLE;
-        else _MY_FAIL
-                 break;
+        }
+        else {
+            PyErr_SetString(PyExc_ValueError, msg);
+            return NULL;
+        }
+        break;
     case 'O':
-        if (size == sizeof(PyObject *))
+        if (size == sizeof(PyObject *)) {
             type_num = PyArray_OBJECT;
-        else _MY_FAIL
-                 break;
+        }
+        else {
+            PyErr_SetString(PyExc_ValueError, msg);
+            return NULL;
+        }
+        break;
     case PyArray_STRINGLTR:
         type_num = PyArray_STRING;
         break;
@@ -8806,22 +8993,27 @@
         type_num = PyArray_VOID;
         break;
     default:
-        _MY_FAIL
-            }
+        PyErr_SetString(PyExc_ValueError, msg);
+        return NULL;
+    }
 
-#undef _MY_FAIL
-
     descr = PyArray_DescrFromType(type_num);
-    if (descr == NULL) return NULL;
+    if (descr == NULL) {
+        return NULL;
+    }
     swap = !PyArray_ISNBO(swapchar);
     if (descr->elsize == 0 || swap) {
         /* Need to make a new PyArray_Descr */
         PyArray_DESCR_REPLACE(descr);
-        if (descr==NULL) return NULL;
-        if (descr->elsize == 0)
+        if (descr==NULL) {
+            return NULL;
+        }
+        if (descr->elsize == 0) {
             descr->elsize = size;
-        if (swap)
+        }
+        if (swap) {
             descr->byteorder = swapchar;
+        }
     }
     return descr;
 }
@@ -8830,7 +9022,7 @@
 static PyObject *
 PyArray_FromStructInterface(PyObject *input)
 {
-    PyArray_Descr *thetype=NULL;
+    PyArray_Descr *thetype = NULL;
     char buf[40];
     PyArrayInterface *inter;
     PyObject *attr, *r;
@@ -8841,9 +9033,13 @@
         PyErr_Clear();
         return Py_NotImplemented;
     }
-    if (!PyCObject_Check(attr)) goto fail;
+    if (!PyCObject_Check(attr)) {
+        goto fail;
+    }
     inter = PyCObject_AsVoidPtr(attr);
-    if (inter->two != 2) goto fail;
+    if (inter->two != 2) {
+        goto fail;
+    }
     if ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {
         endian = PyArray_OPPBYTE;
         inter->flags &= ~NOTSWAPPED;
@@ -8887,10 +9083,10 @@
 static PyObject *
 PyArray_FromInterface(PyObject *input)
 {
-    PyObject *attr=NULL, *item=NULL;
-    PyObject *tstr=NULL, *shape=NULL;
-    PyObject *inter=NULL;
-    PyObject *base=NULL;
+    PyObject *attr = NULL, *item = NULL;
+    PyObject *tstr = NULL, *shape = NULL;
+    PyObject *inter = NULL;
+    PyObject *base = NULL;
     PyArrayObject *ret;
     PyArray_Descr *type=NULL;
     char *data;
@@ -8905,26 +9101,42 @@
     /* Get the strides */
 
     inter = PyObject_GetAttrString(input, "__array_interface__");
-    if (inter == NULL) {PyErr_Clear(); return Py_NotImplemented;}
-    if (!PyDict_Check(inter)) {Py_DECREF(inter); return Py_NotImplemented;}
-
+    if (inter == NULL) {
+        PyErr_Clear();
+        return Py_NotImplemented;
+    }
+    if (!PyDict_Check(inter)) {
+        Py_DECREF(inter);
+        return Py_NotImplemented;
+    }
     shape = PyDict_GetItemString(inter, "shape");
-    if (shape == NULL) {Py_DECREF(inter); return Py_NotImplemented;}
+    if (shape == NULL) {
+        Py_DECREF(inter);
+        return Py_NotImplemented;
+    }
     tstr = PyDict_GetItemString(inter, "typestr");
-    if (tstr == NULL) {Py_DECREF(inter); return Py_NotImplemented;}
+    if (tstr == NULL) {
+        Py_DECREF(inter);
+        return Py_NotImplemented;
+    }
 
     attr = PyDict_GetItemString(inter, "data");
     base = input;
     if ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {
-        if (attr && (attr != Py_None)) item=attr;
-        else item=input;
-        res = PyObject_AsWriteBuffer(item, (void **)&data,
-                                     &buffer_len);
+        if (attr && (attr != Py_None)) {
+            item = attr;
+        }
+        else {
+            item = input;
+        }
+        res = PyObject_AsWriteBuffer(item, (void **)&data, &buffer_len);
         if (res < 0) {
             PyErr_Clear();
-            res = PyObject_AsReadBuffer(item, (const void **)&data,
-                                        &buffer_len);
-            if (res < 0) goto fail;
+            res = PyObject_AsReadBuffer(
+                    item, (const void **)&data, &buffer_len);
+            if (res < 0) {
+                goto fail;
+            }
             dataflags &= ~WRITEABLE;
         }
         attr = PyDict_GetItemString(inter, "offset");
@@ -8979,7 +9191,9 @@
         goto fail;
     }
     type = _array_typedescr_fromstr(PyString_AS_STRING(attr));
-    if (type==NULL) goto fail;
+    if (type == NULL) {
+        goto fail;
+    }
     attr = shape;
     if (!PyTuple_Check(attr)) {
         PyErr_SetString(PyExc_TypeError, "shape must be a tuple");
@@ -8987,17 +9201,21 @@
         goto fail;
     }
     n = PyTuple_GET_SIZE(attr);
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         item = PyTuple_GET_ITEM(attr, i);
         dims[i] = PyArray_PyIntAsIntp(item);
-        if (error_converting(dims[i])) break;
+        if (error_converting(dims[i])) {
+            break;
+        }
     }
 
     ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, type,
                                                 n, dims,
                                                 NULL, data,
                                                 dataflags, NULL);
-    if (ret == NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     Py_INCREF(base);
     ret->base = base;
 
@@ -9016,12 +9234,16 @@
             Py_DECREF(ret);
             return NULL;
         }
-        for(i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             item = PyTuple_GET_ITEM(attr, i);
             strides[i] = PyArray_PyIntAsIntp(item);
-            if (error_converting(strides[i])) break;
+            if (error_converting(strides[i])) {
+                break;
+            }
         }
-        if (PyErr_Occurred()) PyErr_Clear();
+        if (PyErr_Occurred()) {
+            PyErr_Clear();
+        }
         memcpy(ret->strides, strides, n*sizeof(intp));
     }
     else PyErr_Clear();
@@ -9042,35 +9264,38 @@
     PyObject *array_meth;
 
     array_meth = PyObject_GetAttrString(op, "__array__");
-    if (array_meth == NULL) {PyErr_Clear(); return Py_NotImplemented;}
+    if (array_meth == NULL) {
+        PyErr_Clear();
+        return Py_NotImplemented;
+    }
     if (context == NULL) {
-        if (typecode == NULL) new = PyObject_CallFunction(array_meth,
-                                                          NULL);
-        else new = PyObject_CallFunction(array_meth, "O", typecode);
+        if (typecode == NULL) {
+            new = PyObject_CallFunction(array_meth, NULL);
+        }
+        else {
+            new = PyObject_CallFunction(array_meth, "O", typecode);
+        }
     }
     else {
         if (typecode == NULL) {
-            new = PyObject_CallFunction(array_meth, "OO", Py_None,
-                                        context);
-            if (new == NULL && \
-                PyErr_ExceptionMatches(PyExc_TypeError)) {
+            new = PyObject_CallFunction(array_meth, "OO", Py_None, context);
+            if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {
                 PyErr_Clear();
                 new = PyObject_CallFunction(array_meth, "");
             }
         }
         else {
-            new = PyObject_CallFunction(array_meth, "OO",
-                                        typecode, context);
-            if (new == NULL && \
-                PyErr_ExceptionMatches(PyExc_TypeError)) {
+            new = PyObject_CallFunction(array_meth, "OO", typecode, context);
+            if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {
                 PyErr_Clear();
-                new = PyObject_CallFunction(array_meth, "O",
-                                            typecode);
+                new = PyObject_CallFunction(array_meth, "O", typecode);
             }
         }
     }
     Py_DECREF(array_meth);
-    if (new == NULL) return NULL;
+    if (new == NULL) {
+        return NULL;
+    }
     if (!PyArray_Check(new)) {
         PyErr_SetString(PyExc_ValueError,
                         "object __array__ method not "  \
@@ -9081,23 +9306,27 @@
     return new;
 }
 
-/* Does not check for ENSURECOPY and NOTSWAPPED in flags */
-/* Steals a reference to newtype --- which can be NULL */
-/*NUMPY_API*/
+/*NUMPY_API
+ * Does not check for ENSURECOPY and NOTSWAPPED in flags
+ * Steals a reference to newtype --- which can be NULL
+ */
 static PyObject *
 PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth,
                 int max_depth, int flags, PyObject *context)
 {
-    /* This is the main code to make a NumPy array from a Python
-       Object.  It is called from lot's of different places which
-       is why there are so many checks.  The comments try to
-       explain some of the checks. */
-
-    PyObject *r=NULL;
+    /*
+     * This is the main code to make a NumPy array from a Python
+     * Object.  It is called from lot's of different places which
+     * is why there are so many checks.  The comments try to
+     * explain some of the checks.
+     */
+    PyObject *r = NULL;
     int seq = FALSE;
 
-    /* Is input object already an array? */
-    /*  This is where the flags are used */
+    /*
+     * Is input object already an array?
+     * This is where the flags are used
+     */
     if (PyArray_Check(op)) {
         r = PyArray_FromArray((PyArrayObject *)op, newtype, flags);
     }
@@ -9121,8 +9350,7 @@
             return NULL;
         }
         if (newtype != NULL || flags != 0) {
-            new = PyArray_FromArray((PyArrayObject *)r, newtype,
-                                    flags);
+            new = PyArray_FromArray((PyArrayObject *)r, newtype, flags);
             Py_DECREF(r);
             r = new;
         }
@@ -9158,7 +9386,7 @@
                 PyErr_Clear();
                 if (isobject) {
                     Py_INCREF(newtype);
-                    r = ObjectArray_FromNestedList  \
+                    r = ObjectArray_FromNestedList
                         (op, newtype, flags & FORTRAN);
                     seq = TRUE;
                     Py_DECREF(newtype);
@@ -9180,7 +9408,6 @@
     }
 
     /* Be sure we succeed here */
-
     if(!PyArray_Check(r)) {
         PyErr_SetString(PyExc_RuntimeError,
                         "internal error: PyArray_FromAny "\
@@ -9210,8 +9437,9 @@
     return NULL;
 }
 
-/* new reference -- accepts NULL for mintype*/
-/*NUMPY_API*/
+/*NUMPY_API
+* new reference -- accepts NULL for mintype
+*/
 static PyArray_Descr *
 PyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)
 {
@@ -9219,9 +9447,8 @@
 }
 
 /*NUMPY_API
-  Return the typecode of the array a Python object would be converted
-  to
-*/
+ * Return the typecode of the array a Python object would be converted to
+ */
 static int
 PyArray_ObjectType(PyObject *op, int minimum_type)
 {
@@ -9230,7 +9457,9 @@
     int ret;
 
     intype = PyArray_DescrFromType(minimum_type);
-    if (intype == NULL) PyErr_Clear();
+    if (intype == NULL) {
+        PyErr_Clear();
+    }
     outtype = _array_find_type(op, intype, MAX_DIMS);
     ret = outtype->type_num;
     Py_DECREF(outtype);
@@ -9239,56 +9468,57 @@
 }
 
 
-/* flags is any of
-   CONTIGUOUS,
-   FORTRAN,
-   ALIGNED,
-   WRITEABLE,
-   NOTSWAPPED,
-   ENSURECOPY,
-   UPDATEIFCOPY,
-   FORCECAST,
-   ENSUREARRAY,
-   ELEMENTSTRIDES
+/*
+ * flags is any of
+ * CONTIGUOUS,
+ * FORTRAN,
+ * ALIGNED,
+ * WRITEABLE,
+ * NOTSWAPPED,
+ * ENSURECOPY,
+ * UPDATEIFCOPY,
+ * FORCECAST,
+ * ENSUREARRAY,
+ * ELEMENTSTRIDES
+ *
+ * or'd (|) together
+ *
+ * Any of these flags present means that the returned array should
+ * guarantee that aspect of the array.  Otherwise the returned array
+ * won't guarantee it -- it will depend on the object as to whether or
+ * not it has such features.
+ *
+ * Note that ENSURECOPY is enough
+ * to guarantee CONTIGUOUS, ALIGNED and WRITEABLE
+ * and therefore it is redundant to include those as well.
+ *
+ * BEHAVED == ALIGNED | WRITEABLE
+ * CARRAY = CONTIGUOUS | BEHAVED
+ * FARRAY = FORTRAN | BEHAVED
+ *
+ * FORTRAN can be set in the FLAGS to request a FORTRAN array.
+ * Fortran arrays are always behaved (aligned,
+ * notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d).
+ *
+ * UPDATEIFCOPY flag sets this flag in the returned array if a copy is
+ * made and the base argument points to the (possibly) misbehaved array.
+ * When the new array is deallocated, the original array held in base
+ * is updated with the contents of the new array.
+ *
+ * FORCECAST will cause a cast to occur regardless of whether or not
+ * it is safe.
+ */
 
-   or'd (|) together
-
-   Any of these flags present means that the returned array should
-   guarantee that aspect of the array.  Otherwise the returned array
-   won't guarantee it -- it will depend on the object as to whether or
-   not it has such features.
-
-   Note that ENSURECOPY is enough
-   to guarantee CONTIGUOUS, ALIGNED and WRITEABLE
-   and therefore it is redundant to include those as well.
-
-   BEHAVED == ALIGNED | WRITEABLE
-   CARRAY = CONTIGUOUS | BEHAVED
-   FARRAY = FORTRAN | BEHAVED
-
-   FORTRAN can be set in the FLAGS to request a FORTRAN array.
-   Fortran arrays are always behaved (aligned,
-   notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d).
-
-   UPDATEIFCOPY flag sets this flag in the returned array if a copy is
-   made and the base argument points to the (possibly) misbehaved array.
-   When the new array is deallocated, the original array held in base
-   is updated with the contents of the new array.
-
-   FORCECAST will cause a cast to occur regardless of whether or not
-   it is safe.
-*/
-
-
-/* steals a reference to descr -- accepts NULL */
-/*NUMPY_API*/
+/*NUMPY_API
+ * steals a reference to descr -- accepts NULL
+ */
 static PyObject *
 PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth,
                      int max_depth, int requires, PyObject *context)
 {
     PyObject *obj;
     if (requires & NOTSWAPPED) {
-        if (!descr && PyArray_Check(op) && \
+        if (!descr && PyArray_Check(op) &&
             !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {
             descr = PyArray_DescrNew(PyArray_DESCR(op));
         }
@@ -9300,9 +9530,10 @@
         }
     }
 
-    obj = PyArray_FromAny(op, descr, min_depth, max_depth,
-                          requires, context);
-    if (obj == NULL) return NULL;
+    obj = PyArray_FromAny(op, descr, min_depth, max_depth, requires, context);
+    if (obj == NULL) {
+        return NULL;
+    }
     if ((requires & ELEMENTSTRIDES) &&
         !PyArray_ElementStrides(obj)) {
         PyObject *new;
@@ -9313,25 +9544,25 @@
     return obj;
 }
 
-/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0,
-   ENSUREARRAY) */
-/*  that special cases Arrays and PyArray_Scalars up front */
-/*  It *steals a reference* to the object */
-/*  It also guarantees that the result is PyArray_Type */
-
-/*  Because it decrefs op if any conversion needs to take place
-    so it can be used like PyArray_EnsureArray(some_function(...)) */
-
-/*NUMPY_API*/
+/*NUMPY_API
+ * This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, ENSUREARRAY)
+ * that special cases Arrays and PyArray_Scalars up front
+ * It *steals a reference* to the object
+ * It also guarantees that the result is PyArray_Type
+ * Because it decrefs op if any conversion needs to take place
+ * so it can be used like PyArray_EnsureArray(some_function(...))
+ */
 static PyObject *
 PyArray_EnsureArray(PyObject *op)
 {
     PyObject *new;
 
-    if (op == NULL) return NULL;
-
-    if (PyArray_CheckExact(op)) return op;
-
+    if (op == NULL) {
+        return NULL;
+    }
+    if (PyArray_CheckExact(op)) {
+        return op;
+    }
     if (PyArray_Check(op)) {
         new = PyArray_View((PyArrayObject *)op, NULL, &PyArray_Type);
         Py_DECREF(op);
@@ -9351,25 +9582,36 @@
 static PyObject *
 PyArray_EnsureAnyArray(PyObject *op)
 {
-    if (op && PyArray_Check(op)) return op;
+    if (op && PyArray_Check(op)) {
+        return op;
+    }
     return PyArray_EnsureArray(op);
 }
 
 /*NUMPY_API
-  Check the type coercion rules.
-*/
+ *Check the type coercion rules.
+ */
 static int
 PyArray_CanCastSafely(int fromtype, int totype)
 {
     PyArray_Descr *from, *to;
     register int felsize, telsize;
 
-    if (fromtype == totype) return 1;
-    if (fromtype == PyArray_BOOL) return 1;
-    if (totype == PyArray_BOOL) return 0;
-    if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;
-    if (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;
-
+    if (fromtype == totype) {
+        return 1;
+    }
+    if (fromtype == PyArray_BOOL) {
+        return 1;
+    }
+    if (totype == PyArray_BOOL) {
+        return 0;
+    }
+    if (totype == PyArray_OBJECT || totype == PyArray_VOID) {
+        return 1;
+    }
+    if (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) {
+        return 0;
+    }
     from = PyArray_DescrFromType(fromtype);
     /*
      * cancastto is a PyArray_NOTYPE terminated C-int-array of types that
@@ -9379,11 +9621,14 @@
         int *curtype;
         curtype = from->f->cancastto;
         while (*curtype != PyArray_NOTYPE) {
-            if (*curtype++ == totype) return 1;
+            if (*curtype++ == totype) {
+                return 1;
+            }
         }
     }
-    if (PyTypeNum_ISUSERDEF(totype)) return 0;
-
+    if (PyTypeNum_ISUSERDEF(totype)) {
+        return 0;
+    }
     to = PyArray_DescrFromType(totype);
     telsize = to->elsize;
     felsize = from->elsize;
@@ -9401,22 +9646,28 @@
                 return 0;
             }
             else {
-                return (telsize >= felsize);
+                return telsize >= felsize;
             }
         }
         else if (PyTypeNum_ISFLOAT(totype)) {
-            if (felsize < 8)
-                return (telsize > felsize);
-            else
-                return (telsize >= felsize);
+            if (felsize < 8) {
+                return telsize > felsize;
+            }
+            else {
+                return telsize >= felsize;
+            }
         }
         else if (PyTypeNum_ISCOMPLEX(totype)) {
-            if (felsize < 8)
-                return ((telsize >> 1) > felsize);
-            else
-                return ((telsize >> 1) >= felsize);
+            if (felsize < 8) {
+                return (telsize >> 1) > felsize;
+            }
+            else {
+                return (telsize >> 1) >= felsize;
+            }
         }
-        else return totype > fromtype;
+        else {
+            return totype > fromtype;
+        }
     case PyArray_UBYTE:
     case PyArray_USHORT:
     case PyArray_UINT:
@@ -9424,46 +9675,55 @@
     case PyArray_ULONGLONG:
         if (PyTypeNum_ISINTEGER(totype)) {
             if (PyTypeNum_ISSIGNED(totype)) {
-                return (telsize > felsize);
+                return telsize > felsize;
             }
             else {
-                return (telsize >= felsize);
+                return telsize >= felsize;
             }
         }
         else if (PyTypeNum_ISFLOAT(totype)) {
-            if (felsize < 8)
-                return (telsize > felsize);
-            else
-                return (telsize >= felsize);
+            if (felsize < 8) {
+                return telsize > felsize;
+            }
+            else {
+                return telsize >= felsize;
+            }
         }
         else if (PyTypeNum_ISCOMPLEX(totype)) {
-            if (felsize < 8)
-                return ((telsize >> 1) > felsize);
-            else
-                return ((telsize >> 1) >= felsize);
+            if (felsize < 8) {
+                return (telsize >> 1) > felsize;
+            }
+            else {
+                return (telsize >> 1) >= felsize;
+            }
         }
-        else return totype > fromtype;
+        else {
+            return totype > fromtype;
+        }
     case PyArray_FLOAT:
     case PyArray_DOUBLE:
     case PyArray_LONGDOUBLE:
-        if (PyTypeNum_ISCOMPLEX(totype))
-            return ((telsize >> 1) >= felsize);
-        else
-            return (totype > fromtype);
+        if (PyTypeNum_ISCOMPLEX(totype)) {
+            return (telsize >> 1) >= felsize;
+        }
+        else {
+            return totype > fromtype;
+        }
     case PyArray_CFLOAT:
     case PyArray_CDOUBLE:
     case PyArray_CLONGDOUBLE:
-        return (totype > fromtype);
+        return totype > fromtype;
     case PyArray_STRING:
     case PyArray_UNICODE:
-        return (totype > fromtype);
+        return totype > fromtype;
     default:
         return 0;
     }
 }
 
-/* leaves reference count alone --- cannot be NULL*/
-/*NUMPY_API*/
+/*NUMPY_API
+ * leaves reference count alone --- cannot be NULL
+ */
 static Bool
 PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)
 {
@@ -9472,14 +9732,14 @@
     Bool ret;
 
     ret = (Bool) PyArray_CanCastSafely(fromtype, totype);
-    if (ret) { /* Check String and Unicode more closely */
+    if (ret) {
+        /* Check String and Unicode more closely */
         if (fromtype == PyArray_STRING) {
             if (totype == PyArray_STRING) {
                 ret = (from->elsize <= to->elsize);
             }
             else if (totype == PyArray_UNICODE) {
-                ret = (from->elsize << 2 \
-                       <= to->elsize);
+                ret = (from->elsize << 2 <= to->elsize);
             }
         }
         else if (fromtype == PyArray_UNICODE) {
@@ -9487,17 +9747,18 @@
                 ret = (from->elsize <= to->elsize);
             }
         }
-        /* TODO: If totype is STRING or unicode
-           see if the length is long enough to hold the
-           stringified value of the object.
-        */
+        /*
+         * TODO: If totype is STRING or unicode
+         * see if the length is long enough to hold the
+         * stringified value of the object.
+         */
     }
     return ret;
 }
 
 /*NUMPY_API
-  See if array scalars can be cast.
-*/
+ * See if array scalars can be cast.
+ */
 static Bool
 PyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to)
 {
@@ -9506,8 +9767,9 @@
 
     fromtype = _typenum_fromtypeobj((PyObject *)from, 0);
     totype = _typenum_fromtypeobj((PyObject *)to, 0);
-    if (fromtype == PyArray_NOTYPE || totype == PyArray_NOTYPE)
+    if (fromtype == PyArray_NOTYPE || totype == PyArray_NOTYPE) {
         return FALSE;
+    }
     return (Bool) PyArray_CanCastSafely(fromtype, totype);
 }
 
@@ -9517,8 +9779,8 @@
 /*         and Python's array iterator                                   ***/
 
 /*NUMPY_API
-  Get Iterator.
-*/
+ * Get Iterator.
+ */
 static PyObject *
 PyArray_IterNew(PyObject *obj)
 {
@@ -9534,26 +9796,29 @@
     it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));
     PyObject_Init((PyObject *)it, &PyArrayIter_Type);
     /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/
-    if (it == NULL)
+    if (it == NULL) {
         return NULL;
-
+    }
     nd = ao->nd;
     PyArray_UpdateFlags(ao, CONTIGUOUS);
-    if PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;
-    else it->contiguous = 0;
+    if (PyArray_ISCONTIGUOUS(ao)) {
+        it->contiguous = 1;
+    }
+    else {
+        it->contiguous = 0;
+    }
     Py_INCREF(ao);
     it->ao = ao;
     it->size = PyArray_SIZE(ao);
     it->nd_m1 = nd - 1;
     it->factors[nd-1] = 1;
-    for(i=0; i < nd; i++) {
+    for (i = 0; i < nd; i++) {
         it->dims_m1[i] = ao->dimensions[i] - 1;
         it->strides[i] = ao->strides[i];
-        it->backstrides[i] = it->strides[i] *   \
-            it->dims_m1[i];
-        if (i > 0)
-            it->factors[nd-i-1] = it->factors[nd-i] *       \
-                ao->dimensions[nd-i];
+        it->backstrides[i] = it->strides[i] * it->dims_m1[i];
+        if (i > 0) {
+            it->factors[nd-i-1] = it->factors[nd-i] * ao->dimensions[nd-i];
+        }
     }
     PyArray_ITER_RESET(it);
 
@@ -9561,8 +9826,8 @@
 }
 
 /*NUMPY_API
-  Get Iterator broadcast to a particular shape
-*/
+ * Get Iterator broadcast to a particular shape
+ */
 static PyObject *
 PyArray_BroadcastToShape(PyObject *obj, intp *dims, int nd)
 {
@@ -9570,51 +9835,57 @@
     int i, diff, j, compat, k;
     PyArrayObject *ao = (PyArrayObject *)obj;
 
-    if (ao->nd > nd) goto err;
+    if (ao->nd > nd) {
+        goto err;
+    }
     compat = 1;
     diff = j = nd - ao->nd;
-    for(i=0; i<ao->nd; i++, j++) {
-        if (ao->dimensions[i] == 1) continue;
+    for (i = 0; i < ao->nd; i++, j++) {
+        if (ao->dimensions[i] == 1) {
+            continue;
+        }
         if (ao->dimensions[i] != dims[j]) {
             compat = 0;
             break;
         }
     }
-    if (!compat) goto err;
-
+    if (!compat) {
+        goto err;
+    }
     it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));
     PyObject_Init((PyObject *)it, &PyArrayIter_Type);
 
-    if (it == NULL)
+    if (it == NULL) {
         return NULL;
-
+    }
     PyArray_UpdateFlags(ao, CONTIGUOUS);
-    if PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;
-    else it->contiguous = 0;
+    if (PyArray_ISCONTIGUOUS(ao)) {
+        it->contiguous = 1;
+    }
+    else {
+        it->contiguous = 0;
+    }
     Py_INCREF(ao);
     it->ao = ao;
     it->size = PyArray_MultiplyList(dims, nd);
     it->nd_m1 = nd - 1;
     it->factors[nd-1] = 1;
-    for(i=0; i < nd; i++) {
+    for (i = 0; i < nd; i++) {
         it->dims_m1[i] = dims[i] - 1;
         k = i - diff;
-        if ((k < 0) ||
-            ao->dimensions[k] != dims[i]) {
+        if ((k < 0) || ao->dimensions[k] != dims[i]) {
             it->contiguous = 0;
             it->strides[i] = 0;
         }
         else {
             it->strides[i] = ao->strides[k];
         }
-        it->backstrides[i] = it->strides[i] *   \
-            it->dims_m1[i];
-        if (i > 0)
-            it->factors[nd-i-1] = it->factors[nd-i] *       \
-                dims[nd-i];
+        it->backstrides[i] = it->strides[i] * it->dims_m1[i];
+        if (i > 0) {
+            it->factors[nd-i-1] = it->factors[nd-i] * dims[nd-i];
+        }
     }
     PyArray_ITER_RESET(it);
-
     return (PyObject *)it;
 
  err:
@@ -9628,29 +9899,31 @@
 
 
 /*NUMPY_API
-  Get Iterator that iterates over all but one axis (don't use this with
-  PyArray_ITER_GOTO1D).  The axis will be over-written if negative
-  with the axis having the smallest stride.
-*/
+ * Get Iterator that iterates over all but one axis (don't use this with
+ * PyArray_ITER_GOTO1D).  The axis will be over-written if negative
+ * with the axis having the smallest stride.
+ */
 static PyObject *
 PyArray_IterAllButAxis(PyObject *obj, int *inaxis)
 {
     PyArrayIterObject *it;
     int axis;
     it = (PyArrayIterObject *)PyArray_IterNew(obj);
-    if (it == NULL) return NULL;
-
-    if (PyArray_NDIM(obj)==0)
+    if (it == NULL) {
+        return NULL;
+    }
+    if (PyArray_NDIM(obj)==0) {
         return (PyObject *)it;
+    }
     if (*inaxis < 0) {
-        int i, minaxis=0;
-        intp minstride=0;
+        int i, minaxis = 0;
+        intp minstride = 0;
         i = 0;
-        while (minstride==0 && i<PyArray_NDIM(obj)) {
+        while (minstride == 0 && i < PyArray_NDIM(obj)) {
             minstride = PyArray_STRIDE(obj,i);
             i++;
         }
-        for(i=1; i<PyArray_NDIM(obj); i++) {
+        for (i = 1; i < PyArray_NDIM(obj); i++) {
             if (PyArray_STRIDE(obj,i) > 0 &&
                 PyArray_STRIDE(obj, i) < minstride) {
                 minaxis = i;
@@ -9668,21 +9941,21 @@
     it->dims_m1[axis] = 0;
     it->backstrides[axis] = 0;
 
-    /* (won't fix factors so don't use
-       PyArray_ITER_GOTO1D with this iterator) */
+    /*
+     * (won't fix factors so don't use
+     * PyArray_ITER_GOTO1D with this iterator)
+     */
     return (PyObject *)it;
 }
 
-
-/* don't use with PyArray_ITER_GOTO1D because factors are not
-   adjusted */
-
 /*NUMPY_API
-  Adjusts previously broadcasted iterators so that the axis with
-  the smallest sum of iterator strides is not iterated over.
-  Returns dimension which is smallest in the range [0,multi->nd).
-  A -1 is returned if multi->nd == 0.
-*/
+ * Adjusts previously broadcasted iterators so that the axis with
+ * the smallest sum of iterator strides is not iterated over.
+ * Returns dimension which is smallest in the range [0,multi->nd).
+ * A -1 is returned if multi->nd == 0.
+ *
+ * don't use with PyArray_ITER_GOTO1D because factors are not adjusted
+ */
 static int
 PyArray_RemoveSmallest(PyArrayMultiIterObject *multi)
 {
@@ -9692,34 +9965,33 @@
     intp smallest;
     intp sumstrides[NPY_MAXDIMS];
 
-    if (multi->nd == 0) return -1;
-
-
-    for(i=0; i<multi->nd; i++) {
+    if (multi->nd == 0) {
+        return -1;
+    }
+    for (i = 0; i < multi->nd; i++) {
         sumstrides[i] = 0;
-        for(j=0; j<multi->numiter; j++) {
+        for (j = 0; j < multi->numiter; j++) {
             sumstrides[i] += multi->iters[j]->strides[i];
         }
     }
-    axis=0;
+    axis = 0;
     smallest = sumstrides[0];
     /* Find longest dimension */
-    for(i=1; i<multi->nd; i++) {
+    for (i = 1; i < multi->nd; i++) {
         if (sumstrides[i] < smallest) {
             axis = i;
             smallest = sumstrides[i];
         }
     }
-
-    for(i=0; i<multi->numiter; i++) {
+    for(i = 0; i < multi->numiter; i++) {
         it = multi->iters[i];
         it->contiguous = 0;
-        if (it->size != 0)
+        if (it->size != 0) {
             it->size /= (it->dims_m1[axis]+1);
+        }
         it->dims_m1[axis] = 0;
         it->backstrides[axis] = 0;
     }
-
     multi->size = multi->iters[0]->size;
     return axis;
 }
@@ -9757,7 +10029,7 @@
 iter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)
 {
     int index, strides, itemsize;
-    intp count=0;
+    intp count = 0;
     char *dptr, *optr;
     PyObject *r;
     int swap;
@@ -9779,9 +10051,10 @@
     strides = ind->strides[0];
     dptr = ind->data;
     /* Get size of return array */
-    while(index--) {
-        if (*((Bool *)dptr) != 0)
+    while (index--) {
+        if (*((Bool *)dptr) != 0) {
             count++;
+        }
         dptr += strides;
     }
     itemsize = self->ao->descr->elsize;
@@ -9790,17 +10063,17 @@
                              self->ao->descr, 1, &count,
                              NULL, NULL,
                              0, (PyObject *)self->ao);
-    if (r==NULL) return NULL;
-
+    if (r == NULL) {
+        return NULL;
+    }
     /* Set up loop */
     optr = PyArray_DATA(r);
     index = ind->dimensions[0];
     dptr = ind->data;
-
     copyswap = self->ao->descr->f->copyswap;
     /* Loop over Boolean array */
     swap = (PyArray_ISNOTSWAPPED(self->ao) != PyArray_ISNOTSWAPPED(r));
-    while(index--) {
+    while (index--) {
         if (*((Bool *)dptr) != 0) {
             copyswap(optr, self->dataptr, swap, self->ao);
             optr += itemsize;
@@ -9827,7 +10100,9 @@
     itemsize = self->ao->descr->elsize;
     if (ind->nd == 0) {
         num = *((intp *)ind->data);
-        if (num < 0) num += self->size;
+        if (num < 0) {
+            num += self->size;
+        }
         if (num < 0 || num >= self->size) {
             PyErr_Format(PyExc_IndexError,
                          "index %d out of bounds"   \
@@ -9848,17 +10123,23 @@
                              ind->nd, ind->dimensions,
                              NULL, NULL,
                              0, (PyObject *)self->ao);
-    if (r==NULL) return NULL;
-
+    if (r == NULL) {
+        return NULL;
+    }
     optr = PyArray_DATA(r);
     ind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);
-    if (ind_it == NULL) {Py_DECREF(r); return NULL;}
+    if (ind_it == NULL) {
+        Py_DECREF(r);
+        return NULL;
+    }
     index = ind_it->size;
     copyswap = PyArray_DESCR(r)->f->copyswap;
     swap = (PyArray_ISNOTSWAPPED(r) != PyArray_ISNOTSWAPPED(self->ao));
-    while(index--) {
+    while (index--) {
         num = *((intp *)(ind_it->dataptr));
-        if (num < 0) num += self->size;
+        if (num < 0) {
+            num += self->size;
+        }
         if (num < 0 || num >= self->size) {
             PyErr_Format(PyExc_IndexError,
                          "index %d out of bounds"           \
@@ -9883,7 +10164,7 @@
 static PyObject *
 iter_subscript(PyArrayIterObject *self, PyObject *ind)
 {
-    PyArray_Descr *indtype=NULL;
+    PyArray_Descr *indtype = NULL;
     intp start, step_size;
     intp n_steps;
     PyObject *r;
@@ -9901,7 +10182,9 @@
     if (PyTuple_Check(ind)) {
         int len;
         len = PyTuple_GET_SIZE(ind);
-        if (len > 1) goto fail;
+        if (len > 1) {
+            goto fail;
+        }
         if (len == 0) {
             Py_INCREF(self->ao);
             return (PyObject *)self->ao;
@@ -9909,12 +10192,11 @@
         ind = PyTuple_GET_ITEM(ind, 0);
     }
 
-    /* Tuples >1d not accepted --- i.e. no newaxis */
-    /* Could implement this with adjusted strides
-       and dimensions in iterator */
-
-    /* Check for Boolean -- this is first becasue
-       Bool is a subclass of Int */
+    /*
+     * Tuples >1d not accepted --- i.e. no newaxis
+     * Could implement this with adjusted strides and dimensions in iterator
+     * Check for Boolean -- this is first becasue Bool is a subclass of Int
+     */
     PyArray_ITER_RESET(self);
 
     if (PyBool_Check(ind)) {
@@ -9934,12 +10216,12 @@
     }
 
     /* Check for Integer or Slice */
-
     if (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {
         start = parse_subindex(ind, &step_size, &n_steps,
                                self->size);
-        if (start == -1)
+        if (start == -1) {
             goto fail;
+        }
         if (n_steps == RubberIndex || n_steps == PseudoIndex) {
             PyErr_SetString(PyExc_IndexError,
                             "cannot use Ellipsis or newaxes here");
@@ -9958,10 +10240,12 @@
                                  1, &n_steps,
                                  NULL, NULL,
                                  0, (PyObject *)self->ao);
-        if (r==NULL) goto fail;
+        if (r == NULL) {
+            goto fail;
+        }
         dptr = PyArray_DATA(r);
         copyswap = PyArray_DESCR(r)->f->copyswap;
-        while(n_steps--) {
+        while (n_steps--) {
             copyswap(dptr, self->dataptr, 0, r);
             start += step_size;
             PyArray_ITER_GOTO1D(self, start)
@@ -9972,12 +10256,13 @@
     }
 
     /* convert to INTP array if Integer array scalar or List */
-
     indtype = PyArray_DescrFromType(PyArray_INTP);
     if (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {
         Py_INCREF(indtype);
         obj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST, NULL);
-        if (obj == NULL) goto fail;
+        if (obj == NULL) {
+            goto fail;
+        }
     }
     else {
         Py_INCREF(ind);
@@ -9995,7 +10280,9 @@
             PyObject *new;
             new = PyArray_FromAny(obj, indtype, 0, 0,
                                   FORCECAST | ALIGNED, NULL);
-            if (new==NULL) goto fail;
+            if (new == NULL) {
+                goto fail;
+            }
             Py_DECREF(obj);
             obj = new;
             r = iter_subscript_int(self, (PyArrayObject *)obj);
@@ -10006,12 +10293,15 @@
         Py_DECREF(obj);
         return r;
     }
-    else Py_DECREF(indtype);
+    else {
+        Py_DECREF(indtype);
+    }
 
 
  fail:
-    if (!PyErr_Occurred())
+    if (!PyErr_Occurred()) {
         PyErr_SetString(PyExc_IndexError, "unsupported iterator index");
+    }
     Py_XDECREF(indtype);
     Py_XDECREF(obj);
     return NULL;
@@ -10045,12 +10335,13 @@
     PyArray_ITER_RESET(self);
     /* Loop over Boolean array */
     copyswap = self->ao->descr->f->copyswap;
-    while(index--) {
+    while (index--) {
         if (*((Bool *)dptr) != 0) {
             copyswap(self->dataptr, val->dataptr, swap, self->ao);
             PyArray_ITER_NEXT(val);
-            if (val->index==val->size)
+            if (val->index == val->size) {
                 PyArray_ITER_RESET(val);
+            }
         }
         dptr += strides;
         PyArray_ITER_NEXT(self);
@@ -10078,11 +10369,15 @@
         return 0;
     }
     ind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);
-    if (ind_it == NULL) return -1;
+    if (ind_it == NULL) {
+        return -1;
+    }
     index = ind_it->size;
-    while(index--) {
+    while (index--) {
         num = *((intp *)(ind_it->dataptr));
-        if (num < 0) num += self->size;
+        if (num < 0) {
+            num += self->size;
+        }
         if ((num < 0) || (num >= self->size)) {
             PyErr_Format(PyExc_IndexError,
                          "index %d out of bounds"           \
@@ -10095,8 +10390,9 @@
         copyswap(self->dataptr, val->dataptr, swap, self->ao);
         PyArray_ITER_NEXT(ind_it);
         PyArray_ITER_NEXT(val);
-        if (val->index == val->size)
+        if (val->index == val->size) {
             PyArray_ITER_RESET(val);
+        }
     }
     Py_DECREF(ind_it);
     return 0;
@@ -10105,14 +10401,14 @@
 static int
 iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)
 {
-    PyObject *arrval=NULL;
-    PyArrayIterObject *val_it=NULL;
+    PyObject *arrval = NULL;
+    PyArrayIterObject *val_it = NULL;
     PyArray_Descr *type;
-    PyArray_Descr *indtype=NULL;
-    int swap, retval=-1;
+    PyArray_Descr *indtype = NULL;
+    int swap, retval = -1;
     intp start, step_size;
     intp n_steps;
-    PyObject *obj=NULL;
+    PyObject *obj = NULL;
     PyArray_CopySwapFunc *copyswap;
 
 
@@ -10126,15 +10422,18 @@
     if (PyTuple_Check(ind)) {
         int len;
         len = PyTuple_GET_SIZE(ind);
-        if (len > 1) goto finish;
+        if (len > 1) {
+            goto finish;
+        }
         ind = PyTuple_GET_ITEM(ind, 0);
     }
 
     type = self->ao->descr;
 
-    /* Check for Boolean -- this is first becasue
-       Bool is a subclass of Int */
-
+    /*
+     * Check for Boolean -- this is first becasue
+     * Bool is a subclass of Int
+     */
     if (PyBool_Check(ind)) {
         retval = 0;
         if (PyObject_IsTrue(ind)) {
@@ -10143,9 +10442,13 @@
         goto finish;
     }
 
-    if (PySequence_Check(ind) || PySlice_Check(ind)) goto skip;
+    if (PySequence_Check(ind) || PySlice_Check(ind)) {
+        goto skip;
+    }
     start = PyArray_PyIntAsIntp(ind);
-    if (start==-1 && PyErr_Occurred()) PyErr_Clear();
+    if (start==-1 && PyErr_Occurred()) {
+        PyErr_Clear();
+    }
     else {
         if (start < -self->size || start >= self->size) {
             PyErr_Format(PyExc_ValueError,
@@ -10167,41 +10470,48 @@
  skip:
     Py_INCREF(type);
     arrval = PyArray_FromAny(val, type, 0, 0, 0, NULL);
-    if (arrval==NULL) return -1;
+    if (arrval == NULL) {
+        return -1;
+    }
     val_it = (PyArrayIterObject *)PyArray_IterNew(arrval);
-    if (val_it==NULL) goto finish;
-    if (val_it->size == 0) {retval = 0; goto finish;}
+    if (val_it == NULL) {
+        goto finish;
+    }
+    if (val_it->size == 0) {
+        retval = 0;
+        goto finish;
+    }
 
     copyswap = PyArray_DESCR(arrval)->f->copyswap;
     swap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));
 
     /* Check Slice */
-
     if (PySlice_Check(ind)) {
-        start = parse_subindex(ind, &step_size, &n_steps,
-                               self->size);
-        if (start == -1) goto finish;
+        start = parse_subindex(ind, &step_size, &n_steps, self->size);
+        if (start == -1) {
+            goto finish;
+        }
         if (n_steps == RubberIndex || n_steps == PseudoIndex) {
             PyErr_SetString(PyExc_IndexError,
                             "cannot use Ellipsis or newaxes here");
             goto finish;
         }
         PyArray_ITER_GOTO1D(self, start);
-        if (n_steps == SingleIndex) { /* Integer */
-            copyswap(self->dataptr, PyArray_DATA(arrval),
-                     swap, arrval);
+        if (n_steps == SingleIndex) {
+            /* Integer */
+            copyswap(self->dataptr, PyArray_DATA(arrval), swap, arrval);
             PyArray_ITER_RESET(self);
-            retval=0;
+            retval = 0;
             goto finish;
         }
-        while(n_steps--) {
-            copyswap(self->dataptr, val_it->dataptr,
-                     swap, arrval);
+        while (n_steps--) {
+            copyswap(self->dataptr, val_it->dataptr, swap, arrval);
             start += step_size;
-            PyArray_ITER_GOTO1D(self, start)
-                PyArray_ITER_NEXT(val_it);
-            if (val_it->index == val_it->size)
+            PyArray_ITER_GOTO1D(self, start);
+            PyArray_ITER_NEXT(val_it);
+            if (val_it->index == val_it->size) {
                 PyArray_ITER_RESET(val_it);
+            }
         }
         PyArray_ITER_RESET(self);
         retval = 0;
@@ -10209,7 +10519,6 @@
     }
 
     /* convert to INTP array if Integer array scalar or List */
-
     indtype = PyArray_DescrFromType(PyArray_INTP);
     if (PyList_Check(ind)) {
         Py_INCREF(indtype);
@@ -10224,8 +10533,9 @@
         /* Check for Boolean object */
         if (PyArray_TYPE(obj)==PyArray_BOOL) {
             if (iter_ass_sub_Bool(self, (PyArrayObject *)obj,
-                                  val_it, swap) < 0)
+                                  val_it, swap) < 0) {
                 goto finish;
+            }
             retval=0;
         }
         /* Check for integer array */
@@ -10236,18 +10546,21 @@
                                        FORCECAST | BEHAVED_NS, NULL);
             Py_DECREF(obj);
             obj = new;
-            if (new==NULL) goto finish;
+            if (new == NULL) {
+                goto finish;
+            }
             if (iter_ass_sub_int(self, (PyArrayObject *)obj,
-                                 val_it, swap) < 0)
+                                 val_it, swap) < 0) {
                 goto finish;
-            retval=0;
+            }
+            retval = 0;
         }
     }
 
  finish:
-    if (!PyErr_Occurred() && retval < 0)
-        PyErr_SetString(PyExc_IndexError,
-                        "unsupported iterator index");
+    if (!PyErr_Occurred() && retval < 0) {
+        PyErr_SetString(PyExc_IndexError, "unsupported iterator index");
+    }
     Py_XDECREF(indtype);
     Py_XDECREF(obj);
     Py_XDECREF(val_it);
@@ -10279,13 +10592,12 @@
     /* Any argument ignored */
 
     /* Two options:
-       1) underlying array is contiguous
-       -- return 1-d wrapper around it
-       2) underlying array is not contiguous
-       -- make new 1-d contiguous array with updateifcopy flag set
-       to copy back to the old array
-    */
-
+     *  1) underlying array is contiguous
+     *  -- return 1-d wrapper around it
+     * 2) underlying array is not contiguous
+     * -- make new 1-d contiguous array with updateifcopy flag set
+     * to copy back to the old array
+     */
     size = PyArray_SIZE(it->ao);
     Py_INCREF(it->ao->descr);
     if (PyArray_ISCONTIGUOUS(it->ao)) {
@@ -10295,7 +10607,9 @@
                                  NULL, it->ao->data,
                                  it->ao->flags,
                                  (PyObject *)it->ao);
-        if (r==NULL) return NULL;
+        if (r == NULL) {
+            return NULL;
+        }
     }
     else {
         r = PyArray_NewFromDescr(&PyArray_Type,
@@ -10303,7 +10617,9 @@
                                  1, &size,
                                  NULL, NULL,
                                  0, (PyObject *)it->ao);
-        if (r==NULL) return NULL;
+        if (r == NULL) {
+            return NULL;
+        }
         if (_flat_copyinto(r, (PyObject *)it->ao,
                            PyArray_CORDER) < 0) {
             Py_DECREF(r);
@@ -10321,7 +10637,9 @@
 static PyObject *
 iter_copy(PyArrayIterObject *it, PyObject *args)
 {
-    if (!PyArg_ParseTuple(args, "")) return NULL;
+    if (!PyArg_ParseTuple(args, "")) {
+        return NULL;
+    }
     return PyArray_Flatten(it->ao, 0);
 }
 
@@ -10338,7 +10656,9 @@
     PyArrayObject *new;
     PyObject *ret;
     new = (PyArrayObject *)iter_array(self, NULL);
-    if (new == NULL) return NULL;
+    if (new == NULL) {
+        return NULL;
+    }
     ret = array_richcompare(new, other, cmp_op);
     Py_DECREF(new);
     return ret;
@@ -10356,12 +10676,15 @@
 {
     int nd;
     nd = self->ao->nd;
-    if (self->contiguous) { /* coordinates not kept track of --- need to generate
-                               from index */
+    if (self->contiguous) {
+        /*
+         * coordinates not kept track of ---
+         * need to generate from index
+         */
         intp val;
         int i;
         val = self->index;
-        for(i=0;i<nd; i++) {
+        for (i = 0; i < nd; i++) {
             self->coordinates[i] = val / self->factors[i];
             val = val % self->factors[i];
         }
@@ -10378,60 +10701,60 @@
 
 static PyTypeObject PyArrayIter_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                       /* ob_size */
-    "numpy.flatiter",                        /* tp_name */
-    sizeof(PyArrayIterObject),               /* tp_basicsize */
-    0,                                       /* tp_itemsize */
+    0,                                           /* ob_size */
+    "numpy.flatiter",                            /* tp_name */
+    sizeof(PyArrayIterObject),                   /* tp_basicsize */
+    0,                                           /* tp_itemsize */
     /* methods */
-    (destructor)arrayiter_dealloc,          /* tp_dealloc */
-    0,                                      /* tp_print */
-    0,                                      /* tp_getattr */
-    0,                                      /* tp_setattr */
-    0,                                      /* tp_compare */
-    0,                                      /* tp_repr */
-    0,                                      /* tp_as_number */
-    0,                                      /* tp_as_sequence */
-    &iter_as_mapping,                       /* tp_as_mapping */
-    0,                                      /* tp_hash */
-    0,                                      /* tp_call */
-    0,                                      /* tp_str */
-    0,                                      /* tp_getattro */
-    0,                                      /* tp_setattro */
-    0,                                      /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                     /* tp_flags */
-    0,                                      /* tp_doc */
-    0,                                      /* tp_traverse */
-    0,                                      /* tp_clear */
-    (richcmpfunc)iter_richcompare,          /* tp_richcompare */
-    0,                                      /* tp_weaklistoffset */
-    0,                              /* tp_iter */
-    (iternextfunc)arrayiter_next,           /* tp_iternext */
-    iter_methods,                           /* tp_methods */
-    iter_members,                   /* tp_members */
-    iter_getsets,                           /* tp_getset */
-    0,                                          /* tp_base */
-    0,                                          /* tp_dict */
-    0,                                          /* tp_descr_get */
-    0,                                          /* tp_descr_set */
-    0,   				    /* tp_dictoffset */
-    0,   				    /* tp_init */
-    0,   				    /* tp_alloc */
-    0,   				    /* tp_new */
-    0,   				    /* tp_free */
-    0,   				    /* tp_is_gc */
-    0,   				    /* tp_bases */
-    0,   				    /* tp_mro */
-    0,   				    /* tp_cache */
-    0,   				    /* tp_subclasses */
-    0,   				    /* tp_weaklist */
-    0,   				    /* tp_del */
+    (destructor)arrayiter_dealloc,               /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    0,                                           /* tp_as_sequence */
+    &iter_as_mapping,                            /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    0,                                           /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                          /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    (richcmpfunc)iter_richcompare,               /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    (iternextfunc)arrayiter_next,                /* tp_iternext */
+    iter_methods,                                /* tp_methods */
+    iter_members,                                /* tp_members */
+    iter_getsets,                                /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,   				         /* tp_dictoffset */
+    0,   				         /* tp_init */
+    0,   				         /* tp_alloc */
+    0,   				         /* tp_new */
+    0,   				         /* tp_free */
+    0,   				         /* tp_is_gc */
+    0,   				         /* tp_bases */
+    0,   				         /* tp_mro */
+    0,   				         /* tp_cache */
+    0,   				         /* tp_subclasses */
+    0,   				         /* tp_weaklist */
+    0,   				         /* tp_del */
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 
 };
@@ -10462,18 +10785,23 @@
     PyArray_Descr *indtype;
     PyObject *arr;
 
-    if (PySlice_Check(obj) || (obj == Py_Ellipsis))
+    if (PySlice_Check(obj) || (obj == Py_Ellipsis)) {
         return 0;
+    }
     else if (PyArray_Check(obj) && PyArray_ISBOOL(obj)) {
         return _nonzero_indices(obj, iter);
     }
     else {
         indtype = PyArray_DescrFromType(PyArray_INTP);
         arr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST, NULL);
-        if (arr == NULL) return -1;
+        if (arr == NULL) {
+            return -1;
+        }
         *iter = (PyArrayIterObject *)PyArray_IterNew(arr);
         Py_DECREF(arr);
-        if (*iter == NULL) return -1;
+        if (*iter == NULL) {
+            return -1;
+        }
     }
     return 1;
 }
@@ -10490,23 +10818,26 @@
     PyArrayIterObject *it;
 
     /* Discover the broadcast number of dimensions */
-    for(i=0, nd=0; i<mit->numiter; i++)
+    for (i = 0, nd = 0; i < mit->numiter; i++) {
         nd = MAX(nd, mit->iters[i]->ao->nd);
+    }
     mit->nd = nd;
 
     /* Discover the broadcast shape in each dimension */
-    for(i=0; i<nd; i++) {
+    for (i = 0; i < nd; i++) {
         mit->dimensions[i] = 1;
-        for(j=0; j<mit->numiter; j++) {
+        for (j = 0; j < mit->numiter; j++) {
             it = mit->iters[j];
-            /* This prepends 1 to shapes not already
-               equal to nd */
+            /* This prepends 1 to shapes not already equal to nd */
             k = i + it->ao->nd - nd;
-            if (k>=0) {
+            if (k >= 0) {
                 tmp = it->ao->dimensions[k];
-                if (tmp == 1) continue;
-                if (mit->dimensions[i] == 1)
+                if (tmp == 1) {
+                    continue;
+                }
+                if (mit->dimensions[i] == 1) {
                     mit->dimensions[i] = tmp;
+                }
                 else if (mit->dimensions[i] != tmp) {
                     PyErr_SetString(PyExc_ValueError,
                                     "shape mismatch: objects" \
@@ -10518,9 +10849,11 @@
         }
     }
 
-    /* Reset the iterator dimensions and strides of each iterator
-       object -- using 0 valued strides for broadcasting */
-    /* Need to check for overflow */
+    /*
+     * Reset the iterator dimensions and strides of each iterator
+     * object -- using 0 valued strides for broadcasting
+     * Need to check for overflow
+     */
     tmp = PyArray_OverflowMultiplyList(mit->dimensions, mit->nd);
     if (tmp < 0) {
 	PyErr_SetString(PyExc_ValueError, 
@@ -10528,18 +10861,20 @@
 	return -1;
     }
     mit->size = tmp;
-    for(i=0; i<mit->numiter; i++) {
+    for (i = 0; i < mit->numiter; i++) {
         it = mit->iters[i];
         it->nd_m1 = mit->nd - 1;
         it->size = tmp;
         nd = it->ao->nd;
         it->factors[mit->nd-1] = 1;
-        for(j=0; j < mit->nd; j++) {
+        for (j = 0; j < mit->nd; j++) {
             it->dims_m1[j] = mit->dimensions[j] - 1;
             k = j + nd - mit->nd;
-            /* If this dimension was added or shape
-               of underlying array was 1 */
-            if ((k < 0) || \
+            /*
+             * If this dimension was added or shape of
+             * underlying array was 1
+             */
+            if ((k < 0) ||
                 it->ao->dimensions[k] != mit->dimensions[j]) {
                 it->contiguous = 0;
                 it->strides[j] = 0;
@@ -10547,12 +10882,10 @@
             else {
                 it->strides[j] = it->ao->strides[k];
             }
-            it->backstrides[j] = it->strides[j] *   \
-                it->dims_m1[j];
+            it->backstrides[j] = it->strides[j] * it->dims_m1[j];
             if (j > 0)
-                it->factors[mit->nd-j-1] =              \
-                    it->factors[mit->nd-j] *        \
-                    mit->dimensions[mit->nd-j];
+                it->factors[mit->nd-j-1] =
+                    it->factors[mit->nd-j] * mit->dimensions[mit->nd-j];
         }
         PyArray_ITER_RESET(it);
     }
@@ -10574,12 +10907,11 @@
     if (mit->subspace != NULL) {
         memcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);
         PyArray_ITER_RESET(mit->subspace);
-        for(i=0; i<mit->numiter; i++) {
+        for (i = 0; i < mit->numiter; i++) {
             it = mit->iters[i];
             PyArray_ITER_RESET(it);
             j = mit->iteraxes[i];
-            copyswap(coord+j,it->dataptr,
-                     !PyArray_ISNOTSWAPPED(it->ao),
+            copyswap(coord+j,it->dataptr, !PyArray_ISNOTSWAPPED(it->ao),
                      it->ao);
         }
         PyArray_ITER_GOTO(mit->ait, coord);
@@ -10587,15 +10919,16 @@
         mit->dataptr = mit->subspace->dataptr;
     }
     else {
-        for(i=0; i<mit->numiter; i++) {
+        for (i = 0; i < mit->numiter; i++) {
             it = mit->iters[i];
             if (it->size != 0) {
                 PyArray_ITER_RESET(it);
-                copyswap(coord+i,it->dataptr,
-                         !PyArray_ISNOTSWAPPED(it->ao),
+                copyswap(coord+i,it->dataptr, !PyArray_ISNOTSWAPPED(it->ao),
                          it->ao);
             }
-            else coord[i] = 0;
+            else {
+                coord[i] = 0;
+            }
         }
         PyArray_ITER_GOTO(mit->ait, coord);
         mit->dataptr = mit->ait->dataptr;
@@ -10603,9 +10936,10 @@
     return;
 }
 
-/* This function needs to update the state of the map iterator
-   and point mit->dataptr to the memory-location of the next object
-*/
+/*
+ * This function needs to update the state of the map iterator
+ * and point mit->dataptr to the memory-location of the next object
+ */
 static void
 PyArray_MapIterNext(PyArrayMapIterObject *mit)
 {
@@ -10615,23 +10949,22 @@
     PyArray_CopySwapFunc *copyswap;
 
     mit->index += 1;
-    if (mit->index >= mit->size) return;
+    if (mit->index >= mit->size) {
+        return;
+    }
     copyswap = mit->iters[0]->ao->descr->f->copyswap;
     /* Sub-space iteration */
     if (mit->subspace != NULL) {
         PyArray_ITER_NEXT(mit->subspace);
         if (mit->subspace->index >= mit->subspace->size) {
-            /* reset coord to coordinates of
-               beginning of the subspace */
-            memcpy(coord, mit->bscoord,
-                   sizeof(intp)*mit->ait->ao->nd);
+            /* reset coord to coordinates of beginning of the subspace */
+            memcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);
             PyArray_ITER_RESET(mit->subspace);
-            for(i=0; i<mit->numiter; i++) {
+            for (i = 0; i < mit->numiter; i++) {
                 it = mit->iters[i];
                 PyArray_ITER_NEXT(it);
                 j = mit->iteraxes[i];
-                copyswap(coord+j,it->dataptr,
-                         !PyArray_ISNOTSWAPPED(it->ao),
+                copyswap(coord+j,it->dataptr, !PyArray_ISNOTSWAPPED(it->ao),
                          it->ao);
             }
             PyArray_ITER_GOTO(mit->ait, coord);
@@ -10640,7 +10973,7 @@
         mit->dataptr = mit->subspace->dataptr;
     }
     else {
-        for(i=0; i<mit->numiter; i++) {
+        for (i = 0; i < mit->numiter; i++) {
             it = mit->iters[i];
             PyArray_ITER_NEXT(it);
             copyswap(coord+i,it->dataptr,
@@ -10653,26 +10986,26 @@
     return;
 }
 
-/*  Bind a mapiteration to a particular array */
-
-/*  Determine if subspace iteration is necessary.  If so,
-    1) Fill in mit->iteraxes
-    2) Create subspace iterator
-    3) Update nd, dimensions, and size.
-
-    Subspace iteration is necessary if:  arr->nd > mit->numiter
-*/
-
-/* Need to check for index-errors somewhere.
-
-   Let's do it at bind time and also convert all <0 values to >0 here
-   as well.
-*/
+/*
+ * Bind a mapiteration to a particular array
+ *
+ *  Determine if subspace iteration is necessary.  If so,
+ *  1) Fill in mit->iteraxes
+ *  2) Create subspace iterator
+ *  3) Update nd, dimensions, and size.
+ *
+ *  Subspace iteration is necessary if:  arr->nd > mit->numiter
+ *
+ * Need to check for index-errors somewhere.
+ *
+ * Let's do it at bind time and also convert all <0 values to >0 here
+ * as well.
+ */
 static void
 PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)
 {
     int subnd;
-    PyObject *sub, *obj=NULL;
+    PyObject *sub, *obj = NULL;
     int i, j, n, curraxis, ellipexp, noellip;
     PyArrayIterObject *it;
     intp dimsize;
@@ -10686,22 +11019,24 @@
     }
 
     mit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);
-    if (mit->ait == NULL) return;
-
+    if (mit->ait == NULL) {
+        return;
+    }
     /* no subspace iteration needed.  Finish up and Return */
     if (subnd == 0) {
         n = arr->nd;
-        for(i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             mit->iteraxes[i] = i;
         }
         goto finish;
     }
 
-    /* all indexing arrays have been converted to 0
-       therefore we can extract the subspace with a simple
-       getitem call which will use view semantics
-    */
-    /* But, be sure to do it with a true array.
+    /*
+     * all indexing arrays have been converted to 0
+     * therefore we can extract the subspace with a simple
+     * getitem call which will use view semantics
+     *
+     * But, be sure to do it with a true array.
      */
     if (PyArray_CheckExact(arr)) {
         sub = array_subscript_simple(arr, mit->indexobj);
@@ -10709,54 +11044,65 @@
     else {
         Py_INCREF(arr);
         obj = PyArray_EnsureArray((PyObject *)arr);
-        if (obj == NULL) goto fail;
+        if (obj == NULL) {
+            goto fail;
+        }
         sub = array_subscript_simple((PyArrayObject *)obj, mit->indexobj);
         Py_DECREF(obj);
     }
 
-    if (sub == NULL) goto fail;
+    if (sub == NULL) {
+        goto fail;
+    }
     mit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);
     Py_DECREF(sub);
-    if (mit->subspace == NULL) goto fail;
-
+    if (mit->subspace == NULL) {
+        goto fail;
+    }
     /* Expand dimensions of result */
     n = mit->subspace->ao->nd;
-    for(i=0; i<n; i++)
+    for (i = 0; i < n; i++) {
         mit->dimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];
+    }
     mit->nd += n;
 
-    /* Now, we still need to interpret the ellipsis and slice objects
-       to determine which axes the indexing arrays are referring to
-    */
+    /*
+     * Now, we still need to interpret the ellipsis and slice objects
+     * to determine which axes the indexing arrays are referring to
+     */
     n = PyTuple_GET_SIZE(mit->indexobj);
-
     /* The number of dimensions an ellipsis takes up */
     ellipexp = arr->nd - n + 1;
-    /* Now fill in iteraxes -- remember indexing arrays have been
-       converted to 0's in mit->indexobj */
+    /*
+     * Now fill in iteraxes -- remember indexing arrays have been
+     * converted to 0's in mit->indexobj
+     */
     curraxis = 0;
     j = 0;
-    noellip = 1;  /* Only expand the first ellipsis */
+    /* Only expand the first ellipsis */
+    noellip = 1;
     memset(mit->bscoord, 0, sizeof(intp)*arr->nd);
-    for(i=0; i<n; i++) {
-        /* We need to fill in the starting coordinates for
-           the subspace */
+    for (i = 0; i < n; i++) {
+        /*
+         * We need to fill in the starting coordinates for
+         * the subspace
+         */
         obj = PyTuple_GET_ITEM(mit->indexobj, i);
-        if (PyInt_Check(obj) || PyLong_Check(obj))
+        if (PyInt_Check(obj) || PyLong_Check(obj)) {
             mit->iteraxes[j++] = curraxis++;
+        }
         else if (noellip && obj == Py_Ellipsis) {
             curraxis += ellipexp;
             noellip = 0;
         }
         else {
-            intp start=0;
+            intp start = 0;
             intp stop, step;
-            /* Should be slice object or
-               another Ellipsis */
+            /* Should be slice object or another Ellipsis */
             if (obj == Py_Ellipsis) {
                 mit->bscoord[curraxis] = 0;
             }
-            else if (!PySlice_Check(obj) || \
+            else if (!PySlice_Check(obj) ||
                      (slice_GetIndices((PySliceObject *)obj,
                                        arr->dimensions[curraxis],
                                        &start, &stop, &step,
@@ -10773,6 +11119,7 @@
             curraxis += 1;
         }
     }
+
  finish:
     /* Here check the indexes (now that we have iteraxes) */
     mit->size = PyArray_OverflowMultiplyList(mit->dimensions, mit->nd);
@@ -10787,15 +11134,17 @@
         goto fail;
     }
 
-    for(i=0; i<mit->numiter; i++) {
+    for (i = 0; i < mit->numiter; i++) {
         intp indval;
         it = mit->iters[i];
         PyArray_ITER_RESET(it);
         dimsize = arr->dimensions[mit->iteraxes[i]];
-        while(it->index < it->size) {
+        while (it->index < it->size) {
             indptr = ((intp *)it->dataptr);
             indval = *indptr;
-            if (indval < 0) indval += dimsize;
+            if (indval < 0) {
+                indval += dimsize;
+            }
             if (indval < 0 || indval >= dimsize) {
                 PyErr_Format(PyExc_IndexError,
                              "index (%d) out of range "\
@@ -10818,14 +11167,15 @@
     return;
 }
 
-/* This function takes a Boolean array and constructs index objects and
-   iterators as if nonzero(Bool) had been called
-*/
+/*
+ * This function takes a Boolean array and constructs index objects and
+ * iterators as if nonzero(Bool) had been called
+ */
 static int
 _nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)
 {
     PyArray_Descr *typecode;
-    PyArrayObject *ba =NULL, *new=NULL;
+    PyArrayObject *ba = NULL, *new = NULL;
     int nd, j;
     intp size, i, count;
     Bool *ptr;
@@ -10835,45 +11185,59 @@
     typecode=PyArray_DescrFromType(PyArray_BOOL);
     ba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0,
                                           CARRAY, NULL);
-    if (ba == NULL) return -1;
+    if (ba == NULL) {
+        return -1;
+    }
     nd = ba->nd;
-    for(j=0; j<nd; j++) iters[j] = NULL;
+    for (j = 0; j < nd; j++) {
+        iters[j] = NULL;
+    }
     size = PyArray_SIZE(ba);
     ptr = (Bool *)ba->data;
     count = 0;
 
     /* pre-determine how many nonzero entries there are */
-    for(i=0; i<size; i++)
-        if (*(ptr++)) count++;
+    for (i = 0; i < size; i++) {
+        if (*(ptr++)) {
+            count++;
+        }
+    }
 
     /* create count-sized index arrays for each dimension */
-    for(j=0; j<nd; j++) {
+    for (j = 0; j < nd; j++) {
         new = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &count,
                                            PyArray_INTP, NULL, NULL,
                                            0, 0, NULL);
-        if (new == NULL) goto fail;
-        iters[j] = (PyArrayIterObject *)        \
+        if (new == NULL) {
+            goto fail;
+        }
+        iters[j] = (PyArrayIterObject *)
             PyArray_IterNew((PyObject *)new);
         Py_DECREF(new);
-        if (iters[j] == NULL) goto fail;
+        if (iters[j] == NULL) {
+            goto fail;
+        }
         dptr[j] = (intp *)iters[j]->ao->data;
         coords[j] = 0;
         dims_m1[j] = ba->dimensions[j]-1;
     }
-
     ptr = (Bool *)ba->data;
+    if (count == 0) {
+        goto finish;
+    }
 
-    if (count == 0) goto finish;
-
-    /* Loop through the Boolean array  and copy coordinates
-       for non-zero entries */
-    for(i=0; i<size; i++) {
+    /*
+     * Loop through the Boolean array  and copy coordinates
+     * for non-zero entries
+     */
+    for (i = 0; i < size; i++) {
         if (*(ptr++)) {
-            for(j=0; j<nd; j++)
+            for (j = 0; j < nd; j++) {
                 *(dptr[j]++) = coords[j];
+            }
         }
         /* Borrowed from ITER_NEXT macro */
-        for(j=nd-1; j>=0; j--) {
+        for (j = nd - 1; j >= 0; j--) {
             if (coords[j] < dims_m1[j]) {
                 coords[j]++;
                 break;
@@ -10889,7 +11253,7 @@
     return nd;
 
  fail:
-    for(j=0; j<nd; j++) {
+    for (j = 0; j < nd; j++) {
         Py_XDECREF(iters[j]);
     }
     Py_XDECREF(ba);
@@ -10917,10 +11281,12 @@
 
     mit = (PyArrayMapIterObject *)_pya_malloc(sizeof(PyArrayMapIterObject));
     PyObject_Init((PyObject *)mit, &PyArrayMapIter_Type);
-    if (mit == NULL)
+    if (mit == NULL) {
         return NULL;
-    for(i=0; i<MAX_DIMS; i++)
+    }
+    for (i = 0; i < MAX_DIMS; i++) {
         mit->iters[i] = NULL;
+    }
     mit->index = 0;
     mit->ait = NULL;
     mit->subspace = NULL;
@@ -10932,7 +11298,9 @@
     if (fancy == SOBJ_LISTTUP) {
         PyObject *newobj;
         newobj = PySequence_Tuple(indexobj);
-        if (newobj == NULL) goto fail;
+        if (newobj == NULL) {
+            goto fail;
+        }
         Py_DECREF(indexobj);
         indexobj = newobj;
         mit->indexobj = indexobj;
@@ -10944,57 +11312,72 @@
 #undef SOBJ_TOOMANY
 #undef SOBJ_LISTTUP
 
-    if (oned) return (PyObject *)mit;
+    if (oned) {
+        return (PyObject *)mit;
+    }
+    /*
+     * Must have some kind of fancy indexing if we are here
+     * indexobj is either a list, an arrayobject, or a tuple
+     * (with at least 1 list or arrayobject or Bool object)
+     */
 
-    /* Must have some kind of fancy indexing if we are here */
-    /* indexobj is either a list, an arrayobject, or a tuple
-       (with at least 1 list or arrayobject or Bool object), */
-
     /* convert all inputs to iterators */
-    if (PyArray_Check(indexobj) &&                  \
-        (PyArray_TYPE(indexobj) == PyArray_BOOL)) {
+    if (PyArray_Check(indexobj) && (PyArray_TYPE(indexobj) == PyArray_BOOL)) {
         mit->numiter = _nonzero_indices(indexobj, mit->iters);
-        if (mit->numiter < 0) goto fail;
+        if (mit->numiter < 0) {
+            goto fail;
+        }
         mit->nd = 1;
         mit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;
         Py_DECREF(mit->indexobj);
         mit->indexobj = PyTuple_New(mit->numiter);
-        if (mit->indexobj == NULL) goto fail;
-        for(i=0; i<mit->numiter; i++) {
-            PyTuple_SET_ITEM(mit->indexobj, i,
-                             PyInt_FromLong(0));
+        if (mit->indexobj == NULL) {
+            goto fail;
         }
+        for (i = 0; i < mit->numiter; i++) {
+            PyTuple_SET_ITEM(mit->indexobj, i, PyInt_FromLong(0));
+        }
     }
 
     else if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {
         mit->numiter = 1;
         indtype = PyArray_DescrFromType(PyArray_INTP);
         arr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST, NULL);
-        if (arr == NULL) goto fail;
+        if (arr == NULL) {
+            goto fail;
+        }
         mit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);
-        if (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}
+        if (mit->iters[0] == NULL) {
+            Py_DECREF(arr);
+            goto fail;
+        }
         mit->nd = PyArray_NDIM(arr);
-        memcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));
+        memcpy(mit->dimensions, PyArray_DIMS(arr), mit->nd*sizeof(intp));
         mit->size = PyArray_SIZE(arr);
         Py_DECREF(arr);
         Py_DECREF(mit->indexobj);
         mit->indexobj = Py_BuildValue("(N)", PyInt_FromLong(0));
     }
-    else { /* must be a tuple */
+    else {
+        /* must be a tuple */
         PyObject *obj;
         PyArrayIterObject **iterp;
         PyObject *new;
         int numiters, j, n2;
-        /* Make a copy of the tuple -- we will be replacing
-           index objects with 0's */
+        /*
+         * Make a copy of the tuple -- we will be replacing
+         * index objects with 0's
+         */
         n = PyTuple_GET_SIZE(indexobj);
         n2 = n;
         new = PyTuple_New(n2);
-        if (new == NULL) goto fail;
+        if (new == NULL) {
+            goto fail;
+        }
         started = 0;
         nonindex = 0;
         j = 0;
-        for(i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             obj = PyTuple_GET_ITEM(indexobj,i);
             iterp = mit->iters + mit->numiter;
             if ((numiters=_convert_obj(obj, iterp)) < 0) {
@@ -11003,39 +11386,45 @@
             }
             if (numiters > 0) {
                 started = 1;
-                if (nonindex) mit->consec = 0;
+                if (nonindex) {
+                    mit->consec = 0;
+                }
                 mit->numiter += numiters;
                 if (numiters == 1) {
-                    PyTuple_SET_ITEM(new,j++,
-                                     PyInt_FromLong(0));
+                    PyTuple_SET_ITEM(new,j++, PyInt_FromLong(0));
                 }
-                else { /* we need to grow the
-                          new indexing object and fill
-                          it with 0s for each of the iterators
-                          produced */
+                else {
+                    /*
+                     * we need to grow the new indexing object and fill
+                     * it with 0s for each of the iterators produced
+                     */
                     int k;
                     n2 += numiters - 1;
-                    if (_PyTuple_Resize(&new, n2) < 0)
+                    if (_PyTuple_Resize(&new, n2) < 0) {
                         goto fail;
-                    for(k=0;k<numiters;k++) {
-                        PyTuple_SET_ITEM        \
-                            (new,j++,
-                             PyInt_FromLong(0));
                     }
+                    for (k = 0; k < numiters; k++) {
+                        PyTuple_SET_ITEM(new, j++, PyInt_FromLong(0));
+                    }
                 }
             }
             else {
-                if (started) nonindex = 1;
+                if (started) {
+                    nonindex = 1;
+                }
                 Py_INCREF(obj);
                 PyTuple_SET_ITEM(new,j++,obj);
             }
         }
         Py_DECREF(mit->indexobj);
         mit->indexobj = new;
-        /* Store the number of iterators actually converted */
-        /*  These will be mapped to actual axes at bind time */
-        if (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)
+        /*
+         * Store the number of iterators actually converted
+         * These will be mapped to actual axes at bind time
+         */
+        if (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0) {
             goto fail;
+        }
     }
 
     return (PyObject *)mit;
@@ -11053,96 +11442,94 @@
     Py_XDECREF(mit->indexobj);
     Py_XDECREF(mit->ait);
     Py_XDECREF(mit->subspace);
-    for(i=0; i<mit->numiter; i++)
+    for (i = 0; i < mit->numiter; i++) {
         Py_XDECREF(mit->iters[i]);
+    }
     _pya_free(mit);
 }
 
-/* The mapiter object must be created new each time.  It does not work
-   to bind to a new array, and continue.
-
-   This was the orginal intention, but currently that does not work.
-   Do not expose the MapIter_Type to Python.
-
-   It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a);
-   mapiter is equivalent to a[indexobj].flat but the latter gets to use
-   slice syntax.
-*/
-
+/*
+ * The mapiter object must be created new each time.  It does not work
+ * to bind to a new array, and continue.
+ *
+ * This was the orginal intention, but currently that does not work.
+ * Do not expose the MapIter_Type to Python.
+ *
+ * It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a);
+ * mapiter is equivalent to a[indexobj].flat but the latter gets to use
+ * slice syntax.
+ */
 static PyTypeObject PyArrayMapIter_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                       /* ob_size */
-    "numpy.mapiter",                        /* tp_name */
-    sizeof(PyArrayIterObject),               /* tp_basicsize */
-    0,                                       /* tp_itemsize */
+    0,                                           /* ob_size */
+    "numpy.mapiter",                             /* tp_name */
+    sizeof(PyArrayIterObject),                   /* tp_basicsize */
+    0,                                           /* tp_itemsize */
     /* methods */
-    (destructor)arraymapiter_dealloc,       /* tp_dealloc */
-    0,                                      /* tp_print */
-    0,                                      /* tp_getattr */
-    0,                                      /* tp_setattr */
-    0,                                      /* tp_compare */
-    0,                                      /* tp_repr */
-    0,                                      /* tp_as_number */
-    0,                                      /* tp_as_sequence */
-    0,                                      /* tp_as_mapping */
-    0,                                      /* tp_hash */
-    0,                                      /* tp_call */
-    0,                                      /* tp_str */
-    0,              /* tp_getattro */
-    0,                                      /* tp_setattro */
-    0,                                      /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                     /* tp_flags */
-    0,                                      /* tp_doc */
-    (traverseproc)0,                        /* tp_traverse */
-    0,                                      /* tp_clear */
-    0,                                      /* tp_richcompare */
-    0,                                      /* tp_weaklistoffset */
-    0,                                      /* tp_iter */
-    (iternextfunc)0,                        /* tp_iternext */
-    0,                              /* tp_methods */
-    0,                                        /* tp_members */
-    0,                                        /* tp_getset */
-    0,                                        /* tp_base */
-    0,                                        /* tp_dict */
-    0,                                        /* tp_descr_get */
-    0,                                        /* tp_descr_set */
-    0,                                        /* tp_dictoffset */
-    (initproc)0,                              /* tp_init */
-    0,                                        /* tp_alloc */
-    0,                                        /* tp_new */
-    0,                                        /* tp_free */
-    0,                                        /* tp_is_gc */
-    0,                                        /* tp_bases */
-    0,                                        /* tp_mro */
-    0,                                        /* tp_cache */
-    0,                                        /* tp_subclasses */
-    0,                                        /* tp_weaklist */
-    0,   				      /* tp_del */
+    (destructor)arraymapiter_dealloc,            /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    0,                                           /* tp_as_sequence */
+    0,                                           /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    0,                                           /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                          /* tp_flags */
+    0,                                           /* tp_doc */
+    (traverseproc)0,                             /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    (iternextfunc)0,                             /* tp_iternext */
+    0,                                           /* tp_methods */
+    0,                                           /* tp_members */
+    0,                                           /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    (initproc)0,                                 /* tp_init */
+    0,                                           /* tp_alloc */
+    0,                                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,   				         /* tp_del */
 
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
-
 };
 
 /** END of Subscript Iterator **/
 
 
-/*
-  NUMPY_API
-  Get MultiIterator from array of Python objects and any additional
-
-  PyObject **mps -- array of PyObjects 
-  int n - number of PyObjects in the array
-  int nadd - number of additional arrays to include in the
-             iterator. 
-
-  Returns a multi-iterator object.
+/*NUMPY_API
+ * Get MultiIterator from array of Python objects and any additional
+ *
+ * PyObject **mps -- array of PyObjects
+ * int n - number of PyObjects in the array
+ * int nadd - number of additional arrays to include in the iterator.
+ *
+ * Returns a multi-iterator object.
  */
 static PyObject *
 PyArray_MultiIterFromObjects(PyObject **mps, int n, int nadd, ...)
@@ -11161,17 +11548,20 @@
                      "array objects (inclusive).", NPY_MAXARGS);
         return NULL;
     }
-
     multi = _pya_malloc(sizeof(PyArrayMultiIterObject));
-    if (multi == NULL) return PyErr_NoMemory();
+    if (multi == NULL) {
+        return PyErr_NoMemory();
+    }
     PyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);
 
-    for(i=0; i<ntot; i++) multi->iters[i] = NULL;
+    for (i = 0; i < ntot; i++) {
+        multi->iters[i] = NULL;
+    }
     multi->numiter = ntot;
     multi->index = 0;
 
     va_start(va, nadd);
-    for(i=0; i<ntot; i++) {
+    for (i = 0; i < ntot; i++) {
 	if (i < n) {
 	    current = mps[i];
 	}
@@ -11179,32 +11569,31 @@
 	    current = va_arg(va, PyObject *);
 	}
         arr = PyArray_FROM_O(current);
-        if (arr==NULL) {
-            err=1; break;
+        if (arr == NULL) {
+            err = 1;
+            break;
         }
         else {
             multi->iters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);
             Py_DECREF(arr);
         }
     }
-
     va_end(va);
 
-    if (!err && PyArray_Broadcast(multi) < 0) err=1;
-
+    if (!err && PyArray_Broadcast(multi) < 0) {
+        err = 1;
+    }
     if (err) {
         Py_DECREF(multi);
         return NULL;
     }
-
     PyArray_MultiIter_RESET(multi);
-
-    return (PyObject *)multi;  
+    return (PyObject *)multi;
 }
 
 /*NUMPY_API
-  Get MultiIterator,
-*/
+ * Get MultiIterator,
+ */
 static PyObject *
 PyArray_MultiIterNew(int n, ...)
 {
@@ -11213,7 +11602,7 @@
     PyObject *current;
     PyObject *arr;
 
-    int i, err=0;
+    int i, err = 0;
 
     if (n < 2 || n > NPY_MAXARGS) {
         PyErr_Format(PyExc_ValueError,
@@ -11225,37 +11614,40 @@
     /* fprintf(stderr, "multi new...");*/
 
     multi = _pya_malloc(sizeof(PyArrayMultiIterObject));
-    if (multi == NULL) return PyErr_NoMemory();
+    if (multi == NULL) {
+        return PyErr_NoMemory();
+    }
     PyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);
 
-    for(i=0; i<n; i++) multi->iters[i] = NULL;
+    for (i = 0; i < n; i++) {
+        multi->iters[i] = NULL;
+    }
     multi->numiter = n;
     multi->index = 0;
 
     va_start(va, n);
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         current = va_arg(va, PyObject *);
         arr = PyArray_FROM_O(current);
-        if (arr==NULL) {
-            err=1; break;
+        if (arr == NULL) {
+            err = 1;
+            break;
         }
         else {
             multi->iters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);
             Py_DECREF(arr);
         }
     }
-
     va_end(va);
 
-    if (!err && PyArray_Broadcast(multi) < 0) err=1;
-
+    if (!err && PyArray_Broadcast(multi) < 0) {
+        err = 1;
+    }
     if (err) {
         Py_DECREF(multi);
         return NULL;
     }
-
     PyArray_MultiIter_RESET(multi);
-
     return (PyObject *)multi;
 }
 
@@ -11275,7 +11667,9 @@
 
     n = PyTuple_Size(args);
     if (n < 2 || n > NPY_MAXARGS) {
-        if (PyErr_Occurred()) return NULL;
+        if (PyErr_Occurred()) {
+            return NULL;
+        }
         PyErr_Format(PyExc_ValueError,
                      "Need at least two and fewer than (%d) "   \
                      "array objects.", NPY_MAXARGS);
@@ -11283,23 +11677,31 @@
     }
 
     multi = _pya_malloc(sizeof(PyArrayMultiIterObject));
-    if (multi == NULL) return PyErr_NoMemory();
+    if (multi == NULL) {
+        return PyErr_NoMemory();
+    }
     PyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);
 
     multi->numiter = n;
     multi->index = 0;
-    for(i=0; i<n; i++) multi->iters[i] = NULL;
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
+        multi->iters[i] = NULL;
+    }
+    for (i = 0; i < n; i++) {
         arr = PyArray_FromAny(PyTuple_GET_ITEM(args, i), NULL, 0, 0, 0, NULL);
-        if (arr == NULL) goto fail;
-        if ((multi->iters[i] =                                  \
-             (PyArrayIterObject *)PyArray_IterNew(arr))==NULL)
+        if (arr == NULL) {
             goto fail;
+        }
+        if ((multi->iters[i] = (PyArrayIterObject *)PyArray_IterNew(arr))
+                == NULL) {
+            goto fail;
+        }
         Py_DECREF(arr);
     }
-    if (PyArray_Broadcast(multi) < 0) goto fail;
+    if (PyArray_Broadcast(multi) < 0) {
+        goto fail;
+    }
     PyArray_MultiIter_RESET(multi);
-
     return (PyObject *)multi;
 
  fail:
@@ -11315,9 +11717,11 @@
 
     n = multi->numiter;
     ret = PyTuple_New(n);
-    if (ret == NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     if (multi->index < multi->size) {
-        for(i=0; i < n; i++) {
+        for (i = 0; i < n; i++) {
             PyArrayIterObject *it=multi->iters[i];
             PyTuple_SET_ITEM(ret, i,
                              PyArray_ToScalar(it->dataptr, it->ao));
@@ -11334,8 +11738,9 @@
 {
     int i;
 
-    for(i=0; i<multi->numiter; i++)
+    for (i = 0; i < multi->numiter; i++) {
         Py_XDECREF(multi->iters[i]);
+    }
     multi->ob_type->tp_free((PyObject *)multi);
 }
 
@@ -11345,10 +11750,12 @@
 #if SIZEOF_INTP <= SIZEOF_LONG
     return PyInt_FromLong((long) self->size);
 #else
-    if (self->size < MAX_LONG)
+    if (self->size < MAX_LONG) {
         return PyInt_FromLong((long) self->size);
-    else
+    }
+    else {
         return PyLong_FromLongLong((longlong) self->size);
+    }
 #endif
 }
 
@@ -11358,10 +11765,12 @@
 #if SIZEOF_INTP <= SIZEOF_LONG
     return PyInt_FromLong((long) self->index);
 #else
-    if (self->size < MAX_LONG)
+    if (self->size < MAX_LONG) {
         return PyInt_FromLong((long) self->index);
-    else
+    }
+    else {
         return PyLong_FromLongLong((longlong) self->index);
+    }
 #endif
 }
 
@@ -11376,10 +11785,13 @@
 {
     PyObject *res;
     int i, n;
+
     n = self->numiter;
     res = PyTuple_New(n);
-    if (res == NULL) return res;
-    for(i=0; i<n; i++) {
+    if (res == NULL) {
+        return res;
+    }
+    for (i = 0; i < n; i++) {
         Py_INCREF(self->iters[i]);
         PyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);
     }
@@ -11412,8 +11824,9 @@
 static PyObject *
 arraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)
 {
-    if (!PyArg_ParseTuple(args, "")) return NULL;
-
+    if (!PyArg_ParseTuple(args, "")) {
+        return NULL;
+    }
     PyArray_MultiIter_RESET(self);
     Py_INCREF(Py_None);
     return Py_None;
@@ -11426,61 +11839,61 @@
 
 static PyTypeObject PyArrayMultiIter_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                       /* ob_size */
-    "numpy.broadcast",                       /* tp_name */
-    sizeof(PyArrayMultiIterObject),          /* tp_basicsize */
-    0,                                       /* tp_itemsize */
+    0,                                           /* ob_size */
+    "numpy.broadcast",                           /* tp_name */
+    sizeof(PyArrayMultiIterObject),              /* tp_basicsize */
+    0,                                           /* tp_itemsize */
     /* methods */
-    (destructor)arraymultiter_dealloc,      /* tp_dealloc */
-    0,                                      /* tp_print */
-    0,                                      /* tp_getattr */
-    0,                                      /* tp_setattr */
-    0,                                      /* tp_compare */
-    0,                                      /* tp_repr */
-    0,                                      /* tp_as_number */
-    0,                                      /* tp_as_sequence */
-    0,                              /* tp_as_mapping */
-    0,                                      /* tp_hash */
-    0,                                      /* tp_call */
-    0,                                      /* tp_str */
-    0,              /* tp_getattro */
-    0,                                      /* tp_setattro */
-    0,                                      /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                     /* tp_flags */
-    0,                                      /* tp_doc */
-    0,                              /* tp_traverse */
-    0,                                      /* tp_clear */
-    0,                                      /* tp_richcompare */
-    0,                                      /* tp_weaklistoffset */
-    0,                              /* tp_iter */
-    (iternextfunc)arraymultiter_next,       /* tp_iternext */
-    arraymultiter_methods,          /* tp_methods */
-    arraymultiter_members,                  /* tp_members */
-    arraymultiter_getsetlist,               /* tp_getset */
-    0,                                        /* tp_base */
-    0,                                        /* tp_dict */
-    0,                                        /* tp_descr_get */
-    0,                                        /* tp_descr_set */
-    0,                                        /* tp_dictoffset */
-    (initproc)0,                              /* tp_init */
-    0,                                        /* tp_alloc */
-    arraymultiter_new,                        /* tp_new */
-    0,                                        /* tp_free */
-    0,                                        /* tp_is_gc */
-    0,                                        /* tp_bases */
-    0,                                        /* tp_mro */
-    0,                                        /* tp_cache */
-    0,                                        /* tp_subclasses */
-    0,                                        /* tp_weaklist */
-    0,   /* tp_del */
+    (destructor)arraymultiter_dealloc,           /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    0,                                           /* tp_as_sequence */
+    0,                                           /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    0,                                           /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                          /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    (iternextfunc)arraymultiter_next,            /* tp_iternext */
+    arraymultiter_methods,                       /* tp_methods */
+    arraymultiter_members,                       /* tp_members */
+    arraymultiter_getsetlist,                    /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    (initproc)0,                                 /* tp_init */
+    0,                                           /* tp_alloc */
+    arraymultiter_new,                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 
@@ -11497,21 +11910,23 @@
     return new;
 }
 
-/*** Array Descr Objects for dynamic types **/
+/** Array Descr Objects for dynamic types **/
 
-/** There are some statically-defined PyArray_Descr objects corresponding
-    to the basic built-in types.
-    These can and should be DECREF'd and INCREF'd as appropriate, anyway.
-    If a mistake is made in reference counting, deallocation on these
-    builtins will be attempted leading to problems.
+/*
+ * There are some statically-defined PyArray_Descr objects corresponding
+ * to the basic built-in types.
+ * These can and should be DECREF'd and INCREF'd as appropriate, anyway.
+ * If a mistake is made in reference counting, deallocation on these
+ * builtins will be attempted leading to problems.
+ *
+ * This let's us deal with all PyArray_Descr objects using reference
+ * counting (regardless of whether they are statically or dynamically
+ * allocated).
+ */
 
-    This let's us deal with all PyArray_Descr objects using reference
-    counting (regardless of whether they are statically or dynamically
-    allocated).
-**/
-
-/* base cannot be NULL */
-/*NUMPY_API*/
+/*NUMPY_API
+ * base cannot be NULL
+ */
 static PyArray_Descr *
 PyArray_DescrNew(PyArray_Descr *base)
 {
@@ -11540,9 +11955,10 @@
     return new;
 }
 
-/* should never be called for builtin-types unless
-   there is a reference-count problem
-*/
+/*
+ * should never be called for builtin-types unless
+ * there is a reference-count problem
+ */
 static void
 arraydescr_dealloc(PyArray_Descr *self)
 {
@@ -11565,20 +11981,29 @@
     self->ob_type->tp_free((PyObject *)self);
 }
 
-/* we need to be careful about setting attributes because these
-   objects are pointed to by arrays that depend on them for interpreting
-   data.  Currently no attributes of data-type objects can be set
-   directly except names.
-*/
+/*
+ * we need to be careful about setting attributes because these
+ * objects are pointed to by arrays that depend on them for interpreting
+ * data.  Currently no attributes of data-type objects can be set
+ * directly except names.
+ */
 static PyMemberDef arraydescr_members[] = {
-    {"type", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},
-    {"kind", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},
-    {"char", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},
-    {"num", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},
-    {"byteorder", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},
-    {"itemsize", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},
-    {"alignment", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},
-    {"flags", T_UBYTE, offsetof(PyArray_Descr, hasobject), RO, NULL},
+    {"type",
+        T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},
+    {"kind",
+        T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},
+    {"char",
+        T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},
+    {"num",
+        T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},
+    {"byteorder",
+        T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},
+    {"itemsize",
+        T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},
+    {"alignment",
+        T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},
+    {"flags",
+        T_UBYTE, offsetof(PyArray_Descr, hasobject), RO, NULL},
     {NULL, 0, 0, 0, NULL},
 };
 
@@ -11596,15 +12021,16 @@
 static PyObject *
 arraydescr_protocol_typestr_get(PyArray_Descr *self)
 {
-    char basic_=self->kind;
+    char basic_ = self->kind;
     char endian = self->byteorder;
-    int size=self->elsize;
+    int size = self->elsize;
 
     if (endian == '=') {
         endian = '<';
-        if (!PyArray_IsNativeByteOrder(endian)) endian = '>';
+        if (!PyArray_IsNativeByteOrder(endian)) {
+            endian = '>';
+        }
     }
-
     if (self->type_num == PyArray_UNICODE) {
         size >>= 2;
     }
@@ -11618,7 +12044,8 @@
     PyTypeObject *typeobj = self->typeobj;
     PyObject *res;
     char *s;
-    static int prefix_len=0;
+    /* fixme: not reentrant */
+    static int prefix_len = 0;
 
     if (PyTypeNum_ISUSERDEF(self->type_num)) {
         s = strrchr(typeobj->tp_name, '.');
@@ -11626,17 +12053,18 @@
             res = PyString_FromString(typeobj->tp_name);
         }
         else {
-            res = PyString_FromStringAndSize(s+1, strlen(s)-1);
+            res = PyString_FromStringAndSize(s + 1, strlen(s) - 1);
         }
         return res;
     }
     else {
-        if (prefix_len == 0)
+        if (prefix_len == 0) {
             prefix_len = strlen("numpy.");
-
+        }
         len = strlen(typeobj->tp_name);
-        if (*(typeobj->tp_name + (len-1)) == '_')
-            len-=1;
+        if (*(typeobj->tp_name + (len-1)) == '_') {
+            len -= 1;
+        }
         len -= prefix_len;
         res = PyString_FromStringAndSize(typeobj->tp_name+prefix_len, len);
     }
@@ -11681,35 +12109,45 @@
     if (self->names == NULL) {
         /* get default */
         dobj = PyTuple_New(2);
-        if (dobj == NULL) return NULL;
+        if (dobj == NULL) {
+            return NULL;
+        }
         PyTuple_SET_ITEM(dobj, 0, PyString_FromString(""));
-        PyTuple_SET_ITEM(dobj, 1, \
-                         arraydescr_protocol_typestr_get(self));
+        PyTuple_SET_ITEM(dobj, 1, arraydescr_protocol_typestr_get(self));
         res = PyList_New(1);
-        if (res == NULL) {Py_DECREF(dobj); return NULL;}
+        if (res == NULL) {
+            Py_DECREF(dobj);
+            return NULL;
+        }
         PyList_SET_ITEM(res, 0, dobj);
         return res;
     }
 
     _numpy_internal = PyImport_ImportModule("numpy.core._internal");
-    if (_numpy_internal == NULL) return NULL;
-    res = PyObject_CallMethod(_numpy_internal, "_array_descr",
-                              "O", self);
+    if (_numpy_internal == NULL) {
+        return NULL;
+    }
+    res = PyObject_CallMethod(_numpy_internal, "_array_descr", "O", self);
     Py_DECREF(_numpy_internal);
     return res;
 }
 
-/* returns 1 for a builtin type
-   and 2 for a user-defined data-type descriptor
-   return 0 if neither (i.e. it's a copy of one)
-*/
+/*
+ * returns 1 for a builtin type
+ * and 2 for a user-defined data-type descriptor
+ * return 0 if neither (i.e. it's a copy of one)
+ */
 static PyObject *
 arraydescr_isbuiltin_get(PyArray_Descr *self)
 {
     long val;
     val = 0;
-    if (self->fields == Py_None) val = 1;
-    if (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;
+    if (self->fields == Py_None) {
+        val = 1;
+    }
+    if (PyTypeNum_ISUSERDEF(self->type_num)) {
+        val = 2;
+    }
     return PyInt_FromLong(val);
 }
 
@@ -11720,34 +12158,42 @@
         return PyArray_ISNBO(self->byteorder);
     }
     else {
-        PyObject *key, *value, *title=NULL;
+        PyObject *key, *value, *title = NULL;
         PyArray_Descr *new;
         int offset;
-        Py_ssize_t pos=0;
-        while(PyDict_Next(self->fields, &pos, &key, &value)) {
-	    if NPY_TITLE_KEY(key, value) continue;
-            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
-                                  &title)) return -1;
-            if (!_arraydescr_isnative(new)) return 0;
+        Py_ssize_t pos = 0;
+        while (PyDict_Next(self->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) {
+                continue;
+            }
+            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset, &title)) {
+                return -1;
+            }
+            if (!_arraydescr_isnative(new)) {
+                return 0;
+            }
         }
     }
     return 1;
 }
 
-/* return Py_True if this data-type descriptor
-   has native byteorder if no fields are defined
-
-   or if all sub-fields have native-byteorder if
-   fields are defined
-*/
+/*
+ * return Py_True if this data-type descriptor
+ * has native byteorder if no fields are defined
+ *
+ * or if all sub-fields have native-byteorder if
+ * fields are defined
+ */
 static PyObject *
 arraydescr_isnative_get(PyArray_Descr *self)
 {
     PyObject *ret;
     int retval;
     retval = _arraydescr_isnative(self);
-    if (retval == -1) return NULL;
-    ret = (retval ? Py_True : Py_False);
+    if (retval == -1) {
+        return NULL;
+    }
+    ret = retval ? Py_True : Py_False;
     Py_INCREF(ret);
     return ret;
 }
@@ -11766,10 +12212,12 @@
 arraydescr_hasobject_get(PyArray_Descr *self)
 {
     PyObject *res;
-    if (PyDataType_FLAGCHK(self, NPY_ITEM_HASOBJECT))
+    if (PyDataType_FLAGCHK(self, NPY_ITEM_HASOBJECT)) {
         res = Py_True;
-    else
+    }
+    else {
         res = Py_False;
+    }
     Py_INCREF(res);
     return res;
 }
@@ -11803,9 +12251,9 @@
 	return -1;
     }
     /* Make sure all entries are strings */
-    for(i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
 	PyObject *item;
-	int valid=1;
+	int valid = 1;
 	item = PySequence_GetItem(val, i);
 	valid = PyString_Check(item);
 	Py_DECREF(item);
@@ -11818,8 +12266,7 @@
     }
     /* Update dictionary keys in fields */
     new_names = PySequence_Tuple(val);
-
-    for(i=0; i<N; i++) {
+    for (i = 0; i < N; i++) {
 	PyObject *key;
 	PyObject *item;
 	PyObject *new_key;
@@ -11842,39 +12289,39 @@
 
 static PyGetSetDef arraydescr_getsets[] = {
     {"subdtype",
-     (getter)arraydescr_subdescr_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_subdescr_get,
+        NULL, NULL, NULL},
     {"descr",
-     (getter)arraydescr_protocol_descr_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_protocol_descr_get,
+        NULL, NULL, NULL},
     {"str",
-     (getter)arraydescr_protocol_typestr_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_protocol_typestr_get,
+        NULL, NULL, NULL},
     {"name",
-     (getter)arraydescr_typename_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_typename_get,
+        NULL, NULL, NULL},
     {"base",
-     (getter)arraydescr_base_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_base_get,
+        NULL, NULL, NULL},
     {"shape",
-     (getter)arraydescr_shape_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_shape_get,
+        NULL, NULL, NULL},
     {"isbuiltin",
-     (getter)arraydescr_isbuiltin_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_isbuiltin_get,
+        NULL, NULL, NULL},
     {"isnative",
-     (getter)arraydescr_isnative_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_isnative_get,
+        NULL, NULL, NULL},
     {"fields",
-     (getter)arraydescr_fields_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_fields_get,
+        NULL, NULL, NULL},
     {"names",
-     (getter)arraydescr_names_get,
-     (setter)arraydescr_names_set,
-     NULL, NULL},
+        (getter)arraydescr_names_get,
+        (setter)arraydescr_names_set,
+        NULL, NULL},
     {"hasobject",
-     (getter)arraydescr_hasobject_get,
-     NULL, NULL, NULL},
+        (getter)arraydescr_hasobject_get,
+        NULL, NULL, NULL},
     {NULL, NULL, NULL, NULL, NULL},
 };
 
@@ -11883,22 +12330,24 @@
 {
     PyObject *odescr;
     PyArray_Descr *descr, *conv;
-    Bool align=FALSE;
-    Bool copy=FALSE;
+    Bool align = FALSE;
+    Bool copy = FALSE;
     static char *kwlist[] = {"dtype", "align", "copy", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&O&",
                                      kwlist, &odescr,
                                      PyArray_BoolConverter, &align,
-                                     PyArray_BoolConverter, &copy))
+                                     PyArray_BoolConverter, &copy)) {
         return NULL;
-
+    }
     if (align) {
-        if (!PyArray_DescrAlignConverter(odescr, &conv))
+        if (!PyArray_DescrAlignConverter(odescr, &conv)) {
             return NULL;
+        }
     }
-    else if (!PyArray_DescrConverter(odescr, &conv))
+    else if (!PyArray_DescrConverter(odescr, &conv)) {
         return NULL;
+    }
     /* Get a new copy of it unless it's already a copy */
     if (copy && conv->fields == Py_None) {
         descr = PyArray_DescrNew(conv);
@@ -11913,9 +12362,11 @@
 static PyObject *
 arraydescr_reduce(PyArray_Descr *self, PyObject *NPY_UNUSED(args))
 {
-    /* version number of this pickle type. Increment if we need to
-       change the format. Be sure to handle the old versions in
-       arraydescr_setstate. */
+    /*
+     * version number of this pickle type. Increment if we need to
+     * change the format. Be sure to handle the old versions in
+     * arraydescr_setstate.
+    */
     const int version = 3;
     PyObject *ret, *mod, *obj;
     PyObject *state;
@@ -11923,15 +12374,23 @@
     int elsize, alignment;
 
     ret = PyTuple_New(3);
-    if (ret == NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     mod = PyImport_ImportModule("numpy.core.multiarray");
-    if (mod == NULL) {Py_DECREF(ret); return NULL;}
+    if (mod == NULL) {
+        Py_DECREF(ret);
+        return NULL;
+    }
     obj = PyObject_GetAttrString(mod, "dtype");
     Py_DECREF(mod);
-    if (obj == NULL) {Py_DECREF(ret); return NULL;}
+    if (obj == NULL) {
+        Py_DECREF(ret);
+        return NULL;
+    }
     PyTuple_SET_ITEM(ret, 0, obj);
-    if (PyTypeNum_ISUSERDEF(self->type_num) ||              \
-        ((self->type_num == PyArray_VOID &&                 \
+    if (PyTypeNum_ISUSERDEF(self->type_num) ||
+        ((self->type_num == PyArray_VOID &&
           self->typeobj != &PyVoidArrType_Type))) {
         obj = (PyObject *)self->typeobj;
         Py_INCREF(obj);
@@ -11945,12 +12404,16 @@
     }
     PyTuple_SET_ITEM(ret, 1, Py_BuildValue("(Nii)", obj, 0, 1));
 
-    /* Now return the state which is at least
-       byteorder, subarray, and fields */
+    /* 
+     * Now return the state which is at least byteorder,
+     * subarray, and fields
+     */
     endian = self->byteorder;
     if (endian == '=') {
         endian = '<';
-        if (!PyArray_IsNativeByteOrder(endian)) endian = '>';
+        if (!PyArray_IsNativeByteOrder(endian)) {
+            endian = '>';
+        }
     }
     state = PyTuple_New(8);
     PyTuple_SET_ITEM(state, 0, PyInt_FromLong(version));
@@ -11974,12 +12437,13 @@
         elsize = self->elsize;
         alignment = self->alignment;
     }
-    else {elsize = -1; alignment = -1;}
-
+    else {
+        elsize = -1;
+        alignment = -1;
+    }
     PyTuple_SET_ITEM(state, 5, PyInt_FromLong(elsize));
     PyTuple_SET_ITEM(state, 6, PyInt_FromLong(alignment));
     PyTuple_SET_ITEM(state, 7, PyInt_FromLong(self->hasobject));
-
     PyTuple_SET_ITEM(ret, 2, state);
     return ret;
 }
@@ -11991,17 +12455,20 @@
 _descr_find_object(PyArray_Descr *self)
 {
     if (self->hasobject || self->type_num == PyArray_OBJECT ||
-        self->kind == 'O')
+        self->kind == 'O') {
         return NPY_OBJECT_DTYPE_FLAGS;
+    }
     if (PyDescr_HASFIELDS(self)) {
-        PyObject *key, *value, *title=NULL;
+        PyObject *key, *value, *title = NULL;
         PyArray_Descr *new;
         int offset;
-        Py_ssize_t pos=0;
+        Py_ssize_t pos = 0;
+
         while (PyDict_Next(self->fields, &pos, &key, &value)) {
-	    if NPY_TITLE_KEY(key, value) continue;
-            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
-                                  &title)) {
+	    if NPY_TITLE_KEY(key, value) {
+                continue;
+            }
+            if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset, &title)) {
                 PyErr_Clear();
                 return 0;
             }
@@ -12014,22 +12481,24 @@
     return 0;
 }
 
-/* state is at least byteorder, subarray, and fields but could include elsize
-   and alignment for EXTENDED arrays
-*/
-
+/*
+ * state is at least byteorder, subarray, and fields but could include elsize
+ * and alignment for EXTENDED arrays
+ */
 static PyObject *
 arraydescr_setstate(PyArray_Descr *self, PyObject *args)
 {
     int elsize = -1, alignment = -1;
     int version = 3;
     char endian;
-    PyObject *subarray, *fields, *names=NULL;
+    PyObject *subarray, *fields, *names = NULL;
     int incref_names = 1;
-    int dtypeflags=0;
+    int dtypeflags = 0;
 
-    if (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}
-
+    if (self->fields == Py_None) {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
     if (PyTuple_GET_SIZE(args) != 1 ||
         !(PyTuple_Check(PyTuple_GET_ITEM(args, 0)))) {
         PyErr_BadInternalCall();
@@ -12038,40 +12507,42 @@
     switch (PyTuple_GET_SIZE(PyTuple_GET_ITEM(args,0))) {
     case 8:
         if (!PyArg_ParseTuple(args, "(icOOOiii)", &version, &endian,
-                              &subarray, &names, &fields, &elsize,
-                              &alignment, &dtypeflags)) {
+                    &subarray, &names, &fields, &elsize,
+                    &alignment, &dtypeflags)) {
             return NULL;
         }
         break;
     case 7:
         if (!PyArg_ParseTuple(args, "(icOOOii)", &version, &endian,
-                              &subarray, &names, &fields, &elsize,
-                              &alignment)) {
+                    &subarray, &names, &fields, &elsize,
+                    &alignment)) {
             return NULL;
         }
         break;
     case 6:
         if (!PyArg_ParseTuple(args, "(icOOii)", &version,
-                              &endian, &subarray, &fields,
-                              &elsize, &alignment)) {
+                    &endian, &subarray, &fields,
+                    &elsize, &alignment)) {
             PyErr_Clear();
         }
         break;
     case 5:
         version = 0;
         if (!PyArg_ParseTuple(args, "(cOOii)",
-                              &endian, &subarray, &fields, &elsize,
-                              &alignment)) {
+                    &endian, &subarray, &fields, &elsize,
+                    &alignment)) {
             return NULL;
         }
         break;
     default:
-        version = -1; /* raise an error */
+        /* raise an error */
+        version = -1;
     }
 
-    /* If we ever need another pickle format, increment the version
-       number. But we should still be able to handle the old versions.
-    */
+    /*
+     * If we ever need another pickle format, increment the version
+     * number. But we should still be able to handle the old versions.
+     */
     if (version < 0 || version > 3) {
         PyErr_Format(PyExc_ValueError,
                      "can't handle version %d of numpy.dtype pickle",
@@ -12084,7 +12555,9 @@
             PyObject *key, *list;
             key = PyInt_FromLong(-1);
             list = PyDict_GetItem(fields, key);
-            if (!list) return NULL;
+            if (!list) {
+                return NULL;
+            }
             Py_INCREF(list);
             names = list;
             PyDict_DelItem(fields, key);
@@ -12096,16 +12569,16 @@
     }
 
 
-    if ((fields == Py_None && names != Py_None) ||  \
+    if ((fields == Py_None && names != Py_None) ||
         (names == Py_None && fields != Py_None)) {
         PyErr_Format(PyExc_ValueError,
                      "inconsistent fields and names");
         return NULL;
     }
 
-    if (endian != '|' &&
-        PyArray_IsNativeByteOrder(endian)) endian = '=';
-
+    if (endian != '|' && PyArray_IsNativeByteOrder(endian)) {
+        endian = '=';
+    }
     self->byteorder = endian;
     if (self->subarray) {
         Py_XDECREF(self->subarray->base);
@@ -12128,8 +12601,9 @@
         Py_INCREF(fields);
         Py_XDECREF(self->names);
         self->names = names;
-        if (incref_names)
+        if (incref_names) {
             Py_INCREF(names);
+        }
     }
 
     if (PyTypeNum_ISEXTENDED(self->type_num)) {
@@ -12146,23 +12620,23 @@
 }
 
 
-/* returns a copy of the PyArray_Descr structure with the byteorder
-   altered:
-   no arguments:  The byteorder is swapped (in all subfields as well)
-   single argument:  The byteorder is forced to the given state
-   (in all subfields as well)
-
-   Valid states:  ('big', '>') or ('little' or '<')
-   ('native', or '=')
-
-   If a descr structure with | is encountered it's own
-   byte-order is not changed but any fields are:
-*/
-
-/*NUMPY_API
-  Deep bytorder change of a data-type descriptor
-  *** Leaves reference count of self unchanged --- does not DECREF self ***
-  */
+ /*NUMPY_API
+ * returns a copy of the PyArray_Descr structure with the byteorder
+ * altered:
+ * no arguments:  The byteorder is swapped (in all subfields as well)
+ * single argument:  The byteorder is forced to the given state
+ * (in all subfields as well)
+ *
+ * Valid states:  ('big', '>') or ('little' or '<')
+ * ('native', or '=')
+ *
+ * If a descr structure with | is encountered it's own
+ * byte-order is not changed but any fields are:
+ *
+ *
+ * Deep bytorder change of a data-type descriptor
+ * *** Leaves reference count of self unchanged --- does not DECREF self ***
+ */
 static PyArray_Descr *
 PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)
 {
@@ -12172,9 +12646,14 @@
     new = PyArray_DescrNew(self);
     endian = new->byteorder;
     if (endian != PyArray_IGNORE) {
-        if (newendian == PyArray_SWAP) {  /* swap byteorder */
-            if PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;
-            else endian = PyArray_NATBYTE;
+        if (newendian == PyArray_SWAP) {
+            /* swap byteorder */
+            if PyArray_ISNBO(endian) {
+                endian = PyArray_OPPBYTE;
+            }
+            else {
+                endian = PyArray_NATBYTE;
+            }
             new->byteorder = endian;
         }
         else if (newendian != PyArray_IGNORE) {
@@ -12189,28 +12668,31 @@
         PyArray_Descr *newdescr;
         Py_ssize_t pos = 0;
         int len, i;
+
         newfields = PyDict_New();
-        /* make new dictionary with replaced */
-        /* PyArray_Descr Objects */
+        /* make new dictionary with replaced PyArray_Descr Objects */
         while(PyDict_Next(self->fields, &pos, &key, &value)) {
-	    if NPY_TITLE_KEY(key, value) continue;
-            if (!PyString_Check(key) ||          \
-                !PyTuple_Check(value) ||                    \
-                ((len=PyTuple_GET_SIZE(value)) < 2))
+	    if NPY_TITLE_KEY(key, value) {
                 continue;
-
+            }
+            if (!PyString_Check(key) ||
+                !PyTuple_Check(value) ||
+                ((len=PyTuple_GET_SIZE(value)) < 2)) {
+                continue;
+            }
             old = PyTuple_GET_ITEM(value, 0);
-            if (!PyArray_DescrCheck(old)) continue;
-            newdescr = PyArray_DescrNewByteorder            \
-                ((PyArray_Descr *)old, newendian);
+            if (!PyArray_DescrCheck(old)) {
+                continue;
+            }
+            newdescr = PyArray_DescrNewByteorder(
+                    (PyArray_Descr *)old, newendian);
             if (newdescr == NULL) {
                 Py_DECREF(newfields); Py_DECREF(new);
                 return NULL;
             }
             newvalue = PyTuple_New(len);
-            PyTuple_SET_ITEM(newvalue, 0,           \
-                             (PyObject *)newdescr);
-            for(i=1; i<len; i++) {
+            PyTuple_SET_ITEM(newvalue, 0, (PyObject *)newdescr);
+            for (i = 1; i < len; i++) {
                 old = PyTuple_GET_ITEM(value, i);
                 Py_INCREF(old);
                 PyTuple_SET_ITEM(newvalue, i, old);
@@ -12223,7 +12705,7 @@
     }
     if (new->subarray) {
         Py_DECREF(new->subarray->base);
-        new->subarray->base = PyArray_DescrNewByteorder \
+        new->subarray->base = PyArray_DescrNewByteorder
             (self->subarray->base, newendian);
     }
     return new;
@@ -12236,19 +12718,20 @@
     char endian=PyArray_SWAP;
 
     if (!PyArg_ParseTuple(args, "|O&", PyArray_ByteorderConverter,
-                          &endian)) return NULL;
-
+                          &endian)) {
+        return NULL;
+    }
     return (PyObject *)PyArray_DescrNewByteorder(self, endian);
 }
 
 static PyMethodDef arraydescr_methods[] = {
     /* for pickling */
-    {"__reduce__", (PyCFunction)arraydescr_reduce, METH_VARARGS,
-     NULL},
-    {"__setstate__", (PyCFunction)arraydescr_setstate, METH_VARARGS,
-     NULL},
-    {"newbyteorder", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,
-     NULL},
+    {"__reduce__",
+        (PyCFunction)arraydescr_reduce, METH_VARARGS, NULL},
+    {"__setstate__",
+        (PyCFunction)arraydescr_setstate, METH_VARARGS, NULL},
+    {"newbyteorder",
+        (PyCFunction)arraydescr_newbyteorder, METH_VARARGS, NULL},
     {NULL, NULL, 0, NULL}           /* sentinel */
 };
 
@@ -12264,7 +12747,9 @@
             sub = PyString_FromString("<err>");
             PyErr_Clear();
         }
-        else sub = PyObject_Str(lst);
+        else {
+            sub = PyObject_Str(lst);
+        }
         Py_XDECREF(lst);
         if (self->type_num != PyArray_VOID) {
             PyObject *p;
@@ -12335,11 +12820,12 @@
 static PyObject *
 arraydescr_richcompare(PyArray_Descr *self, PyObject *other, int cmp_op)
 {
-    PyArray_Descr *new=NULL;
+    PyArray_Descr *new = NULL;
     PyObject *result = Py_NotImplemented;
     if (!PyArray_DescrCheck(other)) {
-        if (PyArray_DescrConverter(other, &new) == PY_FAIL)
+        if (PyArray_DescrConverter(other, &new) == PY_FAIL) {
             return NULL;
+        }
     }
     else {
         new = (PyArray_Descr *)other;
@@ -12347,22 +12833,28 @@
     }
     switch (cmp_op) {
     case Py_LT:
-        if (!PyArray_EquivTypes(self, new) && PyArray_CanCastTo(self, new))
+        if (!PyArray_EquivTypes(self, new) && PyArray_CanCastTo(self, new)) {
             result = Py_True;
-        else
+        }
+        else {
             result = Py_False;
+        }
         break;
     case Py_LE:
-        if (PyArray_CanCastTo(self, new))
+        if (PyArray_CanCastTo(self, new)) {
             result = Py_True;
-        else
+        }
+        else {
             result = Py_False;
+        }
         break;
     case Py_EQ:
-        if (PyArray_EquivTypes(self, new))
+        if (PyArray_EquivTypes(self, new)) {
             result = Py_True;
-        else
+        }
+        else {
             result = Py_False;
+        }
         break;
     case Py_NE:
         if (PyArray_EquivTypes(self, new))
@@ -12371,16 +12863,20 @@
             result = Py_True;
         break;
     case Py_GT:
-        if (!PyArray_EquivTypes(self, new) && PyArray_CanCastTo(new, self))
+        if (!PyArray_EquivTypes(self, new) && PyArray_CanCastTo(new, self)) {
             result = Py_True;
-        else
+        }
+        else {
             result = Py_False;
+        }
         break;
     case Py_GE:
-        if (PyArray_CanCastTo(new, self))
+        if (PyArray_CanCastTo(new, self)) {
             result = Py_True;
-        else
+        }
+        else {
             result = Py_False;
+        }
         break;
     default:
         result = Py_NotImplemented;
@@ -12398,12 +12894,14 @@
 static Py_ssize_t
 descr_length(PyObject *self0)
 {
-
     PyArray_Descr *self = (PyArray_Descr *)self0;
 
-    if (self->names)
+    if (self->names) {
         return PyTuple_GET_SIZE(self->names);
-    else return 0;
+    }
+    else {
+        return 0;
+    }
 }
 
 static PyObject *
@@ -12411,7 +12909,7 @@
 {
     PyObject *tup;
     PyArray_Descr *new;
-    if (length < 0)
+    if (length < 0) {
         return PyErr_Format(PyExc_ValueError,
 #if (PY_VERSION_HEX < 0x02050000)
                             "Array length must be >= 0, not %d",
@@ -12419,8 +12917,11 @@
                             "Array length must be >= 0, not %zd",
 #endif
                             length);
+    }
     tup = Py_BuildValue("O" NPY_SSIZE_T_PYFMT, self, length);
-    if (tup == NULL) return NULL;
+    if (tup == NULL) {
+        return NULL;
+    }
     PyArray_DescrConverter(tup, &new);
     Py_DECREF(tup);
     return (PyObject *)new;
@@ -12432,11 +12933,9 @@
 
     if (self->names) {
         if (PyString_Check(op) || PyUnicode_Check(op)) {
-            PyObject *obj;
-            obj = PyDict_GetItem(self->fields, op);
+            PyObject *obj = PyDict_GetItem(self->fields, op);
             if (obj != NULL) {
-                PyObject *descr;
-                descr = PyTuple_GET_ITEM(obj, 0);
+                PyObject *descr = PyTuple_GET_ITEM(obj, 0);
                 Py_INCREF(descr);
                 return descr;
             }
@@ -12448,12 +12947,12 @@
         }
         else {
             PyObject *name;
-            int value;
-            value = PyArray_PyIntAsInt(op);
+            int value = PyArray_PyIntAsInt(op);
             if (!PyErr_Occurred()) {
-                int size;
-                size = PyTuple_GET_SIZE(self->names);
-                if (value < 0) value += size;
+                int size = PyTuple_GET_SIZE(self->names);
+                if (value < 0) {
+                    value += size;
+                }
                 if (value < 0 || value >= size) {
                     PyErr_Format(PyExc_IndexError,
                                  "0<=index<%d not %d",
@@ -12484,17 +12983,17 @@
     (binaryfunc)NULL,
     descr_repeat,
     NULL, NULL,
-    NULL, /* sq_ass_item */
-    NULL, /* ssizessizeobjargproc sq_ass_slice */
-    0, /* sq_contains */
-    0, /* sq_inplace_concat */
-    0, /* sq_inplace_repeat */
+    NULL,                                        /* sq_ass_item */
+    NULL,                                        /* ssizessizeobjargproc sq_ass_slice */
+    0,                                           /* sq_contains */
+    0,                                           /* sq_inplace_concat */
+    0,                                           /* sq_inplace_repeat */
 };
 
 static PyMappingMethods descr_as_mapping = {
-    descr_length,                       /*mp_length*/
-    (binaryfunc)descr_subscript,        /*mp_subscript*/
-    (objobjargproc)NULL,                /*mp_ass_subscript*/
+    descr_length,                                /* mp_length*/
+    (binaryfunc)descr_subscript,                 /* mp_subscript*/
+    (objobjargproc)NULL,                         /* mp_ass_subscript*/
 };
 
 /****************** End of Mapping Protocol ******************************/
@@ -12502,70 +13001,71 @@
 
 static PyTypeObject PyArrayDescr_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                       /* ob_size */
-    "numpy.dtype",                           /* tp_name */
-    sizeof(PyArray_Descr),                   /* tp_basicsize */
-    0,                                       /* tp_itemsize */
+    0,                                           /* ob_size */
+    "numpy.dtype",                               /* tp_name */
+    sizeof(PyArray_Descr),                       /* tp_basicsize */
+    0,                                           /* tp_itemsize */
     /* methods */
-    (destructor)arraydescr_dealloc,         /* tp_dealloc */
-    0,                                      /* tp_print */
-    0,                                      /* tp_getattr */
-    0,                                      /* tp_setattr */
-    0,                                      /* tp_compare */
-    (reprfunc)arraydescr_repr,              /* tp_repr */
-    0,                                      /* tp_as_number */
-    &descr_as_sequence,                     /* tp_as_sequence */
-    &descr_as_mapping,                      /* tp_as_mapping */
-    0,                                      /* tp_hash */
-    0,                                      /* tp_call */
-    (reprfunc)arraydescr_str,               /* tp_str */
-    0,                                      /* tp_getattro */
-    0,                                      /* tp_setattro */
-    0,                                      /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                     /* tp_flags */
-    0,                                      /* tp_doc */
-    0,                                      /* tp_traverse */
-    0,                                      /* tp_clear */
-    (richcmpfunc)arraydescr_richcompare,    /* tp_richcompare */
-    0,                                      /* tp_weaklistoffset */
-    0,                                      /* tp_iter */
-    0,                                      /* tp_iternext */
-    arraydescr_methods,                     /* tp_methods */
-    arraydescr_members,                     /* tp_members */
-    arraydescr_getsets,                     /* tp_getset */
-    0,                                        /* tp_base */
-    0,                                        /* tp_dict */
-    0,                                        /* tp_descr_get */
-    0,                                        /* tp_descr_set */
-    0,                                        /* tp_dictoffset */
-    0,                                        /* tp_init */
-    0,                                        /* tp_alloc */
-    arraydescr_new,                           /* tp_new */
-    0,                                        /* tp_free */
-    0,                                        /* tp_is_gc */
-    0,                                        /* tp_bases */
-    0,                                        /* tp_mro */
-    0,                                        /* tp_cache */
-    0,                                        /* tp_subclasses */
-    0,                                        /* tp_weaklist */
-    0,   /* tp_del */
+    (destructor)arraydescr_dealloc,              /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    (reprfunc)arraydescr_repr,                   /* tp_repr */
+    0,                                           /* tp_as_number */
+    &descr_as_sequence,                          /* tp_as_sequence */
+    &descr_as_mapping,                           /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    (reprfunc)arraydescr_str,                    /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                          /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    (richcmpfunc)arraydescr_richcompare,         /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    0,                                           /* tp_iternext */
+    arraydescr_methods,                          /* tp_methods */
+    arraydescr_members,                          /* tp_members */
+    arraydescr_getsets,                          /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    0,                                           /* tp_init */
+    0,                                           /* tp_alloc */
+    arraydescr_new,                              /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 
 
-/** Array Flags Object **/
+/* Array Flags Object */
 
 /*NUMPY_API
-  Get New ArrayFlagsObject
-*/
+ *
+ * Get New ArrayFlagsObject
+ */
 static PyObject *
 PyArray_NewFlagsObject(PyObject *obj)
 {
@@ -12578,11 +13078,12 @@
         flags = PyArray_FLAGS(obj);
     }
     flagobj = PyArrayFlags_Type.tp_alloc(&PyArrayFlags_Type, 0);
-    if (flagobj == NULL) return NULL;
+    if (flagobj == NULL) {
+        return NULL;
+    }
     Py_XINCREF(obj);
     ((PyArrayFlagsObject *)flagobj)->arr = obj;
     ((PyArrayFlagsObject *)flagobj)->flags = flags;
-
     return flagobj;
 }
 
@@ -12620,11 +13121,12 @@
     PyObject *item;
 
     if (((self->flags & FORTRAN) == FORTRAN) ||
-        ((self->flags & CONTIGUOUS) == CONTIGUOUS))
+        ((self->flags & CONTIGUOUS) == CONTIGUOUS)) {
         item = Py_True;
-    else
+    }
+    else {
         item = Py_False;
-
+    }
     Py_INCREF(item);
     return item;
 }
@@ -12635,11 +13137,12 @@
     PyObject *item;
 
     if (((self->flags & FORTRAN) == FORTRAN) &&
-        !((self->flags & CONTIGUOUS) == CONTIGUOUS))
+        !((self->flags & CONTIGUOUS) == CONTIGUOUS)) {
         item = Py_True;
-    else
+    }
+    else {
         item = Py_False;
-
+    }
     Py_INCREF(item);
     return item;
 }
@@ -12649,13 +13152,14 @@
 {
     PyObject *item;
 
-    if (((self->flags & (ALIGNED|WRITEABLE|FORTRAN)) ==     \
+    if (((self->flags & (ALIGNED|WRITEABLE|FORTRAN)) ==
          (ALIGNED|WRITEABLE|FORTRAN)) &&
-        !((self->flags & CONTIGUOUS) == CONTIGUOUS))
+        !((self->flags & CONTIGUOUS) == CONTIGUOUS)) {
         item = Py_True;
-    else
+    }
+    else {
         item = Py_False;
-
+    }
     Py_INCREF(item);
     return item;
 }
@@ -12677,7 +13181,9 @@
     }
     res = PyObject_CallMethod(self->arr, "setflags", "OOO", Py_None, Py_None,
                               (PyObject_IsTrue(obj) ? Py_True : Py_False));
-    if (res == NULL) return -1;
+    if (res == NULL) {
+        return -1;
+    }
     Py_DECREF(res);
     return 0;
 }
@@ -12693,7 +13199,9 @@
     res = PyObject_CallMethod(self->arr, "setflags", "OOO", Py_None,
                               (PyObject_IsTrue(obj) ? Py_True : Py_False),
                               Py_None);
-    if (res == NULL) return -1;
+    if (res == NULL) {
+        return -1;
+    }
     Py_DECREF(res);
     return 0;
 }
@@ -12709,7 +13217,9 @@
     res = PyObject_CallMethod(self->arr, "setflags", "OOO",
                               (PyObject_IsTrue(obj) ? Py_True : Py_False),
                               Py_None, Py_None);
-    if (res == NULL) return -1;
+    if (res == NULL) {
+        return -1;
+    }
     Py_DECREF(res);
     return 0;
 }
@@ -12717,61 +13227,61 @@
 
 static PyGetSetDef arrayflags_getsets[] = {
     {"contiguous",
-     (getter)arrayflags_contiguous_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_contiguous_get,
+        NULL,
+        "", NULL},
     {"c_contiguous",
-     (getter)arrayflags_contiguous_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_contiguous_get,
+        NULL,
+        "", NULL},
     {"f_contiguous",
-     (getter)arrayflags_fortran_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_fortran_get,
+        NULL,
+        "", NULL},
     {"fortran",
-     (getter)arrayflags_fortran_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_fortran_get,
+        NULL,
+        "", NULL},
     {"updateifcopy",
-     (getter)arrayflags_updateifcopy_get,
-     (setter)arrayflags_updateifcopy_set,
-     "", NULL},
+        (getter)arrayflags_updateifcopy_get,
+        (setter)arrayflags_updateifcopy_set,
+        "", NULL},
     {"owndata",
-     (getter)arrayflags_owndata_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_owndata_get,
+        NULL,
+        "", NULL},
     {"aligned",
-     (getter)arrayflags_aligned_get,
-     (setter)arrayflags_aligned_set,
-     "", NULL},
+        (getter)arrayflags_aligned_get,
+        (setter)arrayflags_aligned_set,
+        "", NULL},
     {"writeable",
-     (getter)arrayflags_writeable_get,
-     (setter)arrayflags_writeable_set,
-     "", NULL},
+        (getter)arrayflags_writeable_get,
+        (setter)arrayflags_writeable_set,
+        "", NULL},
     {"fnc",
-     (getter)arrayflags_fnc_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_fnc_get,
+        NULL,
+        "", NULL},
     {"forc",
-     (getter)arrayflags_forc_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_forc_get,
+        NULL,
+        "", NULL},
     {"behaved",
-     (getter)arrayflags_behaved_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_behaved_get,
+        NULL,
+        "", NULL},
     {"carray",
-     (getter)arrayflags_carray_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_carray_get,
+        NULL,
+        "", NULL},
     {"farray",
-     (getter)arrayflags_farray_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_farray_get,
+        NULL,
+        "", NULL},
     {"num",
-     (getter)arrayflags_num_get,
-     NULL,
-     "", NULL},
+        (getter)arrayflags_num_get,
+        NULL,
+        "", NULL},
     {NULL, NULL, NULL, NULL, NULL},
 };
 
@@ -12780,7 +13290,9 @@
 {
     char *key;
     int n;
-    if (!PyString_Check(ind)) goto fail;
+    if (!PyString_Check(ind)) {
+        goto fail;
+    }
     key = PyString_AS_STRING(ind);
     n = PyString_GET_SIZE(ind);
     switch(n) {
@@ -12805,50 +13317,65 @@
         }
         break;
     case 2:
-        if (strncmp(key, "CA", n)==0)
+        if (strncmp(key, "CA", n) == 0) {
             return arrayflags_carray_get(self);
-        if (strncmp(key, "FA", n)==0)
+        }
+        if (strncmp(key, "FA", n) == 0) {
             return arrayflags_farray_get(self);
+        }
         break;
     case 3:
-        if (strncmp(key, "FNC", n)==0)
+        if (strncmp(key, "FNC", n) == 0) {
             return arrayflags_fnc_get(self);
+        }
         break;
     case 4:
-        if (strncmp(key, "FORC", n)==0)
+        if (strncmp(key, "FORC", n) == 0) {
             return arrayflags_forc_get(self);
+        }
         break;
     case 6:
-        if (strncmp(key, "CARRAY", n)==0)
+        if (strncmp(key, "CARRAY", n) == 0) {
             return arrayflags_carray_get(self);
-        if (strncmp(key, "FARRAY", n)==0)
+        }
+        if (strncmp(key, "FARRAY", n) == 0) {
             return arrayflags_farray_get(self);
+        }
         break;
     case 7:
-        if (strncmp(key,"FORTRAN",n)==0)
+        if (strncmp(key,"FORTRAN",n) == 0) {
             return arrayflags_fortran_get(self);
-        if (strncmp(key,"BEHAVED",n)==0)
+        }
+        if (strncmp(key,"BEHAVED",n) == 0) {
             return arrayflags_behaved_get(self);
-        if (strncmp(key,"OWNDATA",n)==0)
+        }
+        if (strncmp(key,"OWNDATA",n) == 0) {
             return arrayflags_owndata_get(self);
-        if (strncmp(key,"ALIGNED",n)==0)
+        }
+        if (strncmp(key,"ALIGNED",n) == 0) {
             return arrayflags_aligned_get(self);
+        }
         break;
     case 9:
-        if (strncmp(key,"WRITEABLE",n)==0)
+        if (strncmp(key,"WRITEABLE",n) == 0) {
             return arrayflags_writeable_get(self);
+        }
         break;
     case 10:
-        if (strncmp(key,"CONTIGUOUS",n)==0)
+        if (strncmp(key,"CONTIGUOUS",n) == 0) {
             return arrayflags_contiguous_get(self);
+        }
         break;
     case 12:
-        if (strncmp(key, "UPDATEIFCOPY", n)==0)
+        if (strncmp(key, "UPDATEIFCOPY", n) == 0) {
             return arrayflags_updateifcopy_get(self);
-        if (strncmp(key, "C_CONTIGUOUS", n)==0)
+        }
+        if (strncmp(key, "C_CONTIGUOUS", n) == 0) {
             return arrayflags_contiguous_get(self);
-        if (strncmp(key, "F_CONTIGUOUS", n)==0)
+        }
+        if (strncmp(key, "F_CONTIGUOUS", n) == 0) {
             return arrayflags_fortran_get(self);
+        }
         break;
     }
 
@@ -12862,18 +13389,23 @@
 {
     char *key;
     int n;
-    if (!PyString_Check(ind)) goto fail;
+    if (!PyString_Check(ind)) {
+        goto fail;
+    }
     key = PyString_AS_STRING(ind);
     n = PyString_GET_SIZE(ind);
-    if (((n==9) && (strncmp(key, "WRITEABLE", n)==0)) ||
-        ((n==1) && (strncmp(key, "W", n)==0)))
+    if (((n==9) && (strncmp(key, "WRITEABLE", n) == 0)) ||
+        ((n==1) && (strncmp(key, "W", n) == 0))) {
         return arrayflags_writeable_set(self, item);
-    else if (((n==7) && (strncmp(key, "ALIGNED", n)==0)) ||
-             ((n==1) && (strncmp(key, "A", n)==0)))
+    }
+    else if (((n==7) && (strncmp(key, "ALIGNED", n) == 0)) ||
+             ((n==1) && (strncmp(key, "A", n) == 0))) {
         return arrayflags_aligned_set(self, item);
-    else if (((n==12) && (strncmp(key, "UPDATEIFCOPY", n)==0)) ||
-             ((n==1) && (strncmp(key, "U", n)==0)))
+    }
+    else if (((n==12) && (strncmp(key, "UPDATEIFCOPY", n) == 0)) ||
+             ((n==1) && (strncmp(key, "U", n) == 0))) {
         return arrayflags_updateifcopy_set(self, item);
+    }
 
  fail:
     PyErr_SetString(PyExc_KeyError, "Unknown flag");
@@ -12883,8 +13415,12 @@
 static char *
 _torf_(int flags, int val)
 {
-    if ((flags & val) == val) return "True";
-    else return "False";
+    if ((flags & val) == val) {
+        return "True";
+    }
+    else {
+        return "False";
+    }
 }
 
 static PyObject *
@@ -12906,12 +13442,15 @@
 static int
 arrayflags_compare(PyArrayFlagsObject *self, PyArrayFlagsObject *other)
 {
-    if (self->flags == other->flags)
+    if (self->flags == other->flags) {
         return 0;
-    else if (self->flags < other->flags)
+    }
+    else if (self->flags < other->flags) {
         return -1;
-    else
+    }
+    else {
         return 1;
+    }
 }
 
 static PyMappingMethods arrayflags_as_mapping = {
@@ -12929,9 +13468,9 @@
 arrayflags_new(PyTypeObject *NPY_UNUSED(self), PyObject *args, PyObject *NPY_UNUSED(kwds))
 {
     PyObject *arg=NULL;
-    if (!PyArg_UnpackTuple(args, "flagsobj", 0, 1, &arg))
+    if (!PyArg_UnpackTuple(args, "flagsobj", 0, 1, &arg)) {
         return NULL;
-
+    }
     if ((arg != NULL) && PyArray_Check(arg)) {
         return PyArray_NewFlagsObject(arg);
     }
@@ -12945,7 +13484,7 @@
     0,
     "numpy.flagsobj",
     sizeof(PyArrayFlagsObject),
-    0,                                       /* tp_itemsize */
+    0,                                      /* tp_itemsize */
     /* methods */
     (destructor)arrayflags_dealloc,         /* tp_dealloc */
     0,                                      /* tp_print */
@@ -12970,32 +13509,32 @@
     0,                                      /* tp_weaklistoffset */
     0,                                      /* tp_iter */
     0,                                      /* tp_iternext */
-    0,                                       /* tp_methods */
-    0,                                       /* tp_members */
-    arrayflags_getsets,                      /* tp_getset */
-    0,                                        /* tp_base */
-    0,                                        /* tp_dict */
-    0,                                        /* tp_descr_get */
-    0,                                        /* tp_descr_set */
-    0,                                        /* tp_dictoffset */
-    0,                                        /* tp_init */
-    0,                                        /* tp_alloc */
-    arrayflags_new,                           /* tp_new */
-    0,                                        /* tp_free */
-    0,                                        /* tp_is_gc */
-    0,                                        /* tp_bases */
-    0,                                        /* tp_mro */
-    0,                                        /* tp_cache */
-    0,                                        /* tp_subclasses */
-    0,                                        /* tp_weaklist */
-    0,   /* tp_del */
+    0,                                      /* tp_methods */
+    0,                                      /* tp_members */
+    arrayflags_getsets,                     /* tp_getset */
+    0,                                      /* tp_base */
+    0,                                      /* tp_dict */
+    0,                                      /* tp_descr_get */
+    0,                                      /* tp_descr_set */
+    0,                                      /* tp_dictoffset */
+    0,                                      /* tp_init */
+    0,                                      /* tp_alloc */
+    arrayflags_new,                         /* tp_new */
+    0,                                      /* tp_free */
+    0,                                      /* tp_is_gc */
+    0,                                      /* tp_bases */
+    0,                                      /* tp_mro */
+    0,                                      /* tp_cache */
+    0,                                      /* tp_subclasses */
+    0,                                      /* tp_weaklist */
+    0,                                      /* tp_del */
 
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                      /* tp_allocs */
+    0,                                      /* tp_frees */
+    0,                                      /* tp_maxalloc */
+    0,                                      /* tp_prev */
+    0,                                      /* *tp_next */
 #endif
 };

Modified: branches/coremath/numpy/core/src/multiarraymodule.c
===================================================================
--- branches/coremath/numpy/core/src/multiarraymodule.c	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/core/src/multiarraymodule.c	2009-02-22 03:41:06 UTC (rev 6445)
@@ -25,7 +25,7 @@
 #define PyAO PyArrayObject
 
 
-static PyObject *typeDict=NULL;   /* Must be explicitly loaded */
+static PyObject *typeDict = NULL;   /* Must be explicitly loaded */
 
 static PyArray_Descr *
 _arraydescr_fromobj(PyObject *obj)
@@ -39,7 +39,9 @@
     if (dtypedescr) {
         ret = PyArray_DescrConverter(dtypedescr, &new);
         Py_DECREF(dtypedescr);
-        if (ret == PY_SUCCEED) return new;
+        if (ret == PY_SUCCEED) {
+            return new;
+        }
         PyErr_Clear();
     }
     /* Understand basic ctypes */
@@ -52,13 +54,16 @@
             PyObject *length;
             length = PyObject_GetAttrString(obj, "_length_");
             PyErr_Clear();
-            if (length) { /* derived type */
+            if (length) {
+                /* derived type */
                 PyObject *newtup;
                 PyArray_Descr *derived;
                 newtup = Py_BuildValue("NO", new, length);
                 ret = PyArray_DescrConverter(newtup, &derived);
                 Py_DECREF(newtup);
-                if (ret == PY_SUCCEED) return derived;
+                if (ret == PY_SUCCEED) {
+                    return derived;
+                }
                 PyErr_Clear();
                 return NULL;
             }
@@ -75,24 +80,27 @@
     if (dtypedescr) {
         ret = PyArray_DescrAlignConverter(dtypedescr, &new);
         Py_DECREF(dtypedescr);
-        if (ret == PY_SUCCEED) return new;
+        if (ret == PY_SUCCEED) {
+            return new;
+        }
         PyErr_Clear();
     }
     return NULL;
 }
 
-/* Including this file is the only way I know how to declare functions
-   static in each file, and store the pointers from functions in both
-   arrayobject.c and multiarraymodule.c for the C-API
+/*
+ * Including this file is the only way I know how to declare functions
+ * static in each file, and store the pointers from functions in both
+ * arrayobject.c and multiarraymodule.c for the C-API
+ *
+ * Declarying an external pointer-containing variable in arrayobject.c
+ * and trying to copy it to PyArray_API, did not work.
+ *
+ * Think about two modules with a common api that import each other...
+ *
+ * This file would just be the module calls.
+ */
 
-   Declarying an external pointer-containing variable in arrayobject.c
-   and trying to copy it to PyArray_API, did not work.
-
-   Think about two modules with a common api that import each other...
-
-   This file would just be the module calls.
-*/
-
 #include "arrayobject.c"
 
 
@@ -100,60 +108,72 @@
 static PyObject *MultiArrayError;
 
 /*NUMPY_API
-  Multiply a List of ints
-*/
+ * Multiply a List of ints
+ */
 static int
 PyArray_MultiplyIntList(register int *l1, register int n)
 {
-    register int s=1;
-    while (n--) s *= (*l1++);
+    int s = 1;
+
+    while (n--) {
+        s *= (*l1++);
+    }
     return s;
 }
 
 /*NUMPY_API
-  Multiply a List
-*/
+ * Multiply a List
+ */
 static intp
 PyArray_MultiplyList(register intp *l1, register int n)
 {
-    register intp s=1;
-    while (n--) s *= (*l1++);
+    intp s = 1;
+
+    while (n--) {
+        s *= (*l1++);
+    }
     return s;
 }
 
 /*NUMPY_API
-  Multiply a List of Non-negative numbers with over-flow detection.
-*/
+ * Multiply a List of Non-negative numbers with over-flow detection.
+ */
 static intp
 PyArray_OverflowMultiplyList(register intp *l1, register int n)
 {
-    register intp s=1;
+    intp s = 1;
+
     while (n--) {
-	if (*l1 == 0) return 0;
-	if ((s > MAX_INTP / *l1) || (*l1 > MAX_INTP / s))
+	if (*l1 == 0) {
+            return 0;
+        }
+	if ((s > MAX_INTP / *l1) || (*l1 > MAX_INTP / s)) {
 	    return -1;
+        }
 	s *= (*l1++);
     }
     return s;
 }
 
 /*NUMPY_API
-  Produce a pointer into array
-*/
+ * Produce a pointer into array
+ */
 static void *
 PyArray_GetPtr(PyArrayObject *obj, register intp* ind)
 {
-    register int n = obj->nd;
-    register intp *strides = obj->strides;
-    register char *dptr = obj->data;
+    int n = obj->nd;
+    intp *strides = obj->strides;
+    char *dptr = obj->data;
 
-    while (n--) dptr += (*strides++) * (*ind++);
+    while (n--) {
+        dptr += (*strides++) * (*ind++);
+    }
     return (void *)dptr;
 }
 
 /*NUMPY_API
-  Get axis from an object (possibly None) -- a converter function,
-*/
+ * Get axis from an object (possibly None) -- a converter function,
+ */
 static int
 PyArray_AxisConverter(PyObject *obj, int *axis)
 {
@@ -170,31 +190,37 @@
 }
 
 /*NUMPY_API
-  Compare Lists
-*/
+ * Compare Lists
+ */
 static int
 PyArray_CompareLists(intp *l1, intp *l2, int n)
 {
     int i;
-    for(i=0;i<n;i++) {
-        if (l1[i] != l2[i]) return 0;
+
+    for (i = 0; i < n; i++) {
+        if (l1[i] != l2[i]) {
+            return 0;
+        }
     }
     return 1;
 }
 
-/* steals a reference to type -- accepts NULL */
 /*NUMPY_API
-  View
-*/
+ * View
+ * steals a reference to type -- accepts NULL
+ */
 static PyObject *
 PyArray_View(PyArrayObject *self, PyArray_Descr *type, PyTypeObject *pytype)
 {
-    PyObject *new=NULL;
+    PyObject *new = NULL;
     PyTypeObject *subtype;
 
-    if (pytype) subtype = pytype;
-    else subtype = self->ob_type;
-
+    if (pytype) {
+        subtype = pytype;
+    }
+    else {
+        subtype = self->ob_type;
+    }
     Py_INCREF(self->descr);
     new = PyArray_NewFromDescr(subtype,
                                self->descr,
@@ -202,8 +228,9 @@
                                self->strides,
                                self->data,
                                self->flags, (PyObject *)self);
-
-    if (new==NULL) return NULL;
+    if (new == NULL) {
+        return NULL;
+    }
     Py_INCREF(self);
     PyArray_BASE(new) = (PyObject *)self;
 
@@ -219,20 +246,20 @@
     return new;
 }
 
-/* Returns a contiguous array */
 
 /*NUMPY_API
-  Ravel
-*/
+ * Ravel
+ * Returns a contiguous array
+ */
 static PyObject *
 PyArray_Ravel(PyArrayObject *a, NPY_ORDER fortran)
 {
     PyArray_Dims newdim = {NULL,1};
     intp val[1] = {-1};
 
-    if (fortran == PyArray_ANYORDER)
+    if (fortran == PyArray_ANYORDER) {
         fortran = PyArray_ISFORTRAN(a);
-
+    }
     newdim.ptr = val;
     if (!fortran && PyArray_ISCONTIGUOUS(a)) {
         return PyArray_Newshape(a, &newdim, PyArray_CORDER);
@@ -240,8 +267,9 @@
     else if (fortran && PyArray_ISFORTRAN(a)) {
         return PyArray_Newshape(a, &newdim, PyArray_FORTRANORDER);
     }
-    else
+    else {
         return PyArray_Flatten(a, fortran);
+    }
 }
 
 static double
@@ -249,23 +277,25 @@
 {
     static const double p10[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8};
     double ret;
-    if (n < 9)
+    if (n < 9) {
         ret = p10[n];
+    }
     else {
         ret = 1e9;
-        while (n-- > 9)
+        while (n-- > 9) {
             ret *= 10.;
+        }
     }
     return ret;
 }
 
 /*NUMPY_API
-  Round
-*/
+ * Round
+ */
 static PyObject *
 PyArray_Round(PyArrayObject *a, int decimals, PyArrayObject *out)
 {
-    PyObject *f, *ret=NULL, *tmp, *op1, *op2;
+    PyObject *f, *ret = NULL, *tmp, *op1, *op2;
     int ret_int=0;
     PyArray_Descr *my_descr;
     if (out && (PyArray_SIZE(out) != PyArray_SIZE(a))) {
@@ -278,45 +308,68 @@
         PyObject *round_part;
         PyObject *new;
         int res;
+
         if (out) {
             new = (PyObject *)out;
             Py_INCREF(new);
         }
         else {
             new = PyArray_Copy(a);
-            if (new == NULL) return NULL;
+            if (new == NULL) {
+                return NULL;
+            }
         }
 
         /* new.real = a.real.round(decimals) */
         part = PyObject_GetAttrString(new, "real");
-        if (part == NULL) {Py_DECREF(new); return NULL;}
+        if (part == NULL) {
+            Py_DECREF(new);
+            return NULL;
+        }
         part = PyArray_EnsureAnyArray(part);
         round_part = PyArray_Round((PyArrayObject *)part,
                                    decimals, NULL);
         Py_DECREF(part);
-        if (round_part == NULL) {Py_DECREF(new); return NULL;}
+        if (round_part == NULL) {
+            Py_DECREF(new);
+            return NULL;
+        }
         res = PyObject_SetAttrString(new, "real", round_part);
         Py_DECREF(round_part);
-        if (res < 0) {Py_DECREF(new); return NULL;}
+        if (res < 0) {
+            Py_DECREF(new);
+            return NULL;
+        }
 
         /* new.imag = a.imag.round(decimals) */
         part = PyObject_GetAttrString(new, "imag");
-        if (part == NULL) {Py_DECREF(new); return NULL;}
+        if (part == NULL) {
+            Py_DECREF(new);
+            return NULL;
+        }
         part = PyArray_EnsureAnyArray(part);
         round_part = PyArray_Round((PyArrayObject *)part,
                                    decimals, NULL);
         Py_DECREF(part);
-        if (round_part == NULL) {Py_DECREF(new); return NULL;}
+        if (round_part == NULL) {
+            Py_DECREF(new);
+            return NULL;
+        }
         res = PyObject_SetAttrString(new, "imag", round_part);
         Py_DECREF(round_part);
-        if (res < 0) {Py_DECREF(new); return NULL;}
+        if (res < 0) {
+            Py_DECREF(new);
+            return NULL;
+        }
         return new;
     }
     /* do the most common case first */
     if (decimals >= 0) {
         if (PyArray_ISINTEGER(a)) {
             if (out) {
-                if (PyArray_CopyAnyInto(out, a) < 0) return NULL;
+                if (PyArray_CopyAnyInto(out, a) < 0) {
+                    return NULL;
+                }
                 Py_INCREF(out);
                 return (PyObject *)out;
             }
@@ -327,8 +380,7 @@
         }
         if (decimals == 0) {
             if (out) {
-                return PyObject_CallFunction(n_ops.rint, "OO",
-                                             a, out);
+                return PyObject_CallFunction(n_ops.rint, "OO", a, out);
             }
             return PyObject_CallFunction(n_ops.rint, "O", a);
         }
@@ -352,18 +404,34 @@
         out = (PyArrayObject *)PyArray_Empty(a->nd, a->dimensions,
                                              my_descr,
                                              PyArray_ISFORTRAN(a));
-        if (out == NULL) return NULL;
+        if (out == NULL) {
+            return NULL;
+        }
     }
-    else Py_INCREF(out);
+    else {
+        Py_INCREF(out);
+    }
     f = PyFloat_FromDouble(power_of_ten(decimals));
-    if (f==NULL) return NULL;
+    if (f == NULL) {
+        return NULL;
+    }
     ret = PyObject_CallFunction(op1, "OOO", a, f, out);
-    if (ret==NULL) goto finish;
+    if (ret == NULL) {
+        goto finish;
+    }
     tmp = PyObject_CallFunction(n_ops.rint, "OO", ret, ret);
-    if (tmp == NULL) {Py_DECREF(ret); ret=NULL; goto finish;}
+    if (tmp == NULL) {
+        Py_DECREF(ret);
+        ret = NULL;
+        goto finish;
+    }
     Py_DECREF(tmp);
     tmp = PyObject_CallFunction(op2, "OOO", ret, f, ret);
-    if (tmp == NULL) {Py_DECREF(ret); ret=NULL; goto finish;}
+    if (tmp == NULL) {
+        Py_DECREF(ret);
+        ret = NULL;
+        goto finish;
+    }
     Py_DECREF(tmp);
 
  finish:
@@ -377,22 +445,21 @@
         return tmp;
     }
     return ret;
-
 }
 
 
 /*NUMPY_API
-  Flatten
-*/
+ * Flatten
+ */
 static PyObject *
 PyArray_Flatten(PyArrayObject *a, NPY_ORDER order)
 {
     PyObject *ret;
     intp size;
 
-    if (order == PyArray_ANYORDER)
+    if (order == PyArray_ANYORDER) {
         order = PyArray_ISFORTRAN(a);
-
+    }
     size = PyArray_SIZE(a);
     Py_INCREF(a->descr);
     ret = PyArray_NewFromDescr(a->ob_type,
@@ -402,7 +469,9 @@
                                NULL,
                                0, (PyObject *)a);
 
-    if (ret== NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     if (_flat_copyinto(ret, (PyObject *)a, order) < 0) {
         Py_DECREF(ret);
         return NULL;
@@ -411,20 +480,20 @@
 }
 
 
-/* For back-ward compatability *
+/* For back-ward compatability -- Not recommended */
 
-   / * Not recommended */
-
 /*NUMPY_API
-  Reshape an array
-*/
+ * Reshape
+ */
 static PyObject *
 PyArray_Reshape(PyArrayObject *self, PyObject *shape)
 {
     PyObject *ret;
     PyArray_Dims newdims;
 
-    if (!PyArray_IntpConverter(shape, &newdims)) return NULL;
+    if (!PyArray_IntpConverter(shape, &newdims)) {
+        return NULL;
+    }
     ret = PyArray_Newshape(self, &newdims, PyArray_CORDER);
     PyDimMem_FREE(newdims.ptr);
     return ret;
@@ -442,25 +511,31 @@
     nd = self->nd;
     dims = self->dimensions;
 
-    for (k=0, j=0; !done && (j<nd || k<newnd);) {
-        if ((j<nd) && (k<newnd) && (newdims[k]==dims[j])) {
+    for (k = 0, j = 0; !done && (j < nd || k < newnd);) {
+        if ((j<nd) && (k<newnd) && (newdims[k] == dims[j])) {
             strides[k] = self->strides[j];
-            j++; k++;
+            j++;
+            k++;
         }
-        else if ((k<newnd) && (newdims[k]==1)) {
+        else if ((k < newnd) && (newdims[k] == 1)) {
             strides[k] = 0;
             k++;
         }
-        else if ((j<nd) && (dims[j]==1)) {
+        else if ((j<nd) && (dims[j] == 1)) {
             j++;
         }
-        else done=TRUE;
+        else {
+            done = TRUE;
+        }
     }
-    if (done) return -1;
+    if (done) {
+        return -1;
+    }
     return 0;
 }
 
-/* attempt to reshape an array without copying data
+/*
+ * attempt to reshape an array without copying data
  *
  * This function should correctly handle all reshapes, including
  * axes of length 1. Zero strides should work but are untested.
@@ -488,8 +563,8 @@
     int np, op;
 
     oldnd = 0;
-    for (oi=0; oi<self->nd; oi++) {
-        if (self->dimensions[oi]!=1) {
+    for (oi = 0; oi < self->nd; oi++) {
+        if (self->dimensions[oi]!= 1) {
             olddims[oldnd] = self->dimensions[oi];
             oldstrides[oldnd] = self->strides[oi];
             oldnd++;
@@ -508,13 +583,17 @@
 
 
     np = 1;
-    for (ni=0; ni<newnd; ni++) np*=newdims[ni];
-
+    for (ni = 0; ni < newnd; ni++) {
+        np *= newdims[ni];
+    }
     op = 1;
-    for (oi=0; oi<oldnd; oi++) op*=olddims[oi];
-
-    if (np != op) return 0; /* different total sizes; no hope */
-
+    for (oi = 0; oi < oldnd; oi++) {
+        op *= olddims[oi];
+    }
+    if (np != op) {
+        /* different total sizes; no hope */
+        return 0;
+    }
     /* the current code does not handle 0-sized arrays, so give up */
     if (np == 0) {
         return 0;
@@ -524,45 +603,49 @@
     oj = 1;
     ni = 0;
     nj = 1;
-
-    while(ni<newnd && oi<oldnd) {
-
+    while(ni < newnd && oi < oldnd) {
         np = newdims[ni];
         op = olddims[oi];
 
-        while (np!=op) {
-            if (np<op) {
+        while (np != op) {
+            if (np < op) {
                 np *= newdims[nj++];
             } else {
                 op *= olddims[oj++];
             }
         }
 
-        for(ok=oi; ok<oj-1; ok++) {
+        for (ok = oi; ok < oj - 1; ok++) {
             if (fortran) {
-                if (oldstrides[ok+1] !=         \
-                    olddims[ok]*oldstrides[ok])
-                    return 0; /* not contiguous enough */
-            } else { /* C order */
-                if (oldstrides[ok] !=                   \
-                    olddims[ok+1]*oldstrides[ok+1])
-                    return 0; /* not contiguous enough */
+                if (oldstrides[ok+1] != olddims[ok]*oldstrides[ok]) {
+                     /* not contiguous enough */
+                    return 0;
+                }
             }
+            else {
+                /* C order */
+                if (oldstrides[ok] != olddims[ok+1]*oldstrides[ok+1]) {
+                    /* not contiguous enough */
+                    return 0;
+                }
+            }
         }
 
         if (fortran) {
-            newstrides[ni]=oldstrides[oi];
-            for (nk=ni+1;nk<nj;nk++)
-                newstrides[nk]=newstrides[nk-1]*newdims[nk-1];
-        } else { /* C order */
-            newstrides[nj-1]=oldstrides[oj-1];
-            for (nk=nj-1;nk>ni;nk--)
-                newstrides[nk-1]=newstrides[nk]*newdims[nk];
+            newstrides[ni] = oldstrides[oi];
+            for (nk = ni + 1; nk < nj; nk++) {
+                newstrides[nk] = newstrides[nk - 1]*newdims[nk - 1];
+            }
         }
-
+        else {
+            /* C order */
+            newstrides[nj - 1] = oldstrides[oj - 1];
+            for (nk = nj - 1; nk > ni; nk--) {
+                newstrides[nk - 1] = newstrides[nk]*newdims[nk];
+            }
+        }
         ni = nj++;
         oi = oj++;
-
     }
 
     /*
@@ -591,17 +674,19 @@
     s_known = 1;
     i_unknown = -1;
 
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         if (dimensions[i] < 0) {
             if (i_unknown == -1) {
                 i_unknown = i;
-            } else {
+            }
+            else {
                 PyErr_SetString(PyExc_ValueError,
                                 "can only specify one"  \
                                 " unknown dimension");
                 return -1;
             }
-        } else {
+        }
+        else {
             s_known *= dimensions[i];
         }
     }
@@ -612,7 +697,8 @@
             return -1;
         }
         dimensions[i_unknown] = s_original/s_known;
-    } else {
+    }
+    else {
         if (s_original != s_known) {
             PyErr_SetString(PyExc_ValueError, msg);
             return -1;
@@ -621,15 +707,16 @@
     return 0;
 }
 
-/* Returns a new array
-   with the new shape from the data
-   in the old array --- order-perspective depends on fortran argument.
-   copy-only-if-necessary
-*/
+/*
+ * Returns a new array
+ * with the new shape from the data
+ * in the old array --- order-perspective depends on fortran argument.
+ * copy-only-if-necessary
+ */
 
 /*NUMPY_API
-  New shape for an array
-*/
+ * New shape for an array
+ */
 static PyObject *
 PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
                  NPY_ORDER fortran)
@@ -638,79 +725,85 @@
     intp *dimensions = newdims->ptr;
     PyArrayObject *ret;
     int n = newdims->len;
-    Bool same, incref=TRUE;
+    Bool same, incref = TRUE;
     intp *strides = NULL;
     intp newstrides[MAX_DIMS];
     int flags;
 
-    if (fortran == PyArray_ANYORDER)
+    if (fortran == PyArray_ANYORDER) {
         fortran = PyArray_ISFORTRAN(self);
-
+    }
     /*  Quick check to make sure anything actually needs to be done */
     if (n == self->nd) {
         same = TRUE;
-        i=0;
-        while(same && i<n) {
-            if (PyArray_DIM(self,i) != dimensions[i])
+        i = 0;
+        while (same && i < n) {
+            if (PyArray_DIM(self,i) != dimensions[i]) {
                 same=FALSE;
+            }
             i++;
         }
-        if (same) return PyArray_View(self, NULL, NULL);
+        if (same) {
+            return PyArray_View(self, NULL, NULL);
+        }
     }
 
-    /* Returns a pointer to an appropriate strides array
-       if all we are doing is inserting ones into the shape,
-       or removing ones from the shape
-       or doing a combination of the two
-       In this case we don't need to do anything but update strides and
-       dimensions.  So, we can handle non single-segment cases.
-    */
-    i=_check_ones(self, n, dimensions, newstrides);
-    if (i==0) strides=newstrides;
-
+    /*
+     * Returns a pointer to an appropriate strides array
+     * if all we are doing is inserting ones into the shape,
+     * or removing ones from the shape
+     * or doing a combination of the two
+     * In this case we don't need to do anything but update strides and
+     * dimensions.  So, we can handle non single-segment cases.
+     */
+    i = _check_ones(self, n, dimensions, newstrides);
+    if (i == 0) {
+        strides = newstrides;
+    }
     flags = self->flags;
 
-    if (strides==NULL) { /* we are really re-shaping not just adding ones
-                            to the shape somewhere */
-
-        /* fix any -1 dimensions and check new-dimensions against
-           old size */
-        if (_fix_unknown_dimension(newdims, PyArray_SIZE(self)) < 0)
+    if (strides == NULL) {
+        /*
+         * we are really re-shaping not just adding ones to the shape somewhere
+         * fix any -1 dimensions and check new-dimensions against old size
+         */
+        if (_fix_unknown_dimension(newdims, PyArray_SIZE(self)) < 0) {
             return NULL;
-
-        /* sometimes we have to create a new copy of the array
-           in order to get the right orientation and
-           because we can't just re-use the buffer with the
-           data in the order it is in.
-        */
+        }
+        /*
+         * sometimes we have to create a new copy of the array
+         * in order to get the right orientation and
+         * because we can't just re-use the buffer with the
+         * data in the order it is in.
+         */
         if (!(PyArray_ISONESEGMENT(self)) ||
             (((PyArray_CHKFLAGS(self, NPY_CONTIGUOUS) &&
-               fortran == NPY_FORTRANORDER)
-              || (PyArray_CHKFLAGS(self, NPY_FORTRAN) &&
+               fortran == NPY_FORTRANORDER) ||
+              (PyArray_CHKFLAGS(self, NPY_FORTRAN) &&
                   fortran == NPY_CORDER)) && (self->nd > 1))) {
-
-            int success=0;
+            int success = 0;
             success = _attempt_nocopy_reshape(self,n,dimensions,
                                               newstrides,fortran);
             if (success) {
                 /* no need to copy the array after all */
                 strides = newstrides;
                 flags = self->flags;
-            } else {
+            }
+            else {
                 PyObject *new;
                 new = PyArray_NewCopy(self, fortran);
-                if (new == NULL) return NULL;
+                if (new == NULL) {
+                    return NULL;
+                }
                 incref = FALSE;
                 self = (PyArrayObject *)new;
                 flags = self->flags;
             }
         }
 
-        /* We always have to interpret the contiguous buffer correctly
-         */
+        /* We always have to interpret the contiguous buffer correctly */
 
-        /* Make sure the flags argument is set.
-         */
+        /* Make sure the flags argument is set. */
         if (n > 1) {
             if (fortran == NPY_FORTRANORDER) {
                 flags &= ~NPY_CONTIGUOUS;
@@ -723,26 +816,29 @@
         }
     }
     else if (n > 0) {
-        /* replace any 0-valued strides with
-           appropriate value to preserve contiguousness
-        */
+        /*
+         * replace any 0-valued strides with
+         * appropriate value to preserve contiguousness
+         */
         if (fortran == PyArray_FORTRANORDER) {
-            if (strides[0] == 0)
+            if (strides[0] == 0) {
                 strides[0] = self->descr->elsize;
-            for (i=1; i<n; i++) {
-                if (strides[i] == 0)
-                    strides[i] = strides[i-1] *     \
-                        dimensions[i-1];
             }
+            for (i = 1; i < n; i++) {
+                if (strides[i] == 0) {
+                    strides[i] = strides[i-1] * dimensions[i-1];
+                }
+            }
         }
         else {
-            if (strides[n-1] == 0)
+            if (strides[n-1] == 0) {
                 strides[n-1] = self->descr->elsize;
-            for (i=n-2; i>-1; i--) {
-                if (strides[i] == 0)
-                    strides[i] = strides[i+1] *     \
-                        dimensions[i+1];
             }
+            for (i = n - 2; i > -1; i--) {
+                if (strides[i] == 0) {
+                    strides[i] = strides[i+1] * dimensions[i+1];
+                }
+            }
         }
     }
 
@@ -754,27 +850,31 @@
                                        self->data,
                                        flags, (PyObject *)self);
 
-    if (ret== NULL) goto fail;
-
-    if (incref) Py_INCREF(self);
+    if (ret == NULL) {
+        goto fail;
+    }
+    if (incref) {
+        Py_INCREF(self);
+    }
     ret->base = (PyObject *)self;
     PyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);
-
     return (PyObject *)ret;
 
  fail:
-    if (!incref) {Py_DECREF(self);}
+    if (!incref) {
+        Py_DECREF(self);
+    }
     return NULL;
 }
 
 
 
-/* return a new view of the array object with all of its unit-length
-   dimensions squeezed out if needed, otherwise
-   return the same array.
-*/
-
-/*NUMPY_API*/
+/*NUMPY_API
+ *
+ * return a new view of the array object with all of its unit-length
+ * dimensions squeezed out if needed, otherwise
+ * return the same array.
+ */
 static PyObject *
 PyArray_Squeeze(PyArrayObject *self)
 {
@@ -782,14 +882,14 @@
     int newnd = nd;
     intp dimensions[MAX_DIMS];
     intp strides[MAX_DIMS];
-    int i,j;
+    int i, j;
     PyObject *ret;
 
     if (nd == 0) {
         Py_INCREF(self);
         return (PyObject *)self;
     }
-    for (j=0, i=0; i<nd; i++) {
+    for (j = 0, i = 0; i < nd; i++) {
         if (self->dimensions[i] == 1) {
             newnd -= 1;
         }
@@ -806,7 +906,9 @@
                                strides, self->data,
                                self->flags,
                                (PyObject *)self);
-    if (ret == NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     PyArray_FLAGS(ret) &= ~OWNDATA;
     PyArray_BASE(ret) = (PyObject *)self;
     Py_INCREF(self);
@@ -815,16 +917,17 @@
 
 
 /*NUMPY_API
-  Mean
-*/
+ * Mean
+ */
 static PyObject *
 PyArray_Mean(PyArrayObject *self, int axis, int rtype, PyArrayObject *out)
 {
-    PyObject *obj1=NULL, *obj2=NULL;
+    PyObject *obj1 = NULL, *obj2 = NULL;
     PyObject *new, *ret;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
-
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
     obj1 = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,
                                          rtype, out);
     obj2 = PyFloat_FromDouble((double) PyArray_DIM(new,axis));
@@ -845,10 +948,10 @@
     return ret;
 }
 
-/* Set variance to 1 to by-pass square-root calculation and return variance */
 /*NUMPY_API
-  Std
-*/
+ * Set variance to 1 to by-pass square-root calculation and return variance
+ * Std
+ */
 static PyObject *
 PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out,
 	    int variance)
@@ -860,34 +963,51 @@
 __New_PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out,
 		  int variance, int num)
 {
-    PyObject *obj1=NULL, *obj2=NULL, *obj3=NULL, *new=NULL;
-    PyObject *ret=NULL, *newshape=NULL;
+    PyObject *obj1 = NULL, *obj2 = NULL, *obj3 = NULL, *new = NULL;
+    PyObject *ret = NULL, *newshape = NULL;
     int i, n;
     intp val;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
-
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
     /* Compute and reshape mean */
     obj1 = PyArray_EnsureAnyArray(PyArray_Mean((PyAO *)new, axis, rtype, NULL));
-    if (obj1 == NULL) {Py_DECREF(new); return NULL;}
+    if (obj1 == NULL) {
+        Py_DECREF(new);
+        return NULL;
+    }
     n = PyArray_NDIM(new);
     newshape = PyTuple_New(n);
-    if (newshape == NULL) {Py_DECREF(obj1); Py_DECREF(new); return NULL;}
-    for (i=0; i<n; i++) {
-        if (i==axis) val = 1;
-        else val = PyArray_DIM(new,i);
+    if (newshape == NULL) {
+        Py_DECREF(obj1);
+        Py_DECREF(new);
+        return NULL;
+    }
+    for (i = 0; i < n; i++) {
+        if (i == axis) {
+            val = 1;
+        }
+        else {
+            val = PyArray_DIM(new,i);
+        }
         PyTuple_SET_ITEM(newshape, i, PyInt_FromLong((long)val));
     }
     obj2 = PyArray_Reshape((PyAO *)obj1, newshape);
     Py_DECREF(obj1);
     Py_DECREF(newshape);
-    if (obj2 == NULL) {Py_DECREF(new); return NULL;}
+    if (obj2 == NULL) {
+        Py_DECREF(new);
+        return NULL;
+    }
 
     /* Compute x = x - mx */
     obj1 = PyArray_EnsureAnyArray(PyNumber_Subtract((PyObject *)new, obj2));
     Py_DECREF(obj2);
-    if (obj1 == NULL) {Py_DECREF(new); return NULL;}
-
+    if (obj1 == NULL) {
+        Py_DECREF(new);
+        return NULL;
+    }
     /* Compute x * x */
     if (PyArray_ISCOMPLEX(obj1)) {
 	obj3 = PyArray_Conjugate((PyAO *)obj1, NULL);
@@ -896,60 +1016,80 @@
 	obj3 = obj1;
 	Py_INCREF(obj1);
     }
-    if (obj3 == NULL) {Py_DECREF(new); return NULL;}
+    if (obj3 == NULL) {
+        Py_DECREF(new);
+        return NULL;
+    }
     obj2 = PyArray_EnsureAnyArray                                      \
         (PyArray_GenericBinaryFunction((PyAO *)obj1, obj3, n_ops.multiply));
     Py_DECREF(obj1);
     Py_DECREF(obj3);
-    if (obj2 == NULL) {Py_DECREF(new); return NULL;}
-
+    if (obj2 == NULL) {
+        Py_DECREF(new);
+        return NULL;
+    }
     if (PyArray_ISCOMPLEX(obj2)) {
 	obj3 = PyObject_GetAttrString(obj2, "real");
-	switch(rtype) {
-	case NPY_CDOUBLE:
-	    rtype = NPY_DOUBLE;
-	    break;
-	case NPY_CFLOAT:
-	    rtype = NPY_FLOAT;
-	    break;
-	case NPY_CLONGDOUBLE:
-	    rtype = NPY_LONGDOUBLE;
-	    break;
-	}
+        switch(rtype) {
+        case NPY_CDOUBLE:
+            rtype = NPY_DOUBLE;
+            break;
+        case NPY_CFLOAT:
+            rtype = NPY_FLOAT;
+            break;
+        case NPY_CLONGDOUBLE:
+            rtype = NPY_LONGDOUBLE;
+            break;
+        }
     }
     else {
 	obj3 = obj2;
 	Py_INCREF(obj2);
     }
-    if (obj3 == NULL) {Py_DECREF(new); return NULL;}
+    if (obj3 == NULL) {
+        Py_DECREF(new);
+        return NULL;
+    }
     /* Compute add.reduce(x*x,axis) */
     obj1 = PyArray_GenericReduceFunction((PyAO *)obj3, n_ops.add,
                                          axis, rtype, NULL);
     Py_DECREF(obj3);
     Py_DECREF(obj2);
-    if (obj1 == NULL) {Py_DECREF(new); return NULL;}
-
+    if (obj1 == NULL) {
+        Py_DECREF(new);
+        return NULL;
+    }
     n = PyArray_DIM(new,axis);
     Py_DECREF(new);
     n = (n-num);
-    if (n==0) n=1;
+    if (n == 0) {
+        n = 1;
+    }
     obj2 = PyFloat_FromDouble(1.0/((double )n));
-    if (obj2 == NULL) {Py_DECREF(obj1); return NULL;}
+    if (obj2 == NULL) {
+        Py_DECREF(obj1);
+        return NULL;
+    }
     ret = PyNumber_Multiply(obj1, obj2);
     Py_DECREF(obj1);
     Py_DECREF(obj2);
 
     if (!variance) {
         obj1 = PyArray_EnsureAnyArray(ret);
-
         /* sqrt() */
         ret = PyArray_GenericUnaryFunction((PyAO *)obj1, n_ops.sqrt);
         Py_DECREF(obj1);
     }
-    if (ret == NULL || PyArray_CheckExact(self)) return ret;
-    if (PyArray_Check(self) && self->ob_type == ret->ob_type) return ret;
+    if (ret == NULL || PyArray_CheckExact(self)) {
+        return ret;
+    }
+    if (PyArray_Check(self) && self->ob_type == ret->ob_type) {
+        return ret;
+    }
     obj1 = PyArray_EnsureArray(ret);
-    if (obj1 == NULL) return NULL;
+    if (obj1 == NULL) {
+        return NULL;
+    }
     ret = PyArray_View((PyAO *)obj1, NULL, self->ob_type);
     Py_DECREF(obj1);
     if (out) {
@@ -966,15 +1106,16 @@
 
 
 /*NUMPY_API
-  Sum
-*/
+ *Sum
+ */
 static PyObject *
 PyArray_Sum(PyArrayObject *self, int axis, int rtype, PyArrayObject *out)
 {
     PyObject *new, *ret;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
-
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
     ret = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,
                                         rtype, out);
     Py_DECREF(new);
@@ -982,15 +1123,16 @@
 }
 
 /*NUMPY_API
-  Prod
-*/
+ * Prod
+ */
 static PyObject *
 PyArray_Prod(PyArrayObject *self, int axis, int rtype, PyArrayObject *out)
 {
     PyObject *new, *ret;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
-
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
     ret = PyArray_GenericReduceFunction((PyAO *)new, n_ops.multiply, axis,
                                         rtype, out);
     Py_DECREF(new);
@@ -998,15 +1140,16 @@
 }
 
 /*NUMPY_API
-  CumSum
-*/
+ *CumSum
+ */
 static PyObject *
 PyArray_CumSum(PyArrayObject *self, int axis, int rtype, PyArrayObject *out)
 {
     PyObject *new, *ret;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
-
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
     ret = PyArray_GenericAccumulateFunction((PyAO *)new, n_ops.add, axis,
                                             rtype, out);
     Py_DECREF(new);
@@ -1014,14 +1157,16 @@
 }
 
 /*NUMPY_API
-  CumProd
-*/
+ * CumProd
+ */
 static PyObject *
 PyArray_CumProd(PyArrayObject *self, int axis, int rtype, PyArrayObject *out)
 {
     PyObject *new, *ret;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
 
     ret = PyArray_GenericAccumulateFunction((PyAO *)new,
                                             n_ops.multiply, axis,
@@ -1031,15 +1176,16 @@
 }
 
 /*NUMPY_API
-  Any
-*/
+ * Any
+ */
 static PyObject *
 PyArray_Any(PyArrayObject *self, int axis, PyArrayObject *out)
 {
     PyObject *new, *ret;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
-
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
     ret = PyArray_GenericReduceFunction((PyAO *)new,
                                         n_ops.logical_or, axis,
                                         PyArray_BOOL, out);
@@ -1048,15 +1194,16 @@
 }
 
 /*NUMPY_API
-  All
-*/
+ * All
+ */
 static PyObject *
 PyArray_All(PyArrayObject *self, int axis, PyArrayObject *out)
 {
     PyObject *new, *ret;
 
-    if ((new = _check_axis(self, &axis, 0))==NULL) return NULL;
-
+    if ((new = _check_axis(self, &axis, 0)) == NULL) {
+        return NULL;
+    }
     ret = PyArray_GenericReduceFunction((PyAO *)new,
                                         n_ops.logical_and, axis,
                                         PyArray_BOOL, out);
@@ -1066,8 +1213,8 @@
 
 
 /*NUMPY_API
-  Compress
-*/
+ * Compress
+ */
 static PyObject *
 PyArray_Compress(PyArrayObject *self, PyObject *condition, int axis,
                  PyArrayObject *out)
@@ -1076,8 +1223,9 @@
     PyObject *res, *ret;
 
     cond = (PyAO *)PyArray_FROM_O(condition);
-    if (cond == NULL) return NULL;
-
+    if (cond == NULL) {
+        return NULL;
+    }
     if (cond->nd != 1) {
         Py_DECREF(cond);
         PyErr_SetString(PyExc_ValueError,
@@ -1087,7 +1235,9 @@
 
     res = PyArray_Nonzero(cond);
     Py_DECREF(cond);
-    if (res == NULL) return res;
+    if (res == NULL) {
+        return res;
+    }
     ret = PyArray_TakeFrom(self, PyTuple_GET_ITEM(res, 0), axis,
                            out, NPY_RAISE);
     Py_DECREF(res);
@@ -1095,51 +1245,61 @@
 }
 
 /*NUMPY_API
-  Nonzero
-*/
+ * Nonzero
+ */
 static PyObject *
 PyArray_Nonzero(PyArrayObject *self)
 {
-    int n=self->nd, j;
-    intp count=0, i, size;
-    PyArrayIterObject *it=NULL;
-    PyObject *ret=NULL, *item;
+    int n = self->nd, j;
+    intp count = 0, i, size;
+    PyArrayIterObject *it = NULL;
+    PyObject *ret = NULL, *item;
     intp *dptr[MAX_DIMS];
 
     it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);
-    if (it==NULL) return NULL;
-
+    if (it == NULL) {
+        return NULL;
+    }
     size = it->size;
-    for (i=0; i<size; i++) {
-        if (self->descr->f->nonzero(it->dataptr, self)) count++;
+    for (i = 0; i < size; i++) {
+        if (self->descr->f->nonzero(it->dataptr, self)) {
+            count++;
+        }
         PyArray_ITER_NEXT(it);
     }
 
     PyArray_ITER_RESET(it);
     ret = PyTuple_New(n);
-    if (ret == NULL) goto fail;
-    for (j=0; j<n; j++) {
+    if (ret == NULL) {
+        goto fail;
+    }
+    for (j = 0; j < n; j++) {
         item = PyArray_New(self->ob_type, 1, &count,
                            PyArray_INTP, NULL, NULL, 0, 0,
                            (PyObject *)self);
-        if (item == NULL) goto fail;
+        if (item == NULL) {
+            goto fail;
+        }
         PyTuple_SET_ITEM(ret, j, item);
         dptr[j] = (intp *)PyArray_DATA(item);
     }
-    if (n==1) {
-        for (i=0; i<size; i++) {
-            if (self->descr->f->nonzero(it->dataptr, self))
+    if (n == 1) {
+        for (i = 0; i < size; i++) {
+            if (self->descr->f->nonzero(it->dataptr, self)) {
                 *(dptr[0])++ = i;
+            }
             PyArray_ITER_NEXT(it);
         }
     }
     else {
         /* reset contiguous so that coordinates gets updated */
         it->contiguous = 0;
-        for (i=0; i<size; i++) {
-            if (self->descr->f->nonzero(it->dataptr, self))
-                for (j=0; j<n; j++)
+        for (i = 0; i < size; i++) {
+            if (self->descr->f->nonzero(it->dataptr, self)) {
+                for (j = 0; j < n; j++) {
                     *(dptr[j])++ = it->coordinates[j];
+                }
+            }
             PyArray_ITER_NEXT(it);
         }
     }
@@ -1158,10 +1318,12 @@
 _GenericBinaryOutFunction(PyArrayObject *m1, PyObject *m2, PyArrayObject *out,
 			  PyObject *op)
 {
-    if (out == NULL)
+    if (out == NULL) {
 	return PyObject_CallFunction(op, "OO", m1, m2);
-    else
+    }
+    else {
 	return PyObject_CallFunction(op, "OOO", m1, m2, out);
+    }
 }
 
 static PyObject *
@@ -1171,7 +1333,9 @@
 
     if (max != NULL) {
 	res1 = _GenericBinaryOutFunction(self, max, out, n_ops.minimum);
-	if (res1 == NULL) return NULL;
+	if (res1 == NULL) {
+            return NULL;
+        }
     }
     else {
 	res1 = (PyObject *)self;
@@ -1181,7 +1345,10 @@
     if (min != NULL) {
 	res2 = _GenericBinaryOutFunction((PyArrayObject *)res1,
 					 min, out, n_ops.maximum);
-	if (res2 == NULL) {Py_XDECREF(res1); return NULL;}
+	if (res2 == NULL) {
+            Py_XDECREF(res1);
+            return NULL;
+        }
     }
     else {
 	res2 = res1;
@@ -1192,16 +1359,16 @@
 }
 
 /*NUMPY_API
-  Clip
-*/
+ * Clip
+ */
 static PyObject *
 PyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max, PyArrayObject *out)
 {
     PyArray_FastClipFunc *func;
-    int outgood=0, ingood=0;
-    PyArrayObject *maxa=NULL;
-    PyArrayObject *mina=NULL;
-    PyArrayObject *newout=NULL, *newin=NULL;
+    int outgood = 0, ingood = 0;
+    PyArrayObject *maxa = NULL;
+    PyArrayObject *mina = NULL;
+    PyArrayObject *newout = NULL, *newin = NULL;
     PyArray_Descr *indescr, *newdescr;
     char *max_data, *min_data;
     PyObject *zero;
@@ -1214,31 +1381,37 @@
 
     func = self->descr->f->fastclip;
     if (func == NULL || (min != NULL && !PyArray_CheckAnyScalar(min)) ||
-        (max != NULL && !PyArray_CheckAnyScalar(max)))
+        (max != NULL && !PyArray_CheckAnyScalar(max))) {
         return _slow_array_clip(self, min, max, out);
-
+    }
     /* Use the fast scalar clip function */
 
     /* First we need to figure out the correct type */
     indescr = NULL;
     if (min != NULL) {
 	indescr = PyArray_DescrFromObject(min, NULL);
-	if (indescr == NULL) return NULL;
+	if (indescr == NULL) {
+            return NULL;
+        }
     }
     if (max != NULL) {
 	newdescr = PyArray_DescrFromObject(max, indescr);
 	Py_XDECREF(indescr);
-	if (newdescr == NULL) return NULL;
+	if (newdescr == NULL) {
+            return NULL;
+        }
     }
     else {
-	newdescr = indescr; /* Steal the reference */
+        /* Steal the reference */
+	newdescr = indescr;
     }
 
 
-    /* Use the scalar descriptor only if it is of a bigger
-       KIND than the input array (and then find the
-       type that matches both).
-    */
+    /*
+     * Use the scalar descriptor only if it is of a bigger
+     * KIND than the input array (and then find the
+     * type that matches both).
+     */
     if (PyArray_ScalarKind(newdescr->type_num, NULL) >
         PyArray_ScalarKind(self->descr->type_num, NULL)) {
         indescr = _array_small_type(newdescr, self->descr);
@@ -1254,7 +1427,9 @@
         PyArray_Descr *descr2;
         descr2 = PyArray_DescrNewByteorder(indescr, '=');
         Py_DECREF(indescr);
-        if (descr2 == NULL) goto fail;
+        if (descr2 == NULL) {
+            goto fail;
+        }
         indescr = descr2;
     }
 
@@ -1262,28 +1437,32 @@
     if (max != NULL) {
 	maxa = (NPY_AO *)PyArray_FromAny(max, indescr, 0, 0,
 					 NPY_DEFAULT, NULL);
-	if (maxa == NULL) return NULL;
+	if (maxa == NULL) {
+            return NULL;
+        }
     }
     else {
 	/* Side-effect of PyArray_FromAny */
 	Py_DECREF(indescr);
     }
 
-
-    /* If we are unsigned, then make sure min is not <0 */
-    /* This is to match the behavior of
-       _slow_array_clip
-
-       We allow min and max to go beyond the limits
-       for other data-types in which case they
-       are interpreted as their modular counterparts.
+    /*
+     * If we are unsigned, then make sure min is not < 0
+     * This is to match the behavior of _slow_array_clip
+     *
+     * We allow min and max to go beyond the limits
+     * for other data-types in which case they
+     * are interpreted as their modular counterparts.
     */
     if (min != NULL) {
 	if (PyArray_ISUNSIGNED(self)) {
 	    int cmp;
 	    zero = PyInt_FromLong(0);
 	    cmp = PyObject_RichCompareBool(min, zero, Py_LT);
-	    if (cmp == -1) { Py_DECREF(zero); goto fail;}
+	    if (cmp == -1) {
+                Py_DECREF(zero);
+                goto fail;
+            }
 	    if (cmp == 1) {
 		min = zero;
 	    }
@@ -1301,46 +1480,61 @@
 	mina = (NPY_AO *)PyArray_FromAny(min, indescr, 0, 0,
 					 NPY_DEFAULT, NULL);
 	Py_DECREF(min);
-	if (mina == NULL) goto fail;
+	if (mina == NULL) {
+            goto fail;
+        }
     }
 
 
-    /* Check to see if input is single-segment, aligned,
-       and in native byteorder */
+    /*
+     * Check to see if input is single-segment, aligned,
+     * and in native byteorder
+     */
     if (PyArray_ISONESEGMENT(self) && PyArray_CHKFLAGS(self, ALIGNED) &&
-        PyArray_ISNOTSWAPPED(self) && (self->descr == indescr))
+        PyArray_ISNOTSWAPPED(self) && (self->descr == indescr)) {
         ingood = 1;
-
+    }
     if (!ingood) {
         int flags;
-        if (PyArray_ISFORTRAN(self)) flags = NPY_FARRAY;
-        else flags = NPY_CARRAY;
+
+        if (PyArray_ISFORTRAN(self)) {
+            flags = NPY_FARRAY;
+        }
+        else {
+            flags = NPY_CARRAY;
+        }
         Py_INCREF(indescr);
         newin = (NPY_AO *)PyArray_FromArray(self, indescr, flags);
-        if (newin == NULL) goto fail;
+        if (newin == NULL) {
+            goto fail;
+        }
     }
     else {
         newin = self;
         Py_INCREF(newin);
     }
 
-    /* At this point, newin is a single-segment, aligned, and correct
-       byte-order array of the correct type
+    /*
+     * At this point, newin is a single-segment, aligned, and correct
+     * byte-order array of the correct type
+     *
+     * if ingood == 0, then it is a copy, otherwise,
+     * it is the original input.
+     */
 
-       if ingood == 0, then it is a copy, otherwise,
-       it is the original input.
-    */
-
-    /* If we have already made a copy of the data, then use
-       that as the output array
-    */
+    /*
+     * If we have already made a copy of the data, then use
+     * that as the output array
+     */
     if (out == NULL && !ingood) {
         out = newin;
     }
 
-    /* Now, we know newin is a usable array for fastclip,
-       we need to make sure the output array is available
-       and usable */
+    /*
+     * Now, we know newin is a usable array for fastclip,
+     * we need to make sure the output array is available
+     * and usable
+     */
     if (out == NULL) {
         Py_INCREF(indescr);
         out = (NPY_AO*)PyArray_NewFromDescr(self->ob_type,
@@ -1349,7 +1543,9 @@
                                             NULL, NULL,
                                             PyArray_ISFORTRAN(self),
                                             (PyObject *)self);
-        if (out == NULL) goto fail;
+        if (out == NULL) {
+            goto fail;
+        }
         outgood = 1;
     }
     else Py_INCREF(out);
@@ -1363,8 +1559,10 @@
         outgood = 1;
     }
 
-    /* Do we still not have a suitable output array? */
-    /* Create one, now */
+    /*
+     * Do we still not have a suitable output array?
+     * Create one, now
+     */
     if (!outgood) {
         int oflags;
         if (PyArray_ISFORTRAN(out))
@@ -1374,7 +1572,9 @@
         oflags |= NPY_UPDATEIFCOPY | NPY_FORCECAST;
         Py_INCREF(indescr);
         newout = (NPY_AO*)PyArray_FromArray(out, indescr, oflags);
-        if (newout == NULL) goto fail;
+        if (newout == NULL) {
+            goto fail;
+        }
     }
     else {
         newout = out;
@@ -1387,22 +1587,20 @@
                         "same shape as the input.");
         goto fail;
     }
-
     if (newout->data != newin->data) {
         memcpy(newout->data, newin->data, PyArray_NBYTES(newin));
     }
 
     /* Now we can call the fast-clip function */
-
     min_data = max_data = NULL;
-    if (mina != NULL)
+    if (mina != NULL) {
 	min_data = mina->data;
-    if (maxa != NULL)
+    }
+    if (maxa != NULL) {
 	max_data = maxa->data;
+    }
+    func(newin->data, PyArray_SIZE(newin), min_data, max_data, newout->data);
 
-    func(newin->data, PyArray_SIZE(newin), min_data, max_data,
-         newout->data);
-
     /* Clean up temporary variables */
     Py_XDECREF(mina);
     Py_XDECREF(maxa);
@@ -1421,8 +1619,8 @@
 
 
 /*NUMPY_API
-  Conjugate
-*/
+ * Conjugate
+ */
 static PyObject *
 PyArray_Conjugate(PyArrayObject *self, PyArrayObject *out)
 {
@@ -1440,35 +1638,40 @@
     else {
         PyArrayObject *ret;
         if (out) {
-            if (PyArray_CopyAnyInto(out, self)< 0)
+            if (PyArray_CopyAnyInto(out, self) < 0) {
                 return NULL;
+            }
             ret = out;
         }
-        else ret = self;
+        else {
+            ret = self;
+        }
         Py_INCREF(ret);
         return (PyObject *)ret;
     }
 }
 
 /*NUMPY_API
-  Trace
-*/
+ * Trace
+ */
 static PyObject *
 PyArray_Trace(PyArrayObject *self, int offset, int axis1, int axis2,
               int rtype, PyArrayObject *out)
 {
-    PyObject *diag=NULL, *ret=NULL;
+    PyObject *diag = NULL, *ret = NULL;
 
     diag = PyArray_Diagonal(self, offset, axis1, axis2);
-    if (diag == NULL) return NULL;
+    if (diag == NULL) {
+        return NULL;
+    }
     ret = PyArray_GenericReduceFunction((PyAO *)diag, n_ops.add, -1, rtype, out);
     Py_DECREF(diag);
     return ret;
 }
 
 /*NUMPY_API
-  Diagonal
-*/
+ * Diagonal
+ */
 static PyObject *
 PyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)
 {
@@ -1484,9 +1687,13 @@
                         "array.ndim must be >= 2");
         return NULL;
     }
-    if (axis1 < 0) axis1 += n;
-    if (axis2 < 0) axis2 += n;
-    if ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||  \
+    if (axis1 < 0) {
+        axis1 += n;
+    }
+    if (axis2 < 0) {
+        axis2 += n;
+    }
+    if ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||
         (axis2 < 0) || (axis2 >= n)) {
         PyErr_Format(PyExc_ValueError, "axis1(=%d) and axis2(=%d) "\
                      "must be different and within range (nd=%d)",
@@ -1499,21 +1706,26 @@
     newaxes.ptr[n-2] = axis1;
     newaxes.ptr[n-1] = axis2;
     pos = 0;
-    for (i=0; i<n; i++) {
-        if ((i==axis1) || (i==axis2)) continue;
+    for (i = 0; i < n; i++) {
+        if ((i==axis1) || (i==axis2)) {
+            continue;
+        }
         newaxes.ptr[pos++] = i;
     }
     new = PyArray_Transpose(self, &newaxes);
-    if (new == NULL) return NULL;
+    if (new == NULL) {
+        return NULL;
+    }
     self = (PyAO *)new;
 
     if (n == 2) {
-        PyObject *a=NULL, *indices=NULL, *ret=NULL;
+        PyObject *a = NULL, *indices= NULL, *ret = NULL;
         intp n1, n2, start, stop, step, count;
         intp *dptr;
+
         n1 = self->dimensions[0];
         n2 = self->dimensions[1];
-        step = n2+1;
+        step = n2 + 1;
         if (offset < 0) {
             start = -n2 * offset;
             stop = MIN(n2, n1+offset)*(n2+1) - n2*offset;
@@ -1525,17 +1737,22 @@
 
         /* count = ceil((stop-start)/step) */
         count = ((stop-start) / step) + (((stop-start) % step) != 0);
-
         indices = PyArray_New(&PyArray_Type, 1, &count,
                               PyArray_INTP, NULL, NULL, 0, 0, NULL);
         if (indices == NULL) {
-            Py_DECREF(self); return NULL;
+            Py_DECREF(self);
+            return NULL;
         }
         dptr = (intp *)PyArray_DATA(indices);
-        for (n1=start; n1<stop; n1+=step) *dptr++ = n1;
+        for (n1 = start; n1 < stop; n1 += step) {
+            *dptr++ = n1;
+        }
         a = PyArray_IterNew((PyObject *)self);
         Py_DECREF(self);
-        if (a == NULL) {Py_DECREF(indices); return NULL;}
+        if (a == NULL) {
+            Py_DECREF(indices);
+            return NULL;
+        }
         ret = PyObject_GetItem(a, indices);
         Py_DECREF(a);
         Py_DECREF(indices);
@@ -1544,22 +1761,24 @@
 
     else {
         /*
-          my_diagonal = []
-          for i in range (s [0]) :
-          my_diagonal.append (diagonal (a [i], offset))
-          return array (my_diagonal)
-        */
-        PyObject *mydiagonal=NULL, *new=NULL, *ret=NULL, *sel=NULL;
+         * my_diagonal = []
+         * for i in range (s [0]) :
+         * my_diagonal.append (diagonal (a [i], offset))
+         * return array (my_diagonal)
+         */
+        PyObject *mydiagonal = NULL, *new = NULL, *ret = NULL, *sel = NULL;
         intp i, n1;
         int res;
         PyArray_Descr *typecode;
 
         typecode = self->descr;
-
         mydiagonal = PyList_New(0);
-        if (mydiagonal == NULL) {Py_DECREF(self); return NULL;}
+        if (mydiagonal == NULL) {
+            Py_DECREF(self);
+            return NULL;
+        }
         n1 = self->dimensions[0];
-        for (i=0; i<n1; i++) {
+        for (i = 0; i < n1; i++) {
             new = PyInt_FromLong((long) i);
             sel = PyArray_EnsureAnyArray(PyObject_GetItem((PyObject *)self, new));
             Py_DECREF(new);
@@ -1591,19 +1810,20 @@
     }
 }
 
-/* simulates a C-style 1-3 dimensional array which can be accesed using
-   ptr[i]  or ptr[i][j] or ptr[i][j][k] -- requires pointer allocation
-   for 2-d and 3-d.
+/*
+ * simulates a C-style 1-3 dimensional array which can be accesed using
+ * ptr[i]  or ptr[i][j] or ptr[i][j][k] -- requires pointer allocation
+ * for 2-d and 3-d.
+ *
+ * For 2-d and up, ptr is NOT equivalent to a statically defined
+ * 2-d or 3-d array.  In particular, it cannot be passed into a
+ * function that requires a true pointer to a fixed-size array.
+ */
 
-   For 2-d and up, ptr is NOT equivalent to a statically defined
-   2-d or 3-d array.  In particular, it cannot be passed into a
-   function that requires a true pointer to a fixed-size array.
-*/
-
-/* steals a reference to typedescr -- can be NULL*/
 /*NUMPY_API
-  Simulat a C-array
-*/
+ * Simulate a C-array
+ * steals a reference to typedescr -- can be NULL
+ */
 static int
 PyArray_AsCArray(PyObject **op, void *ptr, intp *dims, int nd,
                  PyArray_Descr* typedescr)
@@ -1620,8 +1840,9 @@
         return -1;
     }
     if ((ap = (PyArrayObject*)PyArray_FromAny(*op, typedescr, nd, nd,
-                                              CARRAY, NULL)) == NULL)
+                                              CARRAY, NULL)) == NULL) {
         return -1;
+    }
     switch(nd) {
     case 1:
         *((char **)ptr) = ap->data;
@@ -1629,8 +1850,10 @@
     case 2:
         n = ap->dimensions[0];
         ptr2 = (char **)_pya_malloc(n * sizeof(char *));
-        if (!ptr2) goto fail;
-        for (i=0; i<n; i++) {
+        if (!ptr2) {
+            goto fail;
+        }
+        for (i = 0; i < n; i++) {
             ptr2[i] = ap->data + i*ap->strides[0];
         }
         *((char ***)ptr) = ptr2;
@@ -1639,12 +1862,13 @@
         n = ap->dimensions[0];
         m = ap->dimensions[1];
         ptr3 = (char ***)_pya_malloc(n*(m+1) * sizeof(char *));
-        if (!ptr3) goto fail;
-        for (i=0; i<n; i++) {
+        if (!ptr3) {
+            goto fail;
+        }
+        for (i = 0; i < n; i++) {
             ptr3[i] = ptr3[n + (m-1)*i];
-            for (j=0; j<m; j++) {
-                ptr3[i][j] = ap->data + i*ap->strides[0] + \
-                    j*ap->strides[1];
+            for (j = 0; j < m; j++) {
+                ptr3[i][j] = ap->data + i*ap->strides[0] + j*ap->strides[1];
             }
         }
         *((char ****)ptr) = ptr3;
@@ -1661,8 +1885,8 @@
 /* Deprecated --- Use PyArray_AsCArray instead */
 
 /*NUMPY_API
-  Convert to a 1D C-array
-*/
+ * Convert to a 1D C-array
+ */
 static int
 PyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode)
 {
@@ -1674,15 +1898,16 @@
         return -1;
     }
     descr = PyArray_DescrFromType(typecode);
-    if (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1)
+    if (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1) {
         return -1;
+    }
     *d1 = (int) newd1;
     return 0;
 }
 
 /*NUMPY_API
-  Convert to a 2D C-array
-*/
+ * Convert to a 2D C-array
+ */
 static int
 PyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode)
 {
@@ -1694,9 +1919,9 @@
         return -1;
     }
     descr = PyArray_DescrFromType(typecode);
-    if (PyArray_AsCArray(op, (void *)ptr, newdims, 2, descr) == -1)
+    if (PyArray_AsCArray(op, (void *)ptr, newdims, 2, descr) == -1) {
         return -1;
-
+    }
     *d1 = (int ) newdims[0];
     *d2 = (int ) newdims[1];
     return 0;
@@ -1705,15 +1930,16 @@
 /* End Deprecated */
 
 /*NUMPY_API
-  Free pointers created if As2D is called
-*/
+ * Free pointers created if As2D is called
+ */
 static int
 PyArray_Free(PyObject *op, void *ptr)
 {
     PyArrayObject *ap = (PyArrayObject *)op;
 
-    if ((ap->nd < 1) || (ap->nd > 3))
+    if ((ap->nd < 1) || (ap->nd > 3)) {
         return -1;
+    }
     if (ap->nd >= 2) {
         _pya_free(ptr);
     }
@@ -1725,25 +1951,33 @@
 static PyObject *
 _swap_and_concat(PyObject *op, int axis, int n)
 {
-    PyObject *newtup=NULL;
+    PyObject *newtup = NULL;
     PyObject *otmp, *arr;
     int i;
 
     newtup = PyTuple_New(n);
-    if (newtup==NULL) return NULL;
-    for (i=0; i<n; i++) {
+    if (newtup == NULL) {
+        return NULL;
+    }
+    for (i = 0; i < n; i++) {
         otmp = PySequence_GetItem(op, i);
         arr = PyArray_FROM_O(otmp);
         Py_DECREF(otmp);
-        if (arr==NULL) goto fail;
+        if (arr == NULL) {
+            goto fail;
+        }
         otmp = PyArray_SwapAxes((PyArrayObject *)arr, axis, 0);
         Py_DECREF(arr);
-        if (otmp == NULL) goto fail;
+        if (otmp == NULL) {
+            goto fail;
+        }
         PyTuple_SET_ITEM(newtup, i, otmp);
     }
     otmp = PyArray_Concatenate(newtup, 0);
     Py_DECREF(newtup);
-    if (otmp == NULL) return NULL;
+    if (otmp == NULL) {
+        return NULL;
+    }
     arr = PyArray_SwapAxes((PyArrayObject *)otmp, axis, 0);
     Py_DECREF(otmp);
     return arr;
@@ -1753,21 +1987,21 @@
     return NULL;
 }
 
-/*op is a python object supporting the sequence interface.
-  Its elements will be concatenated together to form a single
-  multidimensional array.*/
-/* If axis is MAX_DIMS or bigger, then each sequence object will
-   be flattened before concatenation
-*/
 /*NUMPY_API
-  Concatenate an arbitrary Python sequence into an array.
+ * Concatenate
+ *
+ * Concatenate an arbitrary Python sequence into an array.
+ * op is a python object supporting the sequence interface.
+ * Its elements will be concatenated together to form a single
+ * multidimensional array. If axis is MAX_DIMS or bigger, then
+ * each sequence object will be flattened before concatenation
 */
 static PyObject *
 PyArray_Concatenate(PyObject *op, int axis)
 {
     PyArrayObject *ret, **mps;
     PyObject *otmp;
-    int i, n, tmp, nd=0, new_dim;
+    int i, n, tmp, nd = 0, new_dim;
     char *data;
     PyTypeObject *subtype;
     double prior1, prior2;
@@ -1784,19 +2018,22 @@
         return NULL;
     }
 
-    if ((axis < 0) || ((0 < axis) && (axis < MAX_DIMS)))
+    if ((axis < 0) || ((0 < axis) && (axis < MAX_DIMS))) {
         return _swap_and_concat(op, axis, n);
-
+    }
     mps = PyArray_ConvertToCommonType(op, &n);
-    if (mps == NULL) return NULL;
+    if (mps == NULL) {
+        return NULL;
+    }
 
-    /* Make sure these arrays are legal to concatenate. */
-    /* Must have same dimensions except d0 */
-
+    /*
+     * Make sure these arrays are legal to concatenate.
+     * Must have same dimensions except d0
+     */
     prior1 = PyArray_PRIORITY;
     subtype = &PyArray_Type;
     ret = NULL;
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         if (axis >= MAX_DIMS) {
             otmp = PyArray_Ravel(mps[i],0);
             Py_DECREF(mps[i]);
@@ -1812,9 +2049,13 @@
     }
 
     new_dim = 0;
-    for(i=0; i<n; i++) {
-        if (mps[i] == NULL) goto fail;
-        if (i == 0) nd = mps[i]->nd;
+    for (i = 0; i < n; i++) {
+        if (mps[i] == NULL) {
+            goto fail;
+        }
+        if (i == 0) {
+            nd = mps[i]->nd;
+        }
         else {
             if (nd != mps[i]->nd) {
                 PyErr_SetString(PyExc_ValueError,
@@ -1838,7 +2079,6 @@
         }
         new_dim += mps[i]->dimensions[0];
     }
-
     tmp = mps[0]->dimensions[0];
     mps[0]->dimensions[0] = new_dim;
     Py_INCREF(mps[0]->descr);
@@ -1849,30 +2089,35 @@
                                                 (PyObject *)ret);
     mps[0]->dimensions[0] = tmp;
 
-    if (ret == NULL) goto fail;
-
+    if (ret == NULL) {
+        goto fail;
+    }
     data = ret->data;
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         numbytes = PyArray_NBYTES(mps[i]);
         memcpy(data, mps[i]->data, numbytes);
         data += numbytes;
     }
 
     PyArray_INCREF(ret);
-    for(i=0; i<n; i++) Py_XDECREF(mps[i]);
+    for (i = 0; i < n; i++) {
+        Py_XDECREF(mps[i]);
+    }
     PyDataMem_FREE(mps);
     return (PyObject *)ret;
 
  fail:
     Py_XDECREF(ret);
-    for(i=0; i<n; i++) Py_XDECREF(mps[i]);
+    for (i = 0; i < n; i++) {
+        Py_XDECREF(mps[i]);
+    }
     PyDataMem_FREE(mps);
     return NULL;
 }
 
 /*NUMPY_API
-  SwapAxes
-*/
+ * SwapAxes
+ */
 static PyObject *
 PyArray_SwapAxes(PyArrayObject *ap, int a1, int a2)
 {
@@ -1892,8 +2137,12 @@
         return (PyObject *)ap;
     }
 
-    if (a1 < 0) a1 += n;
-    if (a2 < 0) a2 += n;
+    if (a1 < 0) {
+        a1 += n;
+    }
+    if (a2 < 0) {
+        a2 += n;
+    }
     if ((a1 < 0) || (a1 >= n)) {
         PyErr_SetString(PyExc_ValueError,
                         "bad axis1 argument to swapaxes");
@@ -1907,10 +2156,16 @@
     new_axes.ptr = dims;
     new_axes.len = n;
 
-    for (i=0; i<n; i++) {
-        if (i == a1) val = a2;
-        else if (i == a2) val = a1;
-        else val = i;
+    for (i = 0; i < n; i++) {
+        if (i == a1) {
+            val = a2;
+        }
+        else if (i == a2) {
+            val = a1;
+        }
+        else {
+            val = i;
+        }
         new_axes.ptr[i] = val;
     }
     ret = PyArray_Transpose(ap, &new_axes);
@@ -1918,8 +2173,8 @@
 }
 
 /*NUMPY_API
-  Return Transpose.
-*/
+ * Return Transpose.
+ */
 static PyObject *
 PyArray_Transpose(PyArrayObject *ap, PyArray_Dims *permute)
 {
@@ -1930,10 +2185,11 @@
 
     if (permute == NULL) {
         n = ap->nd;
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             permutation[i] = n-1-i;
         }
-    } else {
+    }
+    else {
         n = permute->len;
         axes = permute->ptr;
         if (n != ap->nd) {
@@ -1941,12 +2197,14 @@
                             "axes don't match array");
             return NULL;
         }
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             reverse_permutation[i] = -1;
         }
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             axis = axes[i];
-            if (axis < 0) axis = ap->nd+axis;
+            if (axis < 0) {
+                axis = ap->nd + axis;
+            }
             if (axis < 0 || axis >= ap->nd) {
                 PyErr_SetString(PyExc_ValueError,
                                 "invalid axis for this array");
@@ -1960,12 +2218,14 @@
             reverse_permutation[axis] = i;
             permutation[i] = axis;
         }
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
         }
     }
 
-    /* this allocates memory for dimensions and strides (but fills them
-       incorrectly), sets up descr, and points data at ap->data. */
+    /*
+     * this allocates memory for dimensions and strides (but fills them
+     * incorrectly), sets up descr, and points data at ap->data.
+     */
     Py_INCREF(ap->descr);
     ret = (PyArrayObject *)\
         PyArray_NewFromDescr(ap->ob_type,
@@ -1973,25 +2233,25 @@
                              n, ap->dimensions,
                              NULL, ap->data, ap->flags,
                              (PyObject *)ap);
-    if (ret == NULL) return NULL;
-
+    if (ret == NULL) {
+        return NULL;
+    }
     /* point at true owner of memory: */
     ret->base = (PyObject *)ap;
     Py_INCREF(ap);
 
     /* fix the dimensions and strides of the return-array */
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         ret->dimensions[i] = ap->dimensions[permutation[i]];
         ret->strides[i] = ap->strides[permutation[i]];
     }
     PyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);
-
     return (PyObject *)ret;
 }
 
 /*NUMPY_API
-  Repeat the array.
-*/
+ * Repeat the array.
+ */
 static PyObject *
 PyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)
 {
@@ -1999,13 +2259,15 @@
     intp n, n_outer, i, j, k, chunk, total;
     intp tmp;
     int nd;
-    PyArrayObject *repeats=NULL;
-    PyObject *ap=NULL;
-    PyArrayObject *ret=NULL;
+    PyArrayObject *repeats = NULL;
+    PyObject *ap = NULL;
+    PyArrayObject *ret = NULL;
     char *new_data, *old_data;
 
     repeats = (PyAO *)PyArray_ContiguousFromAny(op, PyArray_INTP, 0, 1);
-    if (repeats == NULL) return NULL;
+    if (repeats == NULL) {
+        return NULL;
+    }
     nd = repeats->nd;
     counts = (intp *)repeats->data;
 
@@ -2015,25 +2277,26 @@
     }
 
     aop = (PyAO *)ap;
-
-    if (nd == 1)
+    if (nd == 1) {
         n = repeats->dimensions[0];
-    else /* nd == 0 */
+    }
+    else {
+        /* nd == 0 */
         n = aop->dimensions[axis];
-
+    }
     if (aop->dimensions[axis] != n) {
         PyErr_SetString(PyExc_ValueError,
                         "a.shape[axis] != len(repeats)");
         goto fail;
     }
 
-
-    if (nd == 0)
+    if (nd == 0) {
         total = counts[0]*n;
+    }
     else {
 
         total = 0;
-        for(j=0; j<n; j++) {
+        for (j = 0; j < n; j++) {
             if (counts[j] < 0) {
                 PyErr_SetString(PyExc_ValueError, "count < 0");
                 goto fail;
@@ -2053,24 +2316,25 @@
                                                 NULL, NULL, 0,
                                                 (PyObject *)aop);
     aop->dimensions[axis] = n;
-
-    if (ret == NULL) goto fail;
-
+    if (ret == NULL) {
+        goto fail;
+    }
     new_data = ret->data;
     old_data = aop->data;
 
     chunk = aop->descr->elsize;
-    for(i=axis+1; i<aop->nd; i++) {
+    for(i = axis + 1; i < aop->nd; i++) {
         chunk *= aop->dimensions[i];
     }
 
     n_outer = 1;
-    for(i=0; i<axis; i++) n_outer *= aop->dimensions[i];
-
-    for(i=0; i<n_outer; i++) {
-        for(j=0; j<n; j++) {
-            tmp = (nd ? counts[j] : counts[0]);
-            for(k=0; k<tmp; k++) {
+    for (i = 0; i < axis; i++) {
+        n_outer *= aop->dimensions[i];
+    }
+    for (i = 0; i < n_outer; i++) {
+        for (j = 0; j < n; j++) {
+            tmp = nd ? counts[j] : counts[0];
+            for (k = 0; k < tmp; k++) {
                 memcpy(new_data, old_data, chunk);
                 new_data += chunk;
             }
@@ -2112,7 +2376,9 @@
 }
 
 
-/*NUMPY_API*/
+/*NUMPY_API
+ * ScalarKind
+ */
 static NPY_SCALARKIND
 PyArray_ScalarKind(int typenum, PyArrayObject **arr)
 {
@@ -2141,10 +2407,12 @@
         NPY_SCALARKIND retval;
         PyArray_Descr* descr = PyArray_DescrFromType(typenum);
 
-        if (descr->f->scalarkind)
+        if (descr->f->scalarkind) {
             retval = descr->f->scalarkind((arr ? *arr : NULL));
-        else
+        }
+        else {
             retval = PyArray_NOSCALAR;
+        }
         Py_DECREF(descr);
         return retval;
     }
@@ -2162,15 +2430,15 @@
     if (scalar == PyArray_NOSCALAR) {
         return PyArray_CanCastSafely(thistype, neededtype);
     }
-
     from = PyArray_DescrFromType(thistype);
-    if (from->f->cancastscalarkindto &&
-        (castlist = from->f->cancastscalarkindto[scalar])) {
-        while (*castlist != PyArray_NOTYPE)
+    if (from->f->cancastscalarkindto
+        && (castlist = from->f->cancastscalarkindto[scalar])) {
+        while (*castlist != PyArray_NOTYPE) {
             if (*castlist++ == neededtype) {
                 Py_DECREF(from);
                 return 1;
             }
+        }
     }
     Py_DECREF(from);
 
@@ -2186,14 +2454,15 @@
         case PyArray_INTPOS_SCALAR:
             return (neededtype >= PyArray_BYTE);
         case PyArray_INTNEG_SCALAR:
-            return (neededtype >= PyArray_BYTE) &&  \
-                !(PyTypeNum_ISUNSIGNED(neededtype));
+            return (neededtype >= PyArray_BYTE)
+                && !(PyTypeNum_ISUNSIGNED(neededtype));
         case PyArray_FLOAT_SCALAR:
             return (neededtype >= PyArray_FLOAT);
         case PyArray_COMPLEX_SCALAR:
             return (neededtype >= PyArray_CFLOAT);
         default:
-            return 1; /* should never get here... */
+            /* should never get here... */
+            return 1;
         }
     }
 }
@@ -2204,19 +2473,21 @@
 static PyArrayObject **
 PyArray_ConvertToCommonType(PyObject *op, int *retn)
 {
-    int i, n, allscalars=0;
-    PyArrayObject **mps=NULL;
+    int i, n, allscalars = 0;
+    PyArrayObject **mps = NULL;
     PyObject *otmp;
-    PyArray_Descr *intype=NULL, *stype=NULL;
-    PyArray_Descr *newtype=NULL;
-    NPY_SCALARKIND scalarkind=NPY_NOSCALAR, intypekind=NPY_NOSCALAR;
+    PyArray_Descr *intype = NULL, *stype = NULL;
+    PyArray_Descr *newtype = NULL;
+    NPY_SCALARKIND scalarkind = NPY_NOSCALAR, intypekind = NPY_NOSCALAR;
 
     *retn = n = PySequence_Length(op);
     if (n == 0) {
 	PyErr_SetString(PyExc_ValueError, "0-length sequence.");
     }
-    if (PyErr_Occurred()) {*retn = 0; return NULL;}
-
+    if (PyErr_Occurred()) {
+        *retn = 0;
+        return NULL;
+    }
     mps = (PyArrayObject **)PyDataMem_NEW(n*sizeof(PyArrayObject *));
     if (mps == NULL) {
         *retn = 0;
@@ -2224,12 +2495,11 @@
     }
 
     if (PyArray_Check(op)) {
-        for (i=0; i<n; i++) {
-            mps[i] = (PyArrayObject *)\
-                array_big_item((PyArrayObject *)op, i);
+        for (i = 0; i < n; i++) {
+            mps[i] = (PyArrayObject *) array_big_item((PyArrayObject *)op, i);
         }
         if (!PyArray_ISCARRAY(op)) {
-            for (i=0; i<n; i++) {
+            for (i = 0; i < n; i++) {
                 PyObject *obj;
                 obj = PyArray_NewCopy(mps[i], NPY_CORDER);
                 Py_DECREF(mps[i]);
@@ -2239,43 +2509,41 @@
         return mps;
     }
 
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         otmp = PySequence_GetItem(op, i);
         if (!PyArray_CheckAnyScalar(otmp)) {
             newtype = PyArray_DescrFromObject(otmp, intype);
             Py_XDECREF(intype);
             intype = newtype;
             mps[i] = NULL;
-            intypekind = PyArray_ScalarKind(intype->type_num,
-                                            NULL);
+            intypekind = PyArray_ScalarKind(intype->type_num, NULL);
         }
         else {
             newtype = PyArray_DescrFromObject(otmp, stype);
             Py_XDECREF(stype);
             stype = newtype;
-            scalarkind = PyArray_ScalarKind(newtype->type_num,
-                                            NULL);
+            scalarkind = PyArray_ScalarKind(newtype->type_num, NULL);
             mps[i] = (PyArrayObject *)Py_None;
             Py_INCREF(Py_None);
         }
         Py_XDECREF(otmp);
     }
-    if (intype==NULL) { /* all scalars */
+    if (intype==NULL) {
+        /* all scalars */
         allscalars = 1;
         intype = stype;
         Py_INCREF(intype);
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             Py_XDECREF(mps[i]);
             mps[i] = NULL;
         }
     }
-    else if ((stype != NULL) && (intypekind != scalarkind)) {       \
-        /* we need to upconvert to type that
-           handles both intype and stype
-
-           also don't forcecast the scalars.
-        */
-
+    else if ((stype != NULL) && (intypekind != scalarkind)) {
+        /*
+         * we need to upconvert to type that
+         * handles both intype and stype
+         * also don't forcecast the scalars.
+         */
         if (!PyArray_CanCoerceScalar(stype->type_num,
                                      intype->type_num,
                                      scalarkind)) {
@@ -2283,7 +2551,7 @@
             Py_XDECREF(intype);
             intype = newtype;
         }
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             Py_XDECREF(mps[i]);
             mps[i] = NULL;
         }
@@ -2291,10 +2559,12 @@
 
 
     /* Make sure all arrays are actual array objects. */
-    for(i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         int flags = CARRAY;
-        if ((otmp = PySequence_GetItem(op, i)) == NULL)
+
+        if ((otmp = PySequence_GetItem(op, i)) == NULL) {
             goto fail;
+        }
         if (!allscalars && ((PyObject *)(mps[i]) == Py_None)) {
             /* forcecast scalars */
             flags |= FORCECAST;
@@ -2304,7 +2574,9 @@
         mps[i] = (PyArrayObject*)
             PyArray_FromAny(otmp, intype, 0, 0, flags, NULL);
         Py_DECREF(otmp);
-        if (mps[i] == NULL) goto fail;
+        if (mps[i] == NULL) {
+            goto fail;
+        }
     }
     Py_DECREF(intype);
     Py_XDECREF(stype);
@@ -2314,7 +2586,9 @@
     Py_XDECREF(intype);
     Py_XDECREF(stype);
     *retn = 0;
-    for (i=0; i<n; i++) Py_XDECREF(mps[i]);
+    for (i = 0; i < n; i++) {
+        Py_XDECREF(mps[i]);
+    }
     PyDataMem_FREE(mps);
     return NULL;
 }
@@ -2329,29 +2603,34 @@
     intp i;
     char *ret_data;
     PyArrayObject **mps, *ap;
-    PyArrayMultiIterObject *multi=NULL;
+    PyArrayMultiIterObject *multi = NULL;
     intp mi;
-    int copyret=0;
+    int copyret = 0;
     ap = NULL;
 
-    /* Convert all inputs to arrays of a common type */
-    /* Also makes them C-contiguous */
+    /*
+     * Convert all inputs to arrays of a common type
+     * Also makes them C-contiguous
+     */
     mps = PyArray_ConvertToCommonType(op, &n);
-    if (mps == NULL) return NULL;
-
-    for(i=0; i<n; i++) {
-        if (mps[i] == NULL) goto fail;
+    if (mps == NULL) {
+        return NULL;
     }
-
+    for (i = 0; i < n; i++) {
+        if (mps[i] == NULL) {
+            goto fail;
+        }
+    }
     ap = (PyArrayObject *)PyArray_FROM_OT((PyObject *)ip, NPY_INTP);
-
-    if (ap == NULL) goto fail;
-
+    if (ap == NULL) {
+        goto fail;
+    }
     /* Broadcast all arrays to each other, index array at the end. */ 
-    multi = (PyArrayMultiIterObject *)\
+    multi = (PyArrayMultiIterObject *)
 	PyArray_MultiIterFromObjects((PyObject **)mps, n, 1, ap);
-    if (multi == NULL) goto fail;
-
+    if (multi == NULL) {
+        goto fail;
+    }
     /* Set-up return array */
     if (!ret) {
         Py_INCREF(mps[0]->descr);
@@ -2366,29 +2645,33 @@
         PyArrayObject *obj;
         int flags = NPY_CARRAY | NPY_UPDATEIFCOPY | NPY_FORCECAST;
 
-        if ((PyArray_NDIM(ret) != multi->nd) || 
-	    !PyArray_CompareLists(PyArray_DIMS(ret), multi->dimensions, 
-				  multi->nd)) {
+        if ((PyArray_NDIM(ret) != multi->nd)
+                || !PyArray_CompareLists(
+                    PyArray_DIMS(ret), multi->dimensions, multi->nd)) {
 	    PyErr_SetString(PyExc_TypeError,
                             "invalid shape for output array.");
             ret = NULL;
             goto fail;
         }
         if (clipmode == NPY_RAISE) {
-            /* we need to make sure and get a copy
-               so the input array is not changed
-               before the error is called
-            */
+            /*
+             * we need to make sure and get a copy
+             * so the input array is not changed
+             * before the error is called
+             */
             flags |= NPY_ENSURECOPY;
         }
         Py_INCREF(mps[0]->descr);
-        obj = (PyArrayObject *)PyArray_FromArray(ret, mps[0]->descr,
-                                                 flags);
-        if (obj != ret) copyret = 1;
+        obj = (PyArrayObject *)PyArray_FromArray(ret, mps[0]->descr, flags);
+        if (obj != ret) {
+            copyret = 1;
+        }
         ret = obj;
     }
 
-    if (ret == NULL) goto fail;
+    if (ret == NULL) {
+        goto fail;
+    }
     elsize = ret->descr->elsize;
     ret_data = ret->data;
 
@@ -2398,31 +2681,41 @@
             switch(clipmode) {
             case NPY_RAISE:
                 PyErr_SetString(PyExc_ValueError,
-                                "invalid entry in choice "\
-                                "array");
+                        "invalid entry in choice "\
+                        "array");
                 goto fail;
             case NPY_WRAP:
                 if (mi < 0) {
-                    while(mi<0) mi += n;
+                    while (mi < 0) {
+                        mi += n;
+                    }
                 }
                 else {
-                    while(mi>=n) mi -= n;
+                    while (mi >= n) {
+                        mi -= n;
+                    }
                 }
                 break;
             case NPY_CLIP:
-                if (mi < 0) mi=0;
-                else if (mi>=n) mi=n-1;
+                if (mi < 0) {
+                    mi = 0;
+                }
+                else if (mi >= n) {
+                    mi = n - 1;
+                }
                 break;
             }
         }
         memmove(ret_data, PyArray_MultiIter_DATA(multi, mi), elsize);
-        ret_data += elsize; 
+        ret_data += elsize;
 	PyArray_MultiIter_NEXT(multi);
     }
 
     PyArray_INCREF(ret);
     Py_DECREF(multi);
-    for(i=0; i<n; i++) Py_XDECREF(mps[i]);
+    for (i = 0; i < n; i++) {
+        Py_XDECREF(mps[i]);
+    }
     Py_DECREF(ap);
     PyDataMem_FREE(mps);
     if (copyret) {
@@ -2436,29 +2729,28 @@
 
  fail:
     Py_XDECREF(multi);
-    for(i=0; i<n; i++) Py_XDECREF(mps[i]);
+    for (i = 0; i < n; i++) {
+        Py_XDECREF(mps[i]);
+    }
     Py_XDECREF(ap);
     PyDataMem_FREE(mps);
     PyArray_XDECREF_ERR(ret);
     return NULL;
 }
 
-/* These algorithms use special sorting.  They are not called unless the
-   underlying sort function for the type is available.
-   Note that axis is already
-   valid. The sort functions require 1-d contiguous and well-behaved data.
-   Therefore, a copy will be made of the data if needed before handing
-   it to the
-   sorting routine.
-   An iterator is constructed and adjusted to walk over all but
-   the desired sorting
-   axis.
-*/
+/*
+ * These algorithms use special sorting.  They are not called unless the
+ * underlying sort function for the type is available.  Note that axis is
+ * already valid. The sort functions require 1-d contiguous and well-behaved
+ * data.  Therefore, a copy will be made of the data if needed before handing
+ * it to the sorting routine.  An iterator is constructed and adjusted to walk
+ * over all but the desired sorting axis.
+ */
 static int
 _new_sort(PyArrayObject *op, int axis, NPY_SORTKIND which)
 {
     PyArrayIterObject *it;
-    int needcopy=0, swap;
+    int needcopy = 0, swap;
     intp N, size;
     int elsize;
     intp astride;
@@ -2478,12 +2770,10 @@
     elsize = op->descr->elsize;
     astride = op->strides[axis];
 
-    needcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize) \
-        || swap;
+    needcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize) || swap;
+    if (needcopy) {
+        char *buffer = PyDataMem_NEW(N*elsize);
 
-    if (needcopy) {
-        char *buffer;
-        buffer = PyDataMem_NEW(N*elsize);
         while (size--) {
             _unaligned_strided_byte_copy(buffer, (intp) elsize, it->dataptr,
                                          astride, N, elsize);
@@ -2511,7 +2801,6 @@
             PyArray_ITER_NEXT(it);
         }
     }
-
     NPY_END_THREADS_DESCR(op->descr);
     Py_DECREF(it);
     return 0;
@@ -2526,10 +2815,10 @@
 _new_argsort(PyArrayObject *op, int axis, NPY_SORTKIND which)
 {
 
-    PyArrayIterObject *it=NULL;
-    PyArrayIterObject *rit=NULL;
+    PyArrayIterObject *it = NULL;
+    PyArrayIterObject *rit = NULL;
     PyObject *ret;
-    int needcopy=0, i;
+    int needcopy = 0, i;
     intp N, size;
     int elsize, swap;
     intp astride, rstride, *iptr;
@@ -2539,16 +2828,17 @@
     ret = PyArray_New(op->ob_type, op->nd,
                           op->dimensions, PyArray_INTP,
                           NULL, NULL, 0, 0, (PyObject *)op);
-    if (ret == NULL) return NULL;
-
+    if (ret == NULL) {
+        return NULL;
+    }
     it = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, &axis);
     rit = (PyArrayIterObject *)PyArray_IterAllButAxis(ret, &axis);
-    if (rit == NULL || it == NULL) goto fail;
-
+    if (rit == NULL || it == NULL) {
+        goto fail;
+    }
     swap = !PyArray_ISNOTSWAPPED(op);
 
     NPY_BEGIN_THREADS_DESCR(op->descr);
-
     argsort = op->descr->f->argsort[which];
     size = it->size;
     N = op->dimensions[axis];
@@ -2556,19 +2846,23 @@
     astride = op->strides[axis];
     rstride = PyArray_STRIDE(ret,axis);
 
-    needcopy = swap || !(op->flags & ALIGNED) || (astride != (intp) elsize) || \
-        (rstride != sizeof(intp));
-
+    needcopy = swap || !(op->flags & ALIGNED) || (astride != (intp) elsize) ||
+            (rstride != sizeof(intp));
     if (needcopy) {
         char *valbuffer, *indbuffer;
+
         valbuffer = PyDataMem_NEW(N*elsize);
         indbuffer = PyDataMem_NEW(N*sizeof(intp));
         while (size--) {
             _unaligned_strided_byte_copy(valbuffer, (intp) elsize, it->dataptr,
                                          astride, N, elsize);
-            if (swap) _strided_byte_swap(valbuffer, (intp) elsize, N, elsize);
+            if (swap) {
+                _strided_byte_swap(valbuffer, (intp) elsize, N, elsize);
+            }
             iptr = (intp *)indbuffer;
-            for (i=0; i<N; i++) *iptr++ = i;
+            for (i = 0; i < N; i++) {
+                *iptr++ = i;
+            }
             if (argsort(valbuffer, (intp *)indbuffer, N, op) < 0) {
                 PyDataMem_FREE(valbuffer);
                 PyDataMem_FREE(indbuffer);
@@ -2585,9 +2879,12 @@
     else {
         while (size--) {
             iptr = (intp *)rit->dataptr;
-            for (i=0; i<N; i++) *iptr++ = i;
-            if (argsort(it->dataptr, (intp *)rit->dataptr,
-                        N, op) < 0)  goto fail;
+            for (i = 0; i < N; i++) {
+                *iptr++ = i;
+            }
+            if (argsort(it->dataptr, (intp *)rit->dataptr, N, op) < 0) {
+                goto fail;
+            }
             PyArray_ITER_NEXT(it);
             PyArray_ITER_NEXT(rit);
         }
@@ -2600,9 +2897,7 @@
     return ret;
 
  fail:
-
     NPY_END_THREADS;
-
     Py_DECREF(ret);
     Py_XDECREF(it);
     Py_XDECREF(rit);
@@ -2611,7 +2906,6 @@
 
 
 /* Be sure to save this global_compare when necessary */
-
 static PyArrayObject *global_obj;
 
 static int
@@ -2620,12 +2914,11 @@
     return global_obj->descr->f->compare(a,b,global_obj);
 }
 
-/* Consumes reference to ap (op gets it)
-   op contains a version of the array with axes swapped if
-   local variable axis is not the last dimension.
-   orign must be defined locally.
-*/
-
+/*
+ * Consumes reference to ap (op gets it) op contains a version of
+ * the array with axes swapped if local variable axis is not the
+ * last dimension.  Origin must be defined locally.
+ */
 #define SWAPAXES(op, ap) {                                      \
         orign = (ap)->nd-1;                                     \
         if (axis != orign) {                                    \
@@ -2636,11 +2929,11 @@
         else (op) = (ap);                                       \
     }
 
-/* Consumes reference to ap (op gets it)
-   origin must be previously defined locally.
-   SWAPAXES must have been called previously.
-   op contains the swapped version of the array.
-*/
+/*
+ * Consumes reference to ap (op gets it) origin must be previously
+ * defined locally.  SWAPAXES must have been called previously.
+ * op contains the swapped version of the array.
+ */
 #define SWAPBACK(op, ap) {                                      \
         if (axis != orign) {                                    \
             (op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \
@@ -2670,22 +2963,24 @@
     }
 
 /*NUMPY_API
-  Sort an array in-place
-*/
+ * Sort an array in-place
+ */
 static int
 PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND which)
 {
-    PyArrayObject *ap=NULL, *store_arr=NULL;
+    PyArrayObject *ap = NULL, *store_arr = NULL;
     char *ip;
     int i, n, m, elsize, orign;
 
     n = op->nd;
-    if ((n==0) || (PyArray_SIZE(op)==1)) return 0;
-
-    if (axis < 0) axis += n;
+    if ((n == 0) || (PyArray_SIZE(op) == 1)) {
+        return 0;
+    }
+    if (axis < 0) {
+        axis += n;
+    }
     if ((axis < 0) || (axis >= n)) {
-        PyErr_Format(PyExc_ValueError,
-                     "axis(=%d) out of bounds", axis);
+        PyErr_Format(PyExc_ValueError, "axis(=%d) out of bounds", axis);
         return -1;
     }
     if (!PyArray_ISWRITEABLE(op)) {
@@ -2698,9 +2993,8 @@
     if (op->descr->f->sort[which] != NULL) {
         return _new_sort(op, axis, which);
     }
-
-    if ((which != PyArray_QUICKSORT) || \
-        op->descr->f->compare == NULL) {
+    if ((which != PyArray_QUICKSORT)
+        || op->descr->f->compare == NULL) {
         PyErr_SetString(PyExc_TypeError,
                         "desired sort not supported for this type");
         return -1;
@@ -2711,30 +3005,33 @@
     ap = (PyArrayObject *)PyArray_FromAny((PyObject *)op,
                                           NULL, 1, 0,
                                           DEFAULT | UPDATEIFCOPY, NULL);
-    if (ap == NULL) goto fail;
-
+    if (ap == NULL) {
+        goto fail;
+    }
     elsize = ap->descr->elsize;
     m = ap->dimensions[ap->nd-1];
-    if (m == 0) goto finish;
-
+    if (m == 0) {
+        goto finish;
+    }
     n = PyArray_SIZE(ap)/m;
 
     /* Store global -- allows re-entry -- restore before leaving*/
     store_arr = global_obj;
     global_obj = ap;
-
-    for (ip=ap->data, i=0; i<n; i++, ip+=elsize*m) {
+    for (ip = ap->data, i = 0; i < n; i++, ip += elsize*m) {
         qsort(ip, m, elsize, qsortCompare);
     }
-
     global_obj = store_arr;
 
-    if (PyErr_Occurred()) goto fail;
+    if (PyErr_Occurred()) {
+        goto fail;
+    }
 
  finish:
     Py_DECREF(ap);  /* Should update op if needed */
     SWAPBACK2(op);
     return 0;
+
  fail:
     Py_XDECREF(ap);
     SWAPBACK2(op);
@@ -2756,32 +3053,35 @@
 }
 
 /*NUMPY_API
-  ArgSort an array
-*/
+ * ArgSort an array
+ */
 static PyObject *
 PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
 {
-    PyArrayObject *ap=NULL, *ret=NULL, *store, *op2;
+    PyArrayObject *ap = NULL, *ret = NULL, *store, *op2;
     intp *ip;
     intp i, j, n, m, orign;
     int argsort_elsize;
     char *store_ptr;
 
     n = op->nd;
-    if ((n==0) || (PyArray_SIZE(op)==1)) {
+    if ((n == 0) || (PyArray_SIZE(op) == 1)) {
         ret = (PyArrayObject *)PyArray_New(op->ob_type, op->nd,
                                            op->dimensions,
                                            PyArray_INTP,
                                            NULL, NULL, 0, 0,
                                            (PyObject *)op);
-        if (ret == NULL) return NULL;
+        if (ret == NULL) {
+            return NULL;
+        }
         *((intp *)ret->data) = 0;
         return (PyObject *)ret;
     }
 
     /* Creates new reference op2 */
-    if ((op2=(PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;
-
+    if ((op2=(PyAO *)_check_axis(op, &axis, 0)) == NULL) {
+        return NULL;
+    }
     /* Determine if we should use new algorithm or not */
     if (op2->descr->f->argsort[which] != NULL) {
         ret = (PyArrayObject *)_new_argsort(op2, axis, which);
@@ -2799,39 +3099,39 @@
 
     /* ap will contain the reference to op2 */
     SWAPAXES(ap, op2);
-
     op = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)ap,
                                                     PyArray_NOTYPE,
                                                     1, 0);
-
     Py_DECREF(ap);
-    if (op == NULL) return NULL;
-
+    if (op == NULL) {
+        return NULL;
+    }
     ret = (PyArrayObject *)PyArray_New(op->ob_type, op->nd,
                                        op->dimensions, PyArray_INTP,
                                        NULL, NULL, 0, 0, (PyObject *)op);
-    if (ret == NULL) goto fail;
-
-
+    if (ret == NULL) {
+        goto fail;
+    }
     ip = (intp *)ret->data;
     argsort_elsize = op->descr->elsize;
     m = op->dimensions[op->nd-1];
-    if (m == 0) goto finish;
-
+    if (m == 0) {
+        goto finish;
+    }
     n = PyArray_SIZE(op)/m;
     store_ptr = global_data;
     global_data = op->data;
     store = global_obj;
     global_obj = op;
-    for (i=0; i<n; i++, ip+=m, global_data += m*argsort_elsize) {
-        for(j=0; j<m; j++) ip[j] = j;
-        qsort((char *)ip, m, sizeof(intp),
-              argsort_static_compare);
+    for (i = 0; i < n; i++, ip += m, global_data += m*argsort_elsize) {
+        for (j = 0; j < m; j++) {
+            ip[j] = j;
+        }
+        qsort((char *)ip, m, sizeof(intp), argsort_static_compare);
     }
     global_data = store_ptr;
     global_obj = store;
 
-
  finish:
     Py_DECREF(op);
     SWAPBACK(op, ret);
@@ -2846,20 +3146,20 @@
 
 
 /*NUMPY_API
-  LexSort an array providing indices that will sort a collection of arrays
-  lexicographically.  The first key is sorted on first, followed by the second key
-  -- requires that arg"merge"sort is available for each sort_key
-
-  Returns an index array that shows the indexes for the lexicographic sort along
-  the given axis.
-*/
+ *LexSort an array providing indices that will sort a collection of arrays
+ *lexicographically.  The first key is sorted on first, followed by the second key
+ *-- requires that arg"merge"sort is available for each sort_key
+ *
+ *Returns an index array that shows the indexes for the lexicographic sort along
+ *the given axis.
+ */
 static PyObject *
 PyArray_LexSort(PyObject *sort_keys, int axis)
 {
     PyArrayObject **mps;
     PyArrayIterObject **its;
-    PyArrayObject *ret=NULL;
-    PyArrayIterObject *rit=NULL;
+    PyArrayObject *ret = NULL;
+    PyArrayIterObject *rit = NULL;
     int n;
     int nd;
     int needcopy=0, i,j;
@@ -2867,31 +3167,40 @@
     int elsize;
     int maxelsize;
     intp astride, rstride, *iptr;
-    int object=0;
+    int object = 0;
     PyArray_ArgSortFunc *argsort;
-
     NPY_BEGIN_THREADS_DEF;
 
-        if (!PySequence_Check(sort_keys) || \
-            ((n=PySequence_Size(sort_keys)) <= 0)) {
-            PyErr_SetString(PyExc_TypeError,
-                            "need sequence of keys with len > 0 in lexsort");
-            return NULL;
-        }
+    if (!PySequence_Check(sort_keys)
+           || ((n=PySequence_Size(sort_keys)) <= 0)) {
+        PyErr_SetString(PyExc_TypeError,
+                "need sequence of keys with len > 0 in lexsort");
+        return NULL;
+    }
     mps = (PyArrayObject **) _pya_malloc(n*sizeof(PyArrayObject));
-    if (mps==NULL) return PyErr_NoMemory();
+    if (mps == NULL) {
+        return PyErr_NoMemory();
+    }
     its = (PyArrayIterObject **) _pya_malloc(n*sizeof(PyArrayIterObject));
-    if (its == NULL) {_pya_free(mps); return PyErr_NoMemory();}
-    for (i=0; i<n; i++) {mps[i] = NULL; its[i] = NULL;}
-    for (i=0; i<n; i++) {
+    if (its == NULL) {
+        _pya_free(mps);
+        return PyErr_NoMemory();
+    }
+    for (i = 0; i < n; i++) {
+        mps[i] = NULL;
+        its[i] = NULL;
+    }
+    for (i = 0; i < n; i++) {
         PyObject *obj;
         obj = PySequence_GetItem(sort_keys, i);
         mps[i] = (PyArrayObject *)PyArray_FROM_O(obj);
         Py_DECREF(obj);
-        if (mps[i] == NULL) goto fail;
-        if (i>0) {
-            if ((mps[i]->nd != mps[0]->nd) ||       \
-                (!PyArray_CompareLists(mps[i]->dimensions,
+        if (mps[i] == NULL) {
+            goto fail;
+        }
+        if (i > 0) {
+            if ((mps[i]->nd != mps[0]->nd)
+                || (!PyArray_CompareLists(mps[i]->dimensions,
                                        mps[0]->dimensions,
                                        mps[0]->nd))) {
                 PyErr_SetString(PyExc_ValueError,
@@ -2904,78 +3213,92 @@
                          "merge sort not available for item %d", i);
             goto fail;
         }
-        if (!object &&
-            PyDataType_FLAGCHK(mps[i]->descr, NPY_NEEDS_PYAPI))
+        if (!object
+            && PyDataType_FLAGCHK(mps[i]->descr, NPY_NEEDS_PYAPI)) {
             object = 1;
-        its[i] = (PyArrayIterObject *)PyArray_IterAllButAxis    \
+        }
+        its[i] = (PyArrayIterObject *)PyArray_IterAllButAxis
             ((PyObject *)mps[i], &axis);
-        if (its[i]==NULL) goto fail;
+        if (its[i] == NULL) {
+            goto fail;
+        }
     }
 
     /* Now we can check the axis */
     nd = mps[0]->nd;
-    if ((nd==0) || (PyArray_SIZE(mps[0])==1)) {
+    if ((nd == 0) || (PyArray_SIZE(mps[0]) == 1)) {
         ret = (PyArrayObject *)PyArray_New(&PyArray_Type, mps[0]->nd,
                                            mps[0]->dimensions,
                                            PyArray_INTP,
                                            NULL, NULL, 0, 0, NULL);
 
-        if (ret == NULL) goto fail;
+        if (ret == NULL) {
+            goto fail;
+        }
         *((intp *)(ret->data)) = 0;
         goto finish;
     }
-    if (axis < 0) axis += nd;
+    if (axis < 0) {
+        axis += nd;
+    }
     if ((axis < 0) || (axis >= nd)) {
-        PyErr_Format(PyExc_ValueError,
-                     "axis(=%d) out of bounds", axis);
+        PyErr_Format(PyExc_ValueError, "axis(=%d) out of bounds", axis);
         goto fail;
     }
 
     /* Now do the sorting */
-
     ret = (PyArrayObject *)PyArray_New(&PyArray_Type, mps[0]->nd,
                                        mps[0]->dimensions, PyArray_INTP,
                                        NULL, NULL, 0, 0, NULL);
-    if (ret == NULL) goto fail;
-
-    rit = (PyArrayIterObject *)\
-        PyArray_IterAllButAxis((PyObject *)ret, &axis);
-    if (rit == NULL) goto fail;
-
-    if (!object) {NPY_BEGIN_THREADS;}
-
+    if (ret == NULL) {
+        goto fail;
+    }
+    rit = (PyArrayIterObject *)
+            PyArray_IterAllButAxis((PyObject *)ret, &axis);
+    if (rit == NULL) {
+        goto fail;
+    }
+    if (!object) {
+        NPY_BEGIN_THREADS;
+    }
     size = rit->size;
     N = mps[0]->dimensions[axis];
     rstride = PyArray_STRIDE(ret,axis);
-
     maxelsize = mps[0]->descr->elsize;
     needcopy = (rstride != sizeof(intp));
-    for (j=0; j<n && !needcopy; j++) {
-        needcopy = PyArray_ISBYTESWAPPED(mps[j]) ||             \
-            !(mps[j]->flags & ALIGNED) ||                   \
-            (mps[j]->strides[axis] != (intp)mps[j]->descr->elsize);
-        if (mps[j]->descr->elsize > maxelsize)
+    for (j = 0; j < n && !needcopy; j++) {
+        needcopy = PyArray_ISBYTESWAPPED(mps[j])
+            || !(mps[j]->flags & ALIGNED)
+            || (mps[j]->strides[axis] != (intp)mps[j]->descr->elsize);
+        if (mps[j]->descr->elsize > maxelsize) {
             maxelsize = mps[j]->descr->elsize;
+        }
     }
 
     if (needcopy) {
         char *valbuffer, *indbuffer;
         int *swaps;
+
         valbuffer = PyDataMem_NEW(N*maxelsize);
         indbuffer = PyDataMem_NEW(N*sizeof(intp));
         swaps = malloc(n*sizeof(int));
-        for (j=0; j<n; j++) swaps[j] = PyArray_ISBYTESWAPPED(mps[j]);
+        for (j = 0; j < n; j++) {
+            swaps[j] = PyArray_ISBYTESWAPPED(mps[j]);
+        }
         while (size--) {
             iptr = (intp *)indbuffer;
-            for (i=0; i<N; i++) *iptr++ = i;
-            for (j=0; j<n; j++) {
+            for (i = 0; i < N; i++) {
+                *iptr++ = i;
+            }
+            for (j = 0; j < n; j++) {
                 elsize = mps[j]->descr->elsize;
                 astride = mps[j]->strides[axis];
                 argsort = mps[j]->descr->f->argsort[PyArray_MERGESORT];
                 _unaligned_strided_byte_copy(valbuffer, (intp) elsize,
                                              its[j]->dataptr, astride, N, elsize);
-                if (swaps[j])
+                if (swaps[j]) {
                     _strided_byte_swap(valbuffer, (intp) elsize, N, elsize);
+                }
                 if (argsort(valbuffer, (intp *)indbuffer, N, mps[j]) < 0) {
                     PyDataMem_FREE(valbuffer);
                     PyDataMem_FREE(indbuffer);
@@ -2995,21 +3318,30 @@
     else {
         while (size--) {
             iptr = (intp *)rit->dataptr;
-            for (i=0; i<N; i++) *iptr++ = i;
-            for (j=0; j<n; j++) {
+            for (i = 0; i < N; i++) {
+                *iptr++ = i;
+            }
+            for (j = 0; j < n; j++) {
                 argsort = mps[j]->descr->f->argsort[PyArray_MERGESORT];
                 if (argsort(its[j]->dataptr, (intp *)rit->dataptr,
-                            N, mps[j]) < 0)  goto fail;
+                            N, mps[j]) < 0) {
+                    goto fail;
+                }
                 PyArray_ITER_NEXT(its[j]);
             }
             PyArray_ITER_NEXT(rit);
         }
     }
 
-    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]);}
+    for (i = 0; i < n; i++) {
+        Py_XDECREF(mps[i]);
+        Py_XDECREF(its[i]);
+    }
     Py_XDECREF(rit);
     _pya_free(mps);
     _pya_free(its);
@@ -3017,14 +3349,15 @@
 
  fail:
     NPY_END_THREADS;
-
-        Py_XDECREF(rit);
+    Py_XDECREF(rit);
     Py_XDECREF(ret);
-    for (i=0; i<n; i++) {Py_XDECREF(mps[i]); Py_XDECREF(its[i]);}
+    for (i = 0; i < n; i++) {
+        Py_XDECREF(mps[i]);
+        Py_XDECREF(its[i]);
+    }
     _pya_free(mps);
     _pya_free(its);
     return NULL;
-
 }
 
 
@@ -3052,15 +3385,17 @@
     int elsize = arr->descr->elsize;
     intp i;
 
-    for(i = 0; i < nkeys; ++i) {
+    for (i = 0; i < nkeys; ++i) {
         intp imin = 0;
         intp imax = nelts;
         while (imin < imax) {
             intp imid = imin + ((imax - imin) >> 2);
-            if (compare(parr + elsize*imid, pkey, key) < 0)
+            if (compare(parr + elsize*imid, pkey, key) < 0) {
                 imin = imid + 1;
-            else
+            }
+            else {
                 imax = imid;
+            }
         }
         *pret = imin;
         pret += 1;
@@ -3098,10 +3433,12 @@
         intp imax = nelts;
         while (imin < imax) {
             intp imid = imin + ((imax - imin) >> 2);
-            if (compare(parr + elsize*imid, pkey, key) <= 0)
+            if (compare(parr + elsize*imid, pkey, key) <= 0) {
                 imin = imid + 1;
-            else
+            }
+            else {
                 imax = imid;
+            }
         }
         *pret = imin;
         pret += 1;
@@ -3111,8 +3448,8 @@
 
 
 /*NUMPY_API
-  Convert object to searchsorted side
-*/
+ * Convert object to searchsorted side
+ */
 static int
 PyArray_SearchsideConverter(PyObject *obj, void *addr)
 {
@@ -3125,10 +3462,12 @@
         return PY_FAIL;
     }
 
-    if (str[0] == 'l' || str[0] == 'L')
+    if (str[0] == 'l' || str[0] == 'L') {
         *side = NPY_SEARCHLEFT;
-    else if (str[0] == 'r' || str[0] == 'R')
+    }
+    else if (str[0] == 'r' || str[0] == 'R') {
         *side = NPY_SEARCHRIGHT;
+    }
     else {
         PyErr_Format(PyExc_ValueError,
                      "'%s' is an invalid value for keyword 'side'", str);
@@ -3139,43 +3478,40 @@
 
 
 /*NUMPY_API
-  Numeric.searchsorted(a,v)
-*/
+ * Numeric.searchsorted(a,v)
+ */
 static PyObject *
 PyArray_SearchSorted(PyArrayObject *op1, PyObject *op2, NPY_SEARCHSIDE side)
 {
-    PyArrayObject *ap1=NULL;
-    PyArrayObject *ap2=NULL;
-    PyArrayObject *ret=NULL;
+    PyArrayObject *ap1 = NULL;
+    PyArrayObject *ap2 = NULL;
+    PyArrayObject *ret = NULL;
     PyArray_Descr *dtype;
-
     NPY_BEGIN_THREADS_DEF;
 
     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);
-
     if (ap1 == NULL) {
         Py_DECREF(dtype);
         return NULL;
     }
 
     /* need ap2 as contiguous array and of right type */
-    ap2 = (PyArrayObject *)PyArray_FromAny(op2, dtype, 0, 0, NPY_DEFAULT, NULL);
-
-    if (ap2 == NULL)
+    ap2 = (PyArrayObject *)PyArray_FromAny(op2, dtype,
+                                          0, 0, NPY_DEFAULT, NULL);
+    if (ap2 == NULL) {
         goto fail;
-
+    }
     /* ret is a contiguous array of intp type to hold returned indices */
     ret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd,
                                        ap2->dimensions, PyArray_INTP,
                                        NULL, NULL, 0, 0, (PyObject *)ap2);
-    if (ret == NULL)
+    if (ret == NULL) {
         goto fail;
-
+    }
     /* check that comparison function exists */
     if (ap2->descr->f->compare == NULL) {
         PyErr_SetString(PyExc_TypeError,
@@ -3205,9 +3541,9 @@
 }
 
 /*
-  Make a new empty array, of the passed size, of a type that takes the
-  priority of ap1 and ap2 into account.
-*/
+ * Make a new empty array, of the passed size, of a type that takes the
+ * priority of ap1 and ap2 into account.
+ */
 static PyArrayObject *
 new_array_for_sum(PyArrayObject *ap1, PyArrayObject *ap2,
                   int nd, intp dimensions[], int typenum)
@@ -3215,15 +3551,16 @@
     PyArrayObject *ret;
     PyTypeObject *subtype;
     double prior1, prior2;
-    /* Need to choose an output array that can hold a sum
-       -- use priority to determine which subtype.
-    */
+    /*
+     * Need to choose an output array that can hold a sum
+     * -- use priority to determine which subtype.
+     */
     if (ap2->ob_type != ap1->ob_type) {
         prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);
         prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);
-
         subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);
-    } else {
+    }
+    else {
         prior1 = prior2 = 0.0;
         subtype = ap1->ob_type;
     }
@@ -3235,16 +3572,15 @@
     return ret;
 }
 
-/* Could perhaps be redone to not make contiguous arrays
- */
+/* Could perhaps be redone to not make contiguous arrays */
 
 /*NUMPY_API
-  Numeric.innerproduct(a,v)
-*/
+ * Numeric.innerproduct(a,v)
+ */
 static PyObject *
 PyArray_InnerProduct(PyObject *op1, PyObject *op2)
 {
-    PyArrayObject *ap1, *ap2, *ret=NULL;
+    PyArrayObject *ap1, *ap2, *ret = NULL;
     PyArrayIterObject *it1, *it2;
     intp i, j, l;
     int typenum, nd, axis;
@@ -3253,90 +3589,86 @@
     intp dimensions[MAX_DIMS];
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
-
     NPY_BEGIN_THREADS_DEF;
 
-        typenum = PyArray_ObjectType(op1, 0);
+    typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
 
     typec = PyArray_DescrFromType(typenum);
     Py_INCREF(typec);
-    ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0,
-                                           BEHAVED, NULL);
-    if (ap1 == NULL) {Py_DECREF(typec); return NULL;}
-    ap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0,
-                                           BEHAVED, NULL);
-    if (ap2 == NULL) goto fail;
-
+    ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, BEHAVED, NULL);
+    if (ap1 == NULL) {
+        Py_DECREF(typec);
+        return NULL;
+    }
+    ap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0, BEHAVED, NULL);
+    if (ap2 == NULL) {
+        goto fail;
+    }
     if (ap1->nd == 0 || ap2->nd == 0) {
         ret = (ap1->nd == 0 ? ap1 : ap2);
-        ret = (PyArrayObject *)ret->ob_type->tp_as_number->\
-            nb_multiply((PyObject *)ap1, (PyObject *)ap2);
+        ret = (PyArrayObject *)ret->ob_type->tp_as_number->nb_multiply(
+                                            (PyObject *)ap1, (PyObject *)ap2);
         Py_DECREF(ap1);
         Py_DECREF(ap2);
         return (PyObject *)ret;
     }
 
-    l = ap1->dimensions[ap1->nd-1];
-
-    if (ap2->dimensions[ap2->nd-1] != l) {
+    l = ap1->dimensions[ap1->nd - 1];
+    if (ap2->dimensions[ap2->nd - 1] != l) {
         PyErr_SetString(PyExc_ValueError, "matrices are not aligned");
         goto fail;
     }
 
-    nd = ap1->nd+ap2->nd-2;
+    nd = ap1->nd + ap2->nd - 2;
     j = 0;
-    for(i=0; i<ap1->nd-1; i++) {
+    for (i = 0; i < ap1->nd - 1; i++) {
         dimensions[j++] = ap1->dimensions[i];
     }
-    for(i=0; i<ap2->nd-1; i++) {
+    for (i = 0; i < ap2->nd - 1; i++) {
         dimensions[j++] = ap2->dimensions[i];
     }
 
-
-    /* Need to choose an output array that can hold a sum
-       -- use priority to determine which subtype.
-    */
+    /*
+     * Need to choose an output array that can hold a sum
+     * -- use priority to determine which subtype.
+     */
     ret = new_array_for_sum(ap1, ap2, nd, dimensions, typenum);
-    if (ret == NULL) goto fail;
-
+    if (ret == NULL) {
+        goto fail;
+    }
     dot = (ret->descr->f->dotfunc);
-
     if (dot == NULL) {
         PyErr_SetString(PyExc_ValueError,
                         "dot not available for this type");
         goto fail;
     }
-
-    is1 = ap1->strides[ap1->nd-1];
-    is2 = ap2->strides[ap2->nd-1];
+    is1 = ap1->strides[ap1->nd - 1];
+    is2 = ap2->strides[ap2->nd - 1];
     op = ret->data; os = ret->descr->elsize;
-
-    axis = ap1->nd-1;
-    it1 = (PyArrayIterObject *)\
-        PyArray_IterAllButAxis((PyObject *)ap1, &axis);
-    axis = ap2->nd-1;
-    it2 = (PyArrayIterObject *)\
-        PyArray_IterAllButAxis((PyObject *)ap2, &axis);
-
+    axis = ap1->nd - 1;
+    it1 = (PyArrayIterObject *) PyArray_IterAllButAxis((PyObject *)ap1, &axis);
+    axis = ap2->nd - 1;
+    it2 = (PyArrayIterObject *) PyArray_IterAllButAxis((PyObject *)ap2, &axis);
     NPY_BEGIN_THREADS_DESCR(ap2->descr);
-        while(1) {
-            while(it2->index < it2->size) {
-                dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
-                op += os;
-                PyArray_ITER_NEXT(it2);
-            }
-            PyArray_ITER_NEXT(it1);
-            if (it1->index >= it1->size) break;
-            PyArray_ITER_RESET(it2);
+    while (1) {
+        while (it2->index < it2->size) {
+            dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
+            op += os;
+            PyArray_ITER_NEXT(it2);
         }
+        PyArray_ITER_NEXT(it1);
+        if (it1->index >= it1->size) {
+            break;
+        }
+        PyArray_ITER_RESET(it2);
+    }
     NPY_END_THREADS_DESCR(ap2->descr);
-        Py_DECREF(it1);
+    Py_DECREF(it1);
     Py_DECREF(it2);
-
-    if (PyErr_Occurred()) goto fail;
-
-
+    if (PyErr_Occurred()) {
+        goto fail;
+    }
     Py_DECREF(ap1);
     Py_DECREF(ap2);
     return (PyObject *)ret;
@@ -3349,14 +3681,14 @@
 }
 
 
-/* just like inner product but does the swapaxes stuff on the fly */
 /*NUMPY_API
-  Numeric.matrixproduct(a,v)
-*/
+ *Numeric.matrixproduct(a,v)
+ * just like inner product but does the swapaxes stuff on the fly
+ */
 static PyObject *
 PyArray_MatrixProduct(PyObject *op1, PyObject *op2)
 {
-    PyArrayObject *ap1, *ap2, *ret=NULL;
+    PyArrayObject *ap1, *ap2, *ret = NULL;
     PyArrayIterObject *it1, *it2;
     intp i, j, l;
     int typenum, nd, axis, matchDim;
@@ -3365,54 +3697,50 @@
     intp dimensions[MAX_DIMS];
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
-
     NPY_BEGIN_THREADS_DEF;
 
-        typenum = PyArray_ObjectType(op1, 0);
+    typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
-
     typec = PyArray_DescrFromType(typenum);
     Py_INCREF(typec);
-    ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0,
-                                           BEHAVED, NULL);
-    if (ap1 == NULL) {Py_DECREF(typec); return NULL;}
-    ap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0,
-                                           BEHAVED, NULL);
-    if (ap2 == NULL) goto fail;
-
+    ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, BEHAVED, NULL);
+    if (ap1 == NULL) {
+        Py_DECREF(typec);
+        return NULL;
+    }
+    ap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0, BEHAVED, NULL);
+    if (ap2 == NULL) {
+        goto fail;
+    }
     if (ap1->nd == 0 || ap2->nd == 0) {
         ret = (ap1->nd == 0 ? ap1 : ap2);
-        ret = (PyArrayObject *)ret->ob_type->tp_as_number->\
-            nb_multiply((PyObject *)ap1, (PyObject *)ap2);
+        ret = (PyArrayObject *)ret->ob_type->tp_as_number->nb_multiply(
+                                        (PyObject *)ap1, (PyObject *)ap2);
         Py_DECREF(ap1);
         Py_DECREF(ap2);
         return (PyObject *)ret;
     }
-
-    l = ap1->dimensions[ap1->nd-1];
+    l = ap1->dimensions[ap1->nd - 1];
     if (ap2->nd > 1) {
         matchDim = ap2->nd - 2;
     }
     else {
         matchDim = 0;
     }
-
     if (ap2->dimensions[matchDim] != l) {
         PyErr_SetString(PyExc_ValueError, "objects are not aligned");
         goto fail;
     }
-
-    nd = ap1->nd+ap2->nd-2;
+    nd = ap1->nd + ap2->nd - 2;
     if (nd > NPY_MAXDIMS) {
-        PyErr_SetString(PyExc_ValueError,
-                        "dot: too many dimensions in result");
+        PyErr_SetString(PyExc_ValueError, "dot: too many dimensions in result");
         goto fail;
     }
     j = 0;
-    for(i=0; i<ap1->nd-1; i++) {
+    for (i = 0; i < ap1->nd - 1; i++) {
         dimensions[j++] = ap1->dimensions[i];
     }
-    for(i=0; i<ap2->nd-2; i++) {
+    for (i = 0; i < ap2->nd - 2; i++) {
         dimensions[j++] = ap2->dimensions[i];
     }
     if(ap2->nd > 1) {
@@ -3426,20 +3754,20 @@
     */
 
     is1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];
-
     /* Choose which subtype to return */
     ret = new_array_for_sum(ap1, ap2, nd, dimensions, typenum);
-    if (ret == NULL) goto fail;
-
+    if (ret == NULL) {
+        goto fail;
+    }
     /* Ensure that multiarray.dot(<Nx0>,<0xM>) -> zeros((N,M)) */
     if (PyArray_SIZE(ap1) == 0 && PyArray_SIZE(ap2) == 0) {
         memset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));
     }
-    else {  /* Ensure that multiarray.dot([],[]) -> 0 */
+    else {
+        /* Ensure that multiarray.dot([],[]) -> 0 */
         memset(PyArray_DATA(ret), 0, PyArray_ITEMSIZE(ret));
     }
 
-
     dot = ret->descr->f->dotfunc;
     if (dot == NULL) {
         PyErr_SetString(PyExc_ValueError,
@@ -3448,29 +3776,31 @@
     }
 
     op = ret->data; os = ret->descr->elsize;
-
     axis = ap1->nd-1;
-    it1 = (PyArrayIterObject *)\
+    it1 = (PyArrayIterObject *)
         PyArray_IterAllButAxis((PyObject *)ap1, &axis);
-    it2 = (PyArrayIterObject *)\
+    it2 = (PyArrayIterObject *)
         PyArray_IterAllButAxis((PyObject *)ap2, &matchDim);
-
     NPY_BEGIN_THREADS_DESCR(ap2->descr);
-        while(1) {
-            while(it2->index < it2->size) {
-                dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
-                op += os;
-                PyArray_ITER_NEXT(it2);
-            }
-            PyArray_ITER_NEXT(it1);
-            if (it1->index >= it1->size) break;
-            PyArray_ITER_RESET(it2);
+    while (1) {
+        while (it2->index < it2->size) {
+            dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
+            op += os;
+            PyArray_ITER_NEXT(it2);
         }
+        PyArray_ITER_NEXT(it1);
+        if (it1->index >= it1->size) {
+            break;
+        }
+        PyArray_ITER_RESET(it2);
+    }
     NPY_END_THREADS_DESCR(ap2->descr);
-        Py_DECREF(it1);
+    Py_DECREF(it1);
     Py_DECREF(it2);
-    if (PyErr_Occurred()) goto fail;  /* only for OBJECT arrays */
-
+    if (PyErr_Occurred()) {
+        /* only for OBJECT arrays */
+        goto fail;
+    }
     Py_DECREF(ap1);
     Py_DECREF(ap2);
     return (PyObject *)ret;
@@ -3483,8 +3813,8 @@
 }
 
 /*NUMPY_API
-  Fast Copy and Transpose
-*/
+ * Fast Copy and Transpose
+ */
 static PyObject *
 PyArray_CopyAndTranspose(PyObject *op)
 {
@@ -3498,9 +3828,12 @@
 
     /* make sure it is well-behaved */
     arr = PyArray_FromAny(op, NULL, 0, 0, CARRAY, NULL);
-    if (arr == NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     nd = PyArray_NDIM(arr);
-    if (nd == 1) {     /* we will give in to old behavior */
+    if (nd == 1) {
+        /* we will give in to old behavior */
         ret = PyArray_Copy((PyArrayObject *)arr);
         Py_DECREF(arr);
         return ret;
@@ -3516,24 +3849,23 @@
     dims[0] = PyArray_DIM(arr,1);
     dims[1] = PyArray_DIM(arr,0);
     elsize = PyArray_ITEMSIZE(arr);
-
     Py_INCREF(PyArray_DESCR(arr));
     ret = PyArray_NewFromDescr(arr->ob_type,
                                PyArray_DESCR(arr),
                                2, dims,
                                NULL, NULL, 0, arr);
-
     if (ret == NULL) {
         Py_DECREF(arr);
         return NULL;
     }
+
     /* do 2-d loop */
     NPY_BEGIN_ALLOW_THREADS;
     optr = PyArray_DATA(ret);
     str2 = elsize*dims[0];
-    for (i=0; i<dims[0]; i++) {
+    for (i = 0; i < dims[0]; i++) {
         iptr = PyArray_BYTES(arr) + i*elsize;
-        for (j=0; j<dims[1]; j++) {
+        for (j = 0; j < dims[1]; j++) {
             /* optr[i,j] = iptr[j,i] */
             memcpy(optr, iptr, elsize);
             optr += elsize;
@@ -3546,12 +3878,12 @@
 }
 
 /*NUMPY_API
-  Numeric.correlate(a1,a2,mode)
-*/
+ * Numeric.correlate(a1,a2,mode)
+ */
 static PyObject *
 PyArray_Correlate(PyObject *op1, PyObject *op2, int mode)
 {
-    PyArrayObject *ap1, *ap2, *ret=NULL;
+    PyArrayObject *ap1, *ap2, *ret = NULL;
     intp length;
     intp i, n1, n2, n, n_left, n_right;
     int typenum;
@@ -3567,48 +3899,55 @@
 
     typec = PyArray_DescrFromType(typenum);
     Py_INCREF(typec);
-    ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 1, 1,
-                                           DEFAULT, NULL);
-    if (ap1 == NULL) {Py_DECREF(typec); return NULL;}
-    ap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 1, 1,
-                                           DEFAULT, NULL);
-    if (ap2 == NULL) goto fail;
-
+    ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 1, 1, DEFAULT, NULL);
+    if (ap1 == NULL) {
+        Py_DECREF(typec);
+        return NULL;
+    }
+    ap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 1, 1, DEFAULT, NULL);
+    if (ap2 == NULL) {
+        goto fail;
+    }
     n1 = ap1->dimensions[0];
     n2 = ap2->dimensions[0];
-
     if (n1 < n2) {
-        ret = ap1; ap1 = ap2; ap2 = ret;
-        ret = NULL; i = n1;n1=n2;n2=i;
+        ret = ap1;
+        ap1 = ap2;
+        ap2 = ret;
+        ret = NULL;
+        i = n1;
+        n1 = n2;
+        n2 = i;
     }
     length = n1;
     n = n2;
     switch(mode) {
     case 0:
-        length = length-n+1;
+        length = length - n + 1;
         n_left = n_right = 0;
         break;
     case 1:
         n_left = (intp)(n/2);
-        n_right = n-n_left-1;
+        n_right = n - n_left - 1;
         break;
     case 2:
-        n_right = n-1;
-        n_left = n-1;
-        length = length+n-1;
+        n_right = n - 1;
+        n_left = n - 1;
+        length = length + n - 1;
         break;
     default:
-        PyErr_SetString(PyExc_ValueError,
-                        "mode must be 0, 1, or 2");
+        PyErr_SetString(PyExc_ValueError, "mode must be 0, 1, or 2");
         goto fail;
     }
 
-    /* Need to choose an output array that can hold a sum
-       -- use priority to determine which subtype.
-    */
+    /*
+     * Need to choose an output array that can hold a sum
+     * -- use priority to determine which subtype.
+     */
     ret = new_array_for_sum(ap1, ap2, 1, &length, typenum);
-    if (ret == NULL) goto fail;
-
+    if (ret == NULL) {
+        goto fail;
+    }
     dot = ret->descr->f->dotfunc;
     if (dot == NULL) {
         PyErr_SetString(PyExc_ValueError,
@@ -3617,32 +3956,34 @@
     }
 
     NPY_BEGIN_THREADS_DESCR(ret->descr);
-
-        is1 = ap1->strides[0]; is2 = ap2->strides[0];
-    op = ret->data; os = ret->descr->elsize;
-
-    ip1 = ap1->data; ip2 = ap2->data+n_left*is2;
-    n = n-n_left;
-    for(i=0; i<n_left; i++) {
+    is1 = ap1->strides[0];
+    is2 = ap2->strides[0];
+    op = ret->data;
+    os = ret->descr->elsize;
+    ip1 = ap1->data;
+    ip2 = ap2->data + n_left*is2;
+    n = n - n_left;
+    for (i = 0; i < n_left; i++) {
         dot(ip1, is1, ip2, is2, op, n, ret);
         n++;
         ip2 -= is2;
         op += os;
     }
-    for(i=0; i<(n1-n2+1); i++) {
+    for (i = 0; i < (n1 - n2 + 1); i++) {
         dot(ip1, is1, ip2, is2, op, n, ret);
         ip1 += is1;
         op += os;
     }
-    for(i=0; i<n_right; i++) {
+    for (i = 0; i < n_right; i++) {
         n--;
         dot(ip1, is1, ip2, is2, op, n, ret);
         ip1 += is1;
         op += os;
     }
     NPY_END_THREADS_DESCR(ret->descr);
-
-        if (PyErr_Occurred()) goto fail;
+    if (PyErr_Occurred()) {
+        goto fail;
+    }
     Py_DECREF(ap1);
     Py_DECREF(ap2);
     return (PyObject *)ret;
@@ -3656,8 +3997,8 @@
 
 
 /*NUMPY_API
-  ArgMin
-*/
+ * ArgMin
+ */
 static PyObject *
 PyArray_ArgMin(PyArrayObject *ap, int axis, PyArrayObject *out)
 {

Modified: branches/coremath/numpy/core/src/scalarmathmodule.c.src
===================================================================
--- branches/coremath/numpy/core/src/scalarmathmodule.c.src	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/core/src/scalarmathmodule.c.src	2009-02-22 03:41:06 UTC (rev 6445)
@@ -64,8 +64,18 @@
     ulonglong ah, al, bh, bl, w, x, y, z;
 
     /* Convert to non-negative quantities */
-    if (a0 < 0) { a = -a0; } else { a = a0; }
-    if (b0 < 0) { b = -b0; } else { b = b0; }
+    if (a0 < 0) {
+        a = -a0;
+    }
+    else {
+        a = a0;
+    }
+    if (b0 < 0) {
+        b = -b0;
+    }
+    else {
+        b = b0;
+    }
 
 
 #if SIZEOF_LONGLONG == 64
@@ -109,55 +119,61 @@
 
 
 /* Basic operations:
+ *
+ *  BINARY:
+ *
+ * add, subtract, multiply, divide, remainder, divmod, power,
+ * floor_divide, true_divide
+ *
+ * lshift, rshift, and, or, xor (integers only)
+ *
+ * UNARY:
+ *
+ * negative, positive, absolute, nonzero, invert, int, long, float, oct, hex
+ *
+ */
 
-   BINARY:
-
-   add, subtract, multiply, divide, remainder, divmod, power,
-   floor_divide, true_divide
-
-   lshift, rshift, and, or, xor (integers only)
-
-   UNARY:
-
-   negative, positive, absolute, nonzero, invert, int, long, float, oct, hex
-
-*/
-
 /**begin repeat
-   #name=byte,short,int,long,longlong#
-**/
+ *  #name = byte, short, int, long, longlong#
+ */
 static void
 @name@_ctype_add(@name@ a, @name@ b, @name@ *out) {
     *out = a + b;
-    if ((*out^a) >= 0 || (*out^b) >= 0)
+    if ((*out^a) >= 0 || (*out^b) >= 0) {
         return;
+    }
     generate_overflow_error();
     return;
 }
 static void
 @name@_ctype_subtract(@name@ a, @name@ b, @name@ *out) {
     *out = a - b;
-    if ((*out^a) >= 0 || (*out^~b) >= 0)
+    if ((*out^a) >= 0 || (*out^~b) >= 0) {
         return;
+    }
     generate_overflow_error();
     return;
 }
 /**end repeat**/
+
 /**begin repeat
-   #name=ubyte,ushort,uint,ulong,ulonglong#
-**/
+ *  #name = ubyte, ushort, uint, ulong, ulonglong#
+ */
 static void
 @name@_ctype_add(@name@ a, @name@ b, @name@ *out) {
     *out = a + b;
-    if (*out >= a && *out >= b)
+    if (*out >= a && *out >= b) {
         return;
+    }
     generate_overflow_error();
     return;
 }
 static void
 @name@_ctype_subtract(@name@ a, @name@ b, @name@ *out) {
     *out = a - b;
-    if (a >= b) return;
+    if (a >= b) {
+        return;
+    }
     generate_overflow_error();
     return;
 }
@@ -168,13 +184,14 @@
 #endif
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong#
-   #big=(int,uint)*2,(longlong,ulonglong)*2#
-   #NAME=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG#
-   #SIZENAME=BYTE*2,SHORT*2,INT*2,LONG*2#
-   #SIZE=INT*4,LONGLONG*4#
-   #neg=(1,0)*4#
-**/
+ *
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong#
+ * #big = (int,uint)*2, (longlong,ulonglong)*2#
+ * #NAME = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG#
+ * #SIZENAME = BYTE*2, SHORT*2, INT*2, LONG*2#
+ * #SIZE = INT*4,LONGLONG*4#
+ * #neg = (1,0)*4#
+ */
 #if SIZEOF_@SIZE@ > SIZEOF_@SIZENAME@
 static void
 @name@_ctype_multiply(@name@ a, @name@ b, @name@ *out) {
@@ -193,25 +210,29 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=int,uint,long,ulong,longlong,ulonglong#
-   #SIZE=INT*2,LONG*2,LONGLONG*2#
-   #char=(s,u)*3#
-**/
+ *
+ * #name = int, uint, long, ulong, longlong, ulonglong#
+ * #SIZE = INT*2, LONG*2, LONGLONG*2#
+ * #char = (s,u)*3#
+ */
 #if SIZEOF_LONGLONG == SIZEOF_@SIZE@
 static void
 @name@_ctype_multiply(@name@ a, @name@ b, @name@ *out) {
     *out = a * b;
-    if (@char@longlong_overflow(a, b))
+    if (@char@longlong_overflow(a, b)) {
         generate_overflow_error();
+    }
     return;
 }
 #endif
 /**end repeat**/
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
-   #neg=(1,0)*5#
-**/
+ *
+ * #name = byte, ubyte, short, ushort, int, uint, long,
+ *         ulong, longlong, ulonglong#
+ * #neg = (1,0)*5#
+ */
 static void
 @name@_ctype_divide(@name@ a, @name@ b, @name@ *out) {
     if (b == 0) {
@@ -228,13 +249,16 @@
 #if @neg@
         @name@ tmp;
         tmp = a / b;
-        if (((a > 0) != (b > 0)) && (a % b != 0)) tmp--;
+        if (((a > 0) != (b > 0)) && (a % b != 0)) {
+            tmp--;
+        }
         *out = tmp;
 #else
         *out = a / b;
 #endif
     }
 }
+
 #define @name@_ctype_floor_divide @name@_ctype_divide
 static void
 @name@_ctype_remainder(@name@ a, @name@ b, @name@ *out) {
@@ -247,7 +271,8 @@
     else if ((a > 0) == (b > 0)) {
         *out = a % b;
     }
-    else { /* handled like Python does */
+    else {
+        /* handled like Python does */
         *out = a % b;
         if (*out) *out += b;
     }
@@ -258,18 +283,21 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
-   #otyp=float*4, double*6#
-**/
+ *
+ * #name = byte, ubyte, short, ushort, int, uint, long,
+ *         ulong, longlong, ulonglong#
+ * #otyp = float*4, double*6#
+ */
 #define @name@_ctype_true_divide(a, b, out)     \
     *(out) = ((@otyp@) (a)) / ((@otyp@) (b));
 /**end repeat**/
 
 /* b will always be positive in this call */
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
-   #upc=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG#
-**/
+ *
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong#
+ * #upc = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG#
+ */
 static void
 @name@_ctype_power(@name@ a, @name@ b, @name@ *out) {
     @name@ temp, ix, mult;
@@ -280,11 +308,14 @@
         if (b & 1) {
             @name@_ctype_multiply(ix, temp, &mult);
             ix = mult;
-            if (temp == 0)
-                break; /* Avoid ix / 0 */
+            if (temp == 0) {
+                break;
+            }
         }
         b >>= 1;        /* Shift exponent down by 1 bit */
-        if (b==0) break;
+        if (b==0) {
+            break;
+        }
         /* Square the value of temp */
         @name@_ctype_multiply(temp, temp, &mult);
         temp = mult;
@@ -298,16 +329,16 @@
 /* QUESTION:  Should we check for overflow / underflow in (l,r)shift? */
 
 /**begin repeat
-   #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong)*5#
-   #oper=and*10, xor*10, or*10, lshift*10, rshift*10#
-   #op=&*10, ^*10, |*10, <<*10, >>*10#
-**/
+ * #name = (byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong)*5#
+ * #oper = and*10, xor*10, or*10, lshift*10, rshift*10#
+ * #op = &*10, ^*10, |*10, <<*10, >>*10#
+ */
 #define @name@_ctype_@oper@(arg1, arg2, out) *(out) = (arg1) @op@ (arg2)
 /**end repeat**/
 
 /**begin repeat
-   #name=float, double, longdouble#
-**/
+ * #name = float, double, longdouble#
+ */
 static @name@ (*_basic_@name@_floor)(@name@);
 static @name@ (*_basic_@name@_sqrt)(@name@);
 static @name@ (*_basic_@name@_fmod)(@name@, @name@);
@@ -321,44 +352,46 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=cfloat, cdouble, clongdouble#
-   #rtype=float, double, longdouble#
-   #c=f,,l#
-**/
+ * #name = cfloat, cdouble, clongdouble#
+ * #rtype = float, double, longdouble#
+ * #c = f,,l#
+ */
 #define @name@_ctype_add(a, b, outp) do{        \
     (outp)->real = (a).real + (b).real;         \
     (outp)->imag = (a).imag + (b).imag;         \
-    }while(0)
+    } while(0)
 #define @name@_ctype_subtract(a, b, outp) do{   \
     (outp)->real = (a).real - (b).real;         \
     (outp)->imag = (a).imag - (b).imag;         \
-    }while(0)
+    } while(0)
 #define @name@_ctype_multiply(a, b, outp) do{                   \
     (outp)->real = (a).real * (b).real - (a).imag * (b).imag;   \
     (outp)->imag = (a).real * (b).imag + (a).imag * (b).real;   \
-    }while(0)
+    } while(0)
 #define @name@_ctype_divide(a, b, outp) do{                     \
     @rtype@ d = (b).real*(b).real + (b).imag*(b).imag;          \
     (outp)->real = ((a).real*(b).real + (a).imag*(b).imag)/d;   \
     (outp)->imag = ((a).imag*(b).real - (a).real*(b).imag)/d;   \
-    }while(0)
+    } while(0)
 #define @name@_ctype_true_divide @name@_ctype_divide
 #define @name@_ctype_floor_divide(a, b, outp) do {      \
     (outp)->real = _basic_@rtype@_floor                 \
     (((a).real*(b).real + (a).imag*(b).imag) /          \
      ((b).real*(b).real + (b).imag*(b).imag));          \
     (outp)->imag = 0;                                   \
-    }while(0)
+    } while(0)
 /**end repeat**/
 
 /**begin repeat
-   #name=float,double,longdouble#
-**/
+ * #name = float, double, longdouble#
+ */
 static void
 @name@_ctype_remainder(@name@ a, @name@ b, @name@ *out) {
     @name@ mod;
     mod = _basic_@name@_fmod(a, b);
-    if (mod && (((b < 0) != (mod < 0)))) mod += b;
+    if (mod && (((b < 0) != (mod < 0)))) {
+        mod += b;
+    }
     *out = mod;
 }
 /**end repeat**/
@@ -366,8 +399,9 @@
 
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble#
-**/
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong, longlong,
+ *         ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble#
+ */
 #define @name@_ctype_divmod(a, b, out, out2) {  \
     @name@_ctype_floor_divide(a, b, out);       \
     @name@_ctype_remainder(a, b, out2);         \
@@ -375,8 +409,8 @@
 /**end repeat**/
 
 /**begin repeat
-   #name= float, double, longdouble#
-**/
+ * #name = float, double, longdouble#
+ */
 static @name@ (*_basic_@name@_pow)(@name@ a, @name@ b);
 static void
 @name@_ctype_power(@name@ a, @name@ b, @name@ *out) {
@@ -385,9 +419,10 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#
-   #uns=(0,1)*5,0*3#
-**/
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong, longlong,
+ *         ulonglong, float, double, longdouble#
+ * #uns = (0,1)*5,0*3#
+ */
 static void
 @name@_ctype_negative(@name@ a, @name@ *out)
 {
@@ -400,8 +435,8 @@
 
 
 /**begin repeat
-   #name= cfloat, cdouble, clongdouble#
-**/
+ * #name = cfloat, cdouble, clongdouble#
+ */
 static void
 @name@_ctype_negative(@name@ a, @name@ *out)
 {
@@ -411,8 +446,9 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#
-**/
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong, longlong,
+ *         ulonglong, float, double, longdouble#
+ */
 static void
 @name@_ctype_positive(@name@ a, @name@ *out)
 {
@@ -420,13 +456,14 @@
 }
 /**end repeat**/
 
-/* Get the nc_powf, nc_pow, and nc_powl functions from
-   the data area of the power ufunc in umathmodule.
-*/
+/*
+ * Get the nc_powf, nc_pow, and nc_powl functions from
+ * the data area of the power ufunc in umathmodule.
+ */
 
 /**begin repeat
-   #name=cfloat, cdouble, clongdouble#
-**/
+ * #name = cfloat, cdouble, clongdouble#
+ */
 static void
 @name@_ctype_positive(@name@ a, @name@ *out)
 {
@@ -443,15 +480,15 @@
 
 
 /**begin repeat
-   #name=ubyte, ushort, uint, ulong, ulonglong#
-**/
+ * #name = ubyte, ushort, uint, ulong, ulonglong#
+ */
 #define @name@_ctype_absolute @name@_ctype_positive
 /**end repeat**/
 
 
 /**begin repeat
-   #name=byte, short, int, long, longlong, float, double, longdouble#
-**/
+ * #name = byte, short, int, long, longlong, float, double, longdouble#
+ */
 static void
 @name@_ctype_absolute(@name@ a, @name@ *out)
 {
@@ -460,9 +497,9 @@
 /**end repeat**/
 
 /**begin repeat
-   #name= cfloat, cdouble, clongdouble#
-   #rname= float, double, longdouble#
-**/
+ * #name = cfloat, cdouble, clongdouble#
+ * #rname = float, double, longdouble#
+ */
 static void
 @name@_ctype_absolute(@name@ a, @rname@ *out)
 {
@@ -471,8 +508,9 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong#
-**/
+ * #name = byte, ubyte, short, ushort, int, uint, long,
+ *         ulong, longlong, ulonglong#
+ */
 #define @name@_ctype_invert(a, out) *(out) = ~a;
 /**end repeat**/
 
@@ -480,25 +518,27 @@
 
 
 /* The general strategy for commutative binary operators is to
+ *
+ * 1) Convert the types to the common type if both are scalars (0 return)
+ * 2) If both are not scalars use ufunc machinery (-2 return)
+ * 3) If both are scalars but cannot be cast to the right type
+ * return NotImplmented (-1 return)
+ *
+ * 4) Perform the function on the C-type.
+ * 5) If an error condition occurred, check to see
+ * what the current error-handling is and handle the error.
+ *
+ * 6) Construct and return the output scalar.
+ */
 
-   1) Convert the types to the common type if both are scalars (0 return)
-   2) If both are not scalars use ufunc machinery (-2 return)
-   3) If both are scalars but cannot be cast to the right type
-   return NotImplmented (-1 return)
-
-   4) Perform the function on the C-type.
-   5) If an error condition occurred, check to see
-   what the current error-handling is and handle the error.
-
-   6) Construct and return the output scalar.
-*/
-
-
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble#
-   #Name=Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#
-   #NAME=BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
-**/
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong, longlong,
+ *         ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble#
+ * #Name = Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong,
+ *         ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#
+ * #NAME = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG,
+ *         ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
+ */
 
 static int
 _@name@_convert_to_ctype(PyObject *a, @name@ *arg1)
@@ -512,13 +552,17 @@
     else if (PyArray_IsScalar(a, Generic)) {
         PyArray_Descr *descr1;
         int ret;
-        if (!PyArray_IsScalar(a, Number)) return -1;
+        if (!PyArray_IsScalar(a, Number)) {
+            return -1;
+        }
         descr1 = PyArray_DescrFromTypeObject((PyObject *)(a->ob_type));
         if (PyArray_CanCastSafely(descr1->type_num, PyArray_@NAME@)) {
             PyArray_CastScalarDirect(a, descr1, arg1, PyArray_@NAME@);
             ret = 0;
         }
-        else ret = -1;
+        else {
+            ret = -1;
+        }
         Py_DECREF(descr1);
         return ret;
     }
@@ -535,26 +579,29 @@
 
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,cfloat,cdouble#
-**/
-
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong,
+ *         longlong, ulonglong, float, double, cfloat, cdouble#
+ */
 static int
 _@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1,
                            PyObject *b, @name@ *arg2)
 {
     int ret;
     ret = _@name@_convert_to_ctype(a, arg1);
-    if (ret < 0) return ret;
+    if (ret < 0) {
+        return ret;
+    }
     ret = _@name@_convert_to_ctype(b, arg2);
-    if (ret < 0) return ret;
+    if (ret < 0) {
+        return ret;
+    }
     return 0;
 }
-
 /**end repeat**/
 
 /**begin repeat
-   #name=longdouble, clongdouble#
-**/
+ * #name = longdouble, clongdouble#
+ */
 
 static int
 _@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1,
@@ -562,10 +609,16 @@
 {
     int ret;
     ret = _@name@_convert_to_ctype(a, arg1);
-    if (ret < 0) return ret;
+    if (ret < 0) {
+        return ret;
+    }
     ret = _@name@_convert_to_ctype(b, arg2);
-    if (ret == -2) ret = -3;
-    if (ret < 0) return ret;    
+    if (ret == -2) {
+        ret = -3;
+    }
+    if (ret < 0) {
+        return ret;
+    }
     return 0;
 }
 
@@ -600,26 +653,34 @@
 #endif
 
     switch(_@name@_convert2_to_ctypes(a, &arg1, b, &arg2)) {
-    case 0:
-        break;
-    case -1: /* one of them can't be cast safely
-                must be mixed-types*/
-        return PyArray_Type.tp_as_number->nb_@oper@(a,b); 
-    case -2: /* use default handling */
-        if (PyErr_Occurred()) return NULL;
-        return PyGenericArrType_Type.tp_as_number->nb_@oper@(a,b);
-    case -3: /* special case for longdouble and clongdouble
-		because they have a recursive getitem in their dtype */
-        Py_INCREF(Py_NotImplemented);
-	return Py_NotImplemented;
+        case 0:
+            break;
+        case -1:
+            /* one of them can't be cast safely must be mixed-types*/
+            return PyArray_Type.tp_as_number->nb_@oper@(a,b);
+        case -2:
+            /* use default handling */
+            if (PyErr_Occurred()) {
+                return NULL;
+            }
+            return PyGenericArrType_Type.tp_as_number->nb_@oper@(a,b);
+        case -3:
+            /*
+             * special case for longdouble and clongdouble
+             * because they have a recursive getitem in their dtype
+             */
+            Py_INCREF(Py_NotImplemented);
+            return Py_NotImplemented;
     }
 
 #if @fperr@
     PyUFunc_clearfperr();
 #endif
 
-    /* here we do the actual calculation with arg1 and arg2 */
-    /* as a function call. */
+    /*
+     * here we do the actual calculation with arg1 and arg2
+     * as a function call.
+     */
 #if @twoout@
     @name@_ctype_@oper@(arg1, arg2, &out, &out2);
 #else
@@ -632,9 +693,11 @@
     if (retstatus) {
         int bufsize, errmask;
         PyObject *errobj;
+
         if (PyUFunc_GetPyValues("@name@_scalars", &bufsize, &errmask,
-                                &errobj) < 0)
+                                &errobj) < 0) {
             return NULL;
+        }
         first = 1;
         if (PyUFunc_handlefperr(errmask, errobj, retstatus, &first)) {
             Py_XDECREF(errobj);
@@ -647,18 +710,28 @@
 
 #if @twoout@
     ret = PyTuple_New(2);
-    if (ret==NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     obj = PyArrayScalar_New(@OName@);
-    if (obj == NULL) {Py_DECREF(ret); return NULL;}
+    if (obj == NULL) {
+        Py_DECREF(ret);
+        return NULL;
+    }
     PyArrayScalar_ASSIGN(obj, @OName@, out);
     PyTuple_SET_ITEM(ret, 0, obj);
     obj = PyArrayScalar_New(@OName@);
-    if (obj == NULL) {Py_DECREF(ret); return NULL;}
+    if (obj == NULL) {
+        Py_DECREF(ret);
+        return NULL;
+    }
     PyArrayScalar_ASSIGN(obj, @OName@, out2);
     PyTuple_SET_ITEM(ret, 1, obj);
 #else
     ret = PyArrayScalar_New(@OName@);
-    if (ret==NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     PyArrayScalar_ASSIGN(ret, @OName@, out);
 #endif
     return ret;
@@ -692,24 +765,32 @@
 #endif
 
     switch(_@name@_convert2_to_ctypes(a, &arg1, b, &arg2)) {
-    case 0:
-        break;
-    case -1: /* can't cast both safely
-                mixed-types? */
-        return PyArray_Type.tp_as_number->nb_power(a,b,NULL);
-    case -2: /* use default handling */
-        if (PyErr_Occurred()) return NULL;
-        return PyGenericArrType_Type.tp_as_number->nb_power(a,b,NULL);
-    case -3: /* special case for longdouble and clongdouble
-		because they have a recursive getitem in their dtype */
-        Py_INCREF(Py_NotImplemented);
-	return Py_NotImplemented;
+        case 0:
+            break;
+        case -1:
+            /* can't cast both safely mixed-types? */
+            return PyArray_Type.tp_as_number->nb_power(a,b,NULL);
+        case -2:
+            /* use default handling */
+            if (PyErr_Occurred()) {
+                return NULL;
+            }
+            return PyGenericArrType_Type.tp_as_number->nb_power(a,b,NULL);
+        case -3:
+            /*
+             * special case for longdouble and clongdouble
+             * because they have a recursive getitem in their dtype
+             */
+            Py_INCREF(Py_NotImplemented);
+            return Py_NotImplemented;
     }
 
     PyUFunc_clearfperr();
 
-    /* here we do the actual calculation with arg1 and arg2 */
-    /* as a function call. */
+    /*
+     * here we do the actual calculation with arg1 and arg2
+     * as a function call.
+     */
 #if @cmplx@
     if (arg2.real == 0 && arg1.real == 0) {
         out1.real = out.real = 1;
@@ -735,9 +816,11 @@
     if (retstatus) {
         int bufsize, errmask;
         PyObject *errobj;
+
         if (PyUFunc_GetPyValues("@name@_scalars", &bufsize, &errmask,
-                                &errobj) < 0)
+                                &errobj) < 0) {
             return NULL;
+        }
         first = 1;
         if (PyUFunc_handlefperr(errmask, errobj, retstatus, &first)) {
             Py_XDECREF(errobj);
@@ -749,17 +832,23 @@
 #if @isint@
     if (arg2 < 0) {
         ret = PyArrayScalar_New(@OName@);
-        if (ret==NULL) return NULL;
+        if (ret == NULL) {
+            return NULL;
+        }
         PyArrayScalar_ASSIGN(ret, @OName@, out1);
     }
     else {
         ret = PyArrayScalar_New(@Name@);
-        if (ret==NULL) return NULL;
+        if (ret == NULL) {
+            return NULL;
+        }
         PyArrayScalar_ASSIGN(ret, @Name@, out);
     }
 #else
     ret = PyArrayScalar_New(@Name@);
-    if (ret==NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     PyArrayScalar_ASSIGN(ret, @Name@, out);
 #endif
 
@@ -769,26 +858,26 @@
 
 
 /**begin repeat
-   #name=(cfloat,cdouble,clongdouble)*2#
-   #oper=divmod*3,remainder*3#
-**/
+ * #name = (cfloat,cdouble,clongdouble)*2#
+ * #oper = divmod*3,remainder*3#
+ */
 #define @name@_@oper@ NULL
 /**end repeat**/
 
 /**begin repeat
-   #name=(float,double,longdouble,cfloat,cdouble,clongdouble)*5#
-   #oper=lshift*6, rshift*6, and*6, or*6, xor*6#
-**/
+ * #name = (float,double,longdouble,cfloat,cdouble,clongdouble)*5#
+ * #oper = lshift*6, rshift*6, and*6, or*6, xor*6#
+ */
 #define @name@_@oper@ NULL
 /**end repeat**/
 
 
 /**begin repeat
-   #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*3, byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
-   #otyp=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*2,byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,float,double,longdouble,byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
-   #OName=(Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble)*2, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, Float, Double, LongDouble, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong#
-   #oper=negative*16, positive*16, absolute*16, invert*10#
-**/
+ * #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*3, byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
+ * #otyp=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*2,byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,float,double,longdouble,byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
+ * #OName=(Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble)*2, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, Float, Double, LongDouble, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong#
+ * #oper=negative*16, positive*16, absolute*16, invert*10#
+ */
 static PyObject *
 @name@_@oper@(PyObject *a)
 {
@@ -799,16 +888,22 @@
     switch(_@name@_convert_to_ctype(a, &arg1)) {
     case 0:
         break;
-    case -1: /* can't cast both safely use different add function */
+    case -1:
+        /* can't cast both safely use different add function */
         Py_INCREF(Py_NotImplemented);
         return Py_NotImplemented;
-    case -2: /* use default handling */
-        if (PyErr_Occurred()) return NULL;
+    case -2:
+        /* use default handling */
+        if (PyErr_Occurred()) {
+            return NULL;
+        }
         return PyGenericArrType_Type.tp_as_number->nb_@oper@(a);
     }
 
-    /* here we do the actual calculation with arg1 and arg2 */
-    /* make it a function call. */
+    /*
+     * here we do the actual calculation with arg1 and arg2
+     * make it a function call.
+     */
 
     @name@_ctype_@oper@(arg1, &out);
 
@@ -820,15 +915,16 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=float,double,longdouble,cfloat,cdouble,clongdouble#
-**/
+ * #name = float, double, longdouble, cfloat, cdouble, clongdouble#
+ */
 #define @name@_invert NULL
 /**end repeat**/
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble#
-   #simp=1*13,0*3#
-**/
+ * #name = byte, ubyte, short, ushort, int, uint, long, ulong, longlong,
+ *         ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble#
+ * #simp=1*13,0*3#
+ */
 static int
 @name@_nonzero(PyObject *a)
 {
@@ -836,12 +932,16 @@
     @name@ arg1;
 
     if (_@name@_convert_to_ctype(a, &arg1) < 0) {
-        if (PyErr_Occurred()) return -1;
+        if (PyErr_Occurred()) {
+            return -1;
+        }
         return PyGenericArrType_Type.tp_as_number->nb_nonzero(a);
     }
 
-    /* here we do the actual calculation with arg1 and arg2 */
-    /* make it a function call. */
+    /*
+     * here we do the actual calculation with arg1 and arg2
+     * make it a function call.
+     */
 
 #if @simp@
     ret = (arg1 != 0);
@@ -854,14 +954,15 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble#
-   #Name=Byte,UByte,Short,UShort,Int,UInt,Long,ULong,LongLong,ULongLong,Float,Double,LongDouble,CFloat,CDouble,CLongDouble#
-   #cmplx=,,,,,,,,,,,,,.real,.real,.real#
-   #sign=(signed,unsigned)*5,,,,,,#
-   #ctype=long*8,PY_LONG_LONG*2,double*6#
-   #realtyp=0*10,1*6#
-   #func=(PyLong_FromLong,PyLong_FromUnsignedLong)*4,PyLong_FromLongLong,PyLong_FromUnsignedLongLong,PyLong_FromDouble*6#
-**/
+ *
+ * #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble#
+ * #Name=Byte,UByte,Short,UShort,Int,UInt,Long,ULong,LongLong,ULongLong,Float,Double,LongDouble,CFloat,CDouble,CLongDouble#
+ * #cmplx=,,,,,,,,,,,,,.real,.real,.real#
+ * #sign=(signed,unsigned)*5,,,,,,#
+ * #ctype=long*8,PY_LONG_LONG*2,double*6#
+ * #realtyp=0*10,1*6#
+ * #func=(PyLong_FromLong,PyLong_FromUnsignedLong)*4,PyLong_FromLongLong,PyLong_FromUnsignedLongLong,PyLong_FromDouble*6#
+ */
 static PyObject *
 @name@_int(PyObject *obj)
 {
@@ -878,12 +979,13 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*2#
-   #Name=(Byte,UByte,Short,UShort,Int,UInt,Long,ULong,LongLong,ULongLong,Float,Double,LongDouble,CFloat,CDouble,CLongDouble)*2#
-   #cmplx=(,,,,,,,,,,,,,.real,.real,.real)*2#
-   #which=long*16,float*16#
-   #func=(PyLong_FromLongLong, PyLong_FromUnsignedLongLong)*5,PyLong_FromDouble*6,PyFloat_FromDouble*16#
-**/
+ *
+ * #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*2#
+ * #Name=(Byte,UByte,Short,UShort,Int,UInt,Long,ULong,LongLong,ULongLong,Float,Double,LongDouble,CFloat,CDouble,CLongDouble)*2#
+ * #cmplx=(,,,,,,,,,,,,,.real,.real,.real)*2#
+ * #which=long*16,float*16#
+ * #func=(PyLong_FromLongLong, PyLong_FromUnsignedLongLong)*5,PyLong_FromDouble*6,PyFloat_FromDouble*16#
+ */
 static PyObject *
 @name@_@which@(PyObject *obj)
 {
@@ -893,11 +995,12 @@
 
 
 /**begin repeat
-   #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*2#
-   #oper=oct*16, hex*16#
-   #kind=(int*5, long*5, int, long*2, int, long*2)*2#
-   #cap=(Int*5, Long*5, Int, Long*2, Int, Long*2)*2#
-**/
+ *
+ * #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble)*2#
+ * #oper=oct*16, hex*16#
+ * #kind=(int*5, long*5, int, long*2, int, long*2)*2#
+ * #cap=(Int*5, Long*5, Int, Long*2, Int, Long*2)*2#
+ */
 static PyObject *
 @name@_@oper@(PyObject *obj)
 {
@@ -910,9 +1013,9 @@
 
 
 /**begin repeat
-   #oper=le,ge,lt,gt,eq,ne#
-   #op=<=,>=,<,>,==,!=#
-**/
+ * #oper=le,ge,lt,gt,eq,ne#
+ * #op=<=,>=,<,>,==,!=#
+ */
 #define def_cmp_@oper@(arg1, arg2) (arg1 @op@ arg2)
 #define cmplx_cmp_@oper@(arg1, arg2) ((arg1.real == arg2.real) ?        \
                                       arg1.imag @op@ arg2.imag :        \
@@ -920,9 +1023,9 @@
 /**end repeat**/
 
 /**begin repeat
-   #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble#
-   #simp=def*13,cmplx*3#
-**/
+ * #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble#
+ * #simp=def*13,cmplx*3#
+ */
 static PyObject*
 @name@_richcompare(PyObject *self, PyObject *other, int cmp_op)
 {

Modified: branches/coremath/numpy/core/src/scalartypes.inc.src
===================================================================
--- branches/coremath/numpy/core/src/scalartypes.inc.src	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/core/src/scalartypes.inc.src	2009-02-22 03:41:06 UTC (rev 6445)
@@ -13,72 +13,74 @@
     {PyObject_HEAD_INIT(&PyBoolArrType_Type) 1},
 };
 
-/* Inheritance established later when tp_bases is set (or tp_base for
-   single inheritance) */
+/*
+ * Inheritance is established later when tp_bases is set (or tp_base for
+ * single inheritance)
+ */
 
 /**begin repeat
-
-#name=number, integer, signedinteger, unsignedinteger, inexact, floating, complexfloating, flexible, character#
-#NAME=Number, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character#
-*/
-
+ * #name = number, integer, signedinteger, unsignedinteger, inexact,
+ *         floating, complexfloating, flexible, character#
+ * #NAME = Number, Integer, SignedInteger, UnsignedInteger, Inexact,
+ *         Floating, ComplexFloating, Flexible, Character#
+ */
 static PyTypeObject Py@NAME@ArrType_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                /*ob_size*/
-    "numpy.@name@",                   /*tp_name*/
-    sizeof(PyObject),                 /*tp_basicsize*/
-    0,                                  /* tp_itemsize */
+    0,                                           /* ob_size*/
+    "numpy.@name@",                              /* tp_name*/
+    sizeof(PyObject),                            /* tp_basicsize*/
+    0,                                           /* tp_itemsize */
     /* methods */
-    0,   /* tp_dealloc */
-    0,   /* tp_print */
-    0,   /* tp_getattr */
-    0,   /* tp_setattr */
-    0,   /* tp_compare */
-    0,   /* tp_repr */
-    0,   /* tp_as_number */
-    0,   /* tp_as_sequence */
-    0,   /* tp_as_mapping */
-    0,   /* tp_hash */
-    0,   /* tp_call */
-    0,   /* tp_str */
-    0,   /* tp_getattro */
-    0,   /* tp_setattro */
-    0,   /* tp_as_buffer */
-    0,   /* tp_flags */
-    0,   /* tp_doc */
-    0,   /* tp_traverse */
-    0,   /* tp_clear */
-    0,   /* tp_richcompare */
-    0,   /* tp_weaklistoffset */
-    0,   /* tp_iter */ 
-    0,   /* tp_iternext */ 
-    0,   /* tp_methods */
-    0,   /* tp_members */
-    0,   /* tp_getset */
-    0,   /* tp_base */
-    0,   /* tp_dict */
-    0,   /* tp_descr_get */
-    0,   /* tp_descr_set */
-    0,   /* tp_dictoffset */
-    0,   /* tp_init */
-    0,   /* tp_alloc */
-    0,   /* tp_new */
-    0,   /* tp_free */
-    0,   /* tp_is_gc */
-    0,   /* tp_bases */
-    0,   /* tp_mro */
-    0,   /* tp_cache */
-    0,   /* tp_subclasses */
-    0,   /* tp_weaklist */
-    0,   /* tp_del */
+    0,                                           /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    0,                                           /* tp_as_sequence */
+    0,                                           /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    0,                                           /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    0,                                           /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    0,                                           /* tp_iternext */
+    0,                                           /* tp_methods */
+    0,                                           /* tp_members */
+    0,                                           /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    0,                                           /* tp_init */
+    0,                                           /* tp_alloc */
+    0,                                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 /**end repeat**/
@@ -118,13 +120,18 @@
         CASE(CLONGDOUBLE, CLongDouble);
         CASE(OBJECT, Object);
 #undef CASE
-        case NPY_STRING: return (void *)PyString_AS_STRING(scalar);
-        case NPY_UNICODE: return (void *)PyUnicode_AS_DATA(scalar);
-        case NPY_VOID: return ((PyVoidScalarObject *)scalar)->obval;
+        case NPY_STRING:
+            return (void *)PyString_AS_STRING(scalar);
+        case NPY_UNICODE:
+            return (void *)PyUnicode_AS_DATA(scalar);
+        case NPY_VOID:
+            return ((PyVoidScalarObject *)scalar)->obval;
     }
 
-    /* Must be a user-defined type --- check to see which
-       scalar it inherits from. */
+    /*
+     * Must be a user-defined type --- check to see which
+     * scalar it inherits from.
+     */
 
 #define _CHK(cls) (PyObject_IsInstance(scalar, \
             (PyObject *)&Py##cls##ArrType_Type))
@@ -140,7 +147,8 @@
                 _IFCASE(Long);
                 _IFCASE(LongLong);
             }
-            else { /* Unsigned Integer */
+            else {
+                /* Unsigned Integer */
                 _IFCASE(UByte);
                 _IFCASE(UShort);
                 _IFCASE(UInt);
@@ -148,49 +156,64 @@
                 _IFCASE(ULongLong);
             }
         }
-        else { /* Inexact */
+        else {
+            /* Inexact */
             if _CHK(Floating) {
                 _IFCASE(Float);
                 _IFCASE(Double);
                 _IFCASE(LongDouble);
             }
-            else { /*ComplexFloating */
+            else {
+                /*ComplexFloating */
                 _IFCASE(CFloat);
                 _IFCASE(CDouble);
                 _IFCASE(CLongDouble);
             }
         }
     }
-    else if _CHK(Bool) return _OBJ(Bool);
-    else if _CHK(Flexible) {
-        if _CHK(String) return (void *)PyString_AS_STRING(scalar);
-        if _CHK(Unicode) return (void *)PyUnicode_AS_DATA(scalar);
-        if _CHK(Void) return ((PyVoidScalarObject *)scalar)->obval;
+    else if (_CHK(Bool)) {
+        return _OBJ(Bool);
     }
-    else _IFCASE(Object);
+    else if (_CHK(Flexible)) {
+        if (_CHK(String)) {
+            return (void *)PyString_AS_STRING(scalar);
+        }
+        if (_CHK(Unicode)) {
+            return (void *)PyUnicode_AS_DATA(scalar);
+        }
+        if (_CHK(Void)) {
+            return ((PyVoidScalarObject *)scalar)->obval;
+        }
+    }
+    else {
+        _IFCASE(Object);
+    }
 
 
-    /* Use the alignment flag to figure out where the data begins
-       after a PyObject_HEAD
+    /*
+     * Use the alignment flag to figure out where the data begins
+     * after a PyObject_HEAD
      */
     memloc = (intp)scalar;
     memloc += sizeof(PyObject);
-    /* now round-up to the nearest alignment value
-     */
+    /* now round-up to the nearest alignment value */
     align = descr->alignment;
-    if (align > 1) memloc = ((memloc + align - 1)/align)*align;
+    if (align > 1) {
+        memloc = ((memloc + align - 1)/align)*align;
+    }
     return (void *)memloc;
 #undef _IFCASE
 #undef _OBJ
 #undef _CHK
 }
 
-/* no error checking is performed -- ctypeptr must be same type as scalar */
-/* in case of flexible type, the data is not copied
-   into ctypeptr which is expected to be a pointer to pointer */
 /*NUMPY_API
- Convert to c-type
-*/
+ * Convert to c-type
+ *
+ * no error checking is performed -- ctypeptr must be same type as scalar
+ * in case of flexible type, the data is not copied
+ * into ctypeptr which is expected to be a pointer to pointer
+ */
 static void
 PyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr)
 {
@@ -202,24 +225,23 @@
     if (PyTypeNum_ISEXTENDED(typecode->type_num)) {
         void **ct = (void **)ctypeptr;
         *ct = newptr;
-    } else {
+    }
+    else {
         memcpy(ctypeptr, newptr, typecode->elsize);
     }
     Py_DECREF(typecode);
     return;
 }
 
-/* The output buffer must be large-enough to receive the value */
-/*  Even for flexible types which is different from ScalarAsCtype
-    where only a reference for flexible types is returned
-*/
-
-/* This may not work right on narrow builds for NumPy unicode scalars.
+/*NUMPY_API
+ * Cast Scalar to c-type
+ *
+ * The output buffer must be large-enough to receive the value
+ *  Even for flexible types which is different from ScalarAsCtype
+ *  where only a reference for flexible types is returned
+ *
+ * This may not work right on narrow builds for NumPy unicode scalars.
  */
-
-/*NUMPY_API
- Cast Scalar to c-type
-*/
 static int
 PyArray_CastScalarToCtype(PyObject *scalar, void *ctypeptr,
                           PyArray_Descr *outcode)
@@ -229,7 +251,9 @@
 
     descr = PyArray_DescrFromScalar(scalar);
     castfunc = PyArray_GetCastFunc(descr, outcode->type_num);
-    if (castfunc == NULL) return -1;
+    if (castfunc == NULL) {
+        return -1;
+    }
     if (PyTypeNum_ISEXTENDED(descr->type_num) ||
             PyTypeNum_ISEXTENDED(outcode->type_num)) {
         PyArrayObject *ain, *aout;
@@ -245,7 +269,10 @@
                     0, NULL,
                     NULL, ctypeptr,
                     CARRAY, NULL);
-        if (aout == NULL) {Py_DECREF(ain); return -1;}
+        if (aout == NULL) {
+            Py_DECREF(ain);
+            return -1;
+        }
         castfunc(ain->data, aout->data, 1, ain, aout);
         Py_DECREF(ain);
         Py_DECREF(aout);
@@ -258,8 +285,8 @@
 }
 
 /*NUMPY_API
- Cast Scalar to c-type
-*/
+ * Cast Scalar to c-type
+ */
 static int
 PyArray_CastScalarDirect(PyObject *scalar, PyArray_Descr *indescr,
                          void *ctypeptr, int outtype)
@@ -267,22 +294,24 @@
     PyArray_VectorUnaryFunc* castfunc;
     void *ptr;
     castfunc = PyArray_GetCastFunc(indescr, outtype);
-    if (castfunc == NULL) return -1;
+    if (castfunc == NULL) {
+        return -1;
+    }
     ptr = scalar_value(scalar, indescr);
     castfunc(ptr, ctypeptr, 1, NULL, NULL);
     return 0;
 }
 
-/* 0-dim array from array-scalar object */
-/* always contains a copy of the data
-   unless outcode is NULL, it is of void type and the referrer does
-   not own it either.
-*/
-
-/* steals reference to outcode */
 /*NUMPY_API
- Get 0-dim array from scalar
-*/
+ * Get 0-dim array from scalar
+ *
+ * 0-dim array from array-scalar object
+ * always contains a copy of the data
+ * unless outcode is NULL, it is of void type and the referrer does
+ * not own it either.
+ *
+ * steals reference to outcode
+ */
 static PyObject *
 PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode)
 {
@@ -310,8 +339,10 @@
             typecode,
             0, NULL,
             NULL, NULL, 0, NULL);
-    if (r==NULL) {Py_XDECREF(outcode); return NULL;}
-
+    if (r==NULL) {
+        Py_XDECREF(outcode);
+        return NULL;
+    }
     if (PyDataType_FLAGCHK(typecode, NPY_USE_SETITEM)) {
         if (typecode->f->setitem(scalar, PyArray_DATA(r), r) < 0) {
             Py_XDECREF(outcode); Py_DECREF(r);
@@ -328,7 +359,8 @@
                 (PyArray_UCS4 *)PyArray_DATA(r),
                 PyUnicode_GET_SIZE(scalar),
                 PyArray_ITEMSIZE(r) >> 2);
-    } else
+    }
+    else
 #endif
     {
         memcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r));
@@ -338,8 +370,9 @@
     }
 
 finish:
-    if (outcode == NULL) return r;
-
+    if (outcode == NULL) {
+        return r;
+    }
     if (outcode->type_num == typecode->type_num) {
         if (!PyTypeNum_ISEXTENDED(typecode->type_num) ||
                 (outcode->elsize == typecode->elsize))
@@ -353,10 +386,10 @@
 }
 
 /*NUMPY_API
-  Get an Array Scalar From a Python Object
-  Returns NULL if unsuccessful but error is only
-  set if another error occurred. Currently only Numeric-like
-  object supported.
+ * Get an Array Scalar From a Python Object
+ *
+ * Returns NULL if unsuccessful but error is only set if another error occurred.
+ * Currently only Numeric-like object supported.
  */
 static PyObject *
 PyArray_ScalarFromObject(PyObject *object)
@@ -367,17 +400,23 @@
     }
     if (PyInt_Check(object)) {
         ret = PyArrayScalar_New(Long);
-        if (ret == NULL) return NULL;
+        if (ret == NULL) {
+            return NULL;
+        }
         PyArrayScalar_VAL(ret, Long) = PyInt_AS_LONG(object);
     }
     else if (PyFloat_Check(object)) {
         ret = PyArrayScalar_New(Double);
-        if (ret == NULL) return NULL;
+        if (ret == NULL) {
+            return NULL;
+        }
         PyArrayScalar_VAL(ret, Double) = PyFloat_AS_DOUBLE(object);
     }
     else if (PyComplex_Check(object)) {
         ret = PyArrayScalar_New(CDouble);
-        if (ret == NULL) return NULL;
+        if (ret == NULL) {
+            return NULL;
+        }
         PyArrayScalar_VAL(ret, CDouble).real =
                 ((PyComplexObject *)object)->cval.real;
         PyArrayScalar_VAL(ret, CDouble).imag =
@@ -391,7 +430,9 @@
             return NULL;
         }
         ret = PyArrayScalar_New(LongLong);
-        if (ret == NULL) return NULL;
+        if (ret == NULL) {
+            return NULL;
+        }
         PyArrayScalar_VAL(ret, LongLong) = val;
     }
     else if (PyBool_Check(object)) {
@@ -410,14 +451,16 @@
 gentype_alloc(PyTypeObject *type, Py_ssize_t nitems)
 {
     PyObject *obj;
-    const size_t size = _PyObject_VAR_SIZE(type, nitems+1);
+    const size_t size = _PyObject_VAR_SIZE(type, nitems + 1);
 
     obj = (PyObject *)_pya_malloc(size);
     memset(obj, 0, size);
-    if (type->tp_itemsize == 0)
+    if (type->tp_itemsize == 0) {
         PyObject_INIT(obj, type);
-    else
+    }
+    else {
         (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems);
+    }
     return obj;
 }
 
@@ -436,8 +479,7 @@
 
     if (!PyArray_IsScalar(m1,Generic)) {
         if (PyArray_Check(m1)) {
-            ret = m1->ob_type->tp_as_number->nb_power(m1,m2,
-                    Py_None);
+            ret = m1->ob_type->tp_as_number->nb_power(m1,m2, Py_None);
         }
         else {
             if (!PyArray_IsScalar(m2,Generic)) {
@@ -445,17 +487,17 @@
                 return NULL;
             }
             arr = PyArray_FromScalar(m2, NULL);
-            if (arr == NULL) return NULL;
-            ret = arr->ob_type->tp_as_number->nb_power(m1, arr,
-                    Py_None);
+            if (arr == NULL) {
+                return NULL;
+            }
+            ret = arr->ob_type->tp_as_number->nb_power(m1, arr, Py_None);
             Py_DECREF(arr);
         }
         return ret;
     }
     if (!PyArray_IsScalar(m2, Generic)) {
         if (PyArray_Check(m2)) {
-            ret = m2->ob_type->tp_as_number->nb_power(m1,m2,
-                    Py_None);
+            ret = m2->ob_type->tp_as_number->nb_power(m1,m2, Py_None);
         }
         else {
             if (!PyArray_IsScalar(m1, Generic)) {
@@ -463,18 +505,21 @@
                 return NULL;
             }
             arr = PyArray_FromScalar(m1, NULL);
-            if (arr == NULL) return NULL;
-            ret = arr->ob_type->tp_as_number->nb_power(arr, m2,
-                    Py_None);
+            if (arr == NULL) {
+                return NULL;
+            }
+            ret = arr->ob_type->tp_as_number->nb_power(arr, m2, Py_None);
             Py_DECREF(arr);
         }
         return ret;
     }
-    arr=arg2=NULL;
+    arr = arg2 = NULL;
     arr = PyArray_FromScalar(m1, NULL);
     arg2 = PyArray_FromScalar(m2, NULL);
     if (arr == NULL || arg2 == NULL) {
-        Py_XDECREF(arr); Py_XDECREF(arg2); return NULL;
+        Py_XDECREF(arr);
+        Py_XDECREF(arg2);
+        return NULL;
     }
     ret = arr->ob_type->tp_as_number->nb_power(arr, arg2, Py_None);
     Py_DECREF(arr);
@@ -489,26 +534,35 @@
     PyObject *arr, *meth, *ret;
 
     arr = PyArray_FromScalar(self, NULL);
-    if (arr == NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     meth = PyObject_GetAttrString(arr, str);
-    if (meth == NULL) {Py_DECREF(arr); return NULL;}
-    if (kwds == NULL)
+    if (meth == NULL) {
+        Py_DECREF(arr);
+        return NULL;
+    }
+    if (kwds == NULL) {
         ret = PyObject_CallObject(meth, args);
-    else
+    }
+    else {
         ret = PyObject_Call(meth, args, kwds);
+    }
     Py_DECREF(meth);
     Py_DECREF(arr);
-    if (ret && PyArray_Check(ret))
+    if (ret && PyArray_Check(ret)) {
         return PyArray_Return((PyArrayObject *)ret);
-    else
+    }
+    else {
         return ret;
+    }
 }
 
 /**begin repeat
  *
- * #name=add, subtract, divide, remainder, divmod, lshift, rshift, and, xor, or, floor_divide, true_divide#
+ * #name = add, subtract, divide, remainder, divmod, lshift, rshift,
+ *         and, xor, or, floor_divide, true_divide#
  */
-
 static PyObject *
 gentype_@name@(PyObject *m1, PyObject *m2)
 {
@@ -521,28 +575,30 @@
 static PyObject *
 gentype_multiply(PyObject *m1, PyObject *m2)
 {
-    PyObject *ret=NULL;
+    PyObject *ret = NULL;
     long repeat;
 
     if (!PyArray_IsScalar(m1, Generic) &&
             ((m1->ob_type->tp_as_number == NULL) ||
              (m1->ob_type->tp_as_number->nb_multiply == NULL))) {
-        /* Try to convert m2 to an int and try sequence
-           repeat */
+        /* Try to convert m2 to an int and try sequence repeat */
         repeat = PyInt_AsLong(m2);
-        if (repeat == -1 && PyErr_Occurred()) return NULL;
+        if (repeat == -1 && PyErr_Occurred()) {
+            return NULL;
+        }
         ret = PySequence_Repeat(m1, (int) repeat);
     }
     else if (!PyArray_IsScalar(m2, Generic) &&
             ((m2->ob_type->tp_as_number == NULL) ||
              (m2->ob_type->tp_as_number->nb_multiply == NULL))) {
-        /* Try to convert m1 to an int and try sequence
-           repeat */
+        /* Try to convert m1 to an int and try sequence repeat */
         repeat = PyInt_AsLong(m1);
-        if (repeat == -1 && PyErr_Occurred()) return NULL;
+        if (repeat == -1 && PyErr_Occurred()) {
+            return NULL;
+        }
         ret = PySequence_Repeat(m2, (int) repeat);
     }
-    if (ret==NULL) {
+    if (ret == NULL) {
         PyErr_Clear(); /* no effect if not set */
         ret = PyArray_Type.tp_as_number->nb_multiply(m1, m2);
     }
@@ -550,17 +606,18 @@
 }
 
 /**begin repeat
-
-#name=positive, negative, absolute, invert, int, long, float, oct, hex#
-*/
-
+ *
+ * #name=positive, negative, absolute, invert, int, long, float, oct, hex#
+ */
 static PyObject *
 gentype_@name@(PyObject *m1)
 {
     PyObject *arr, *ret;
 
     arr = PyArray_FromScalar(m1, NULL);
-    if (arr == NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     ret = arr->ob_type->tp_as_number->nb_@name@(arr);
     Py_DECREF(arr);
     return ret;
@@ -574,7 +631,9 @@
     int ret;
 
     arr = PyArray_FromScalar(m1, NULL);
-    if (arr == NULL) return -1;
+    if (arr == NULL) {
+        return -1;
+    }
     ret = arr->ob_type->tp_as_number->nb_nonzero(arr);
     Py_DECREF(arr);
     return ret;
@@ -587,7 +646,9 @@
     PyObject *ret;
 
     arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
-    if (arr==NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     ret = PyObject_Str((PyObject *)arr);
     Py_DECREF(arr);
     return ret;
@@ -601,7 +662,9 @@
     PyObject *ret;
 
     arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
-    if (arr==NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     ret = PyObject_Str((PyObject *)arr);
     Py_DECREF(arr);
     return ret;
@@ -613,9 +676,9 @@
 #endif
 
 /**begin repeat
- * #name=float, double, longdouble#
- * #NAME=FLOAT, DOUBLE, LONGDOUBLE#
- * #type=f, d, l#
+ * #name = float, double, longdouble#
+ * #NAME = FLOAT, DOUBLE, LONGDOUBLE#
+ * #type = f, d, l#
  */
 
 #define _FMT1 "%%.%i" NPY_@NAME@_FMT
@@ -632,7 +695,7 @@
     res = NumPyOS_ascii_format@type@(buf, buflen, format, val, 0);
     if (res == NULL) {
         fprintf(stderr, "Error while formatting\n");
-	return;
+        return;
     }
 
     /* If nothing but digits after sign, append ".0" */
@@ -656,28 +719,28 @@
     if (val.real == 0.0) {
         PyOS_snprintf(format, sizeof(format), _FMT1, prec);
         res = NumPyOS_ascii_format@type@(buf, buflen-1, format, val.imag, 0);
-	if (res == NULL) {
+        if (res == NULL) {
             fprintf(stderr, "Error while formatting\n");
-	    return;
-	}
-	strncat(buf, "j", 1);
+            return;
+        }
+        strncat(buf, "j", 1);
     }
     else {
-	char re[64], im[64];
-	PyOS_snprintf(format, sizeof(format), _FMT1, prec);
+        char re[64], im[64];
+        PyOS_snprintf(format, sizeof(format), _FMT1, prec);
         res = NumPyOS_ascii_format@type@(re, sizeof(re), format, val.real, 0);
-	if (res == NULL) {
+        if (res == NULL) {
             fprintf(stderr, "Error while formatting\n");
-	    return;
-	}
+            return;
+        }
 
-	PyOS_snprintf(format, sizeof(format), _FMT2, prec);
+        PyOS_snprintf(format, sizeof(format), _FMT2, prec);
         res = NumPyOS_ascii_format@type@(im, sizeof(im), format, val.imag, 0);
-	if (res == NULL) {
+        if (res == NULL) {
             fprintf(stderr, "Error while formatting\n");
-	    return;
-	}
-	PyOS_snprintf(buf, buflen, "(%s%sj)", re, im);
+            return;
+        }
+        PyOS_snprintf(buf, buflen, "(%s%sj)", re, im);
     }
 }
 
@@ -686,19 +749,20 @@
 
 /**end repeat**/
 
-/* over-ride repr and str of array-scalar strings and unicode to
-   remove NULL bytes and then call the corresponding functions
-   of string and unicode.
+/*
+ * over-ride repr and str of array-scalar strings and unicode to
+ * remove NULL bytes and then call the corresponding functions
+ * of string and unicode.
  */
 
 /**begin repeat
-#name=string*2,unicode*2#
-#form=(repr,str)*2#
-#Name=String*2,Unicode*2#
-#NAME=STRING*2,UNICODE*2#
-#extra=AndSize*2,,#
-#type=char*2, Py_UNICODE*2#
-*/
+ * #name = string*2,unicode*2#
+ * #form = (repr,str)*2#
+ * #Name = String*2,Unicode*2#
+ * #NAME = STRING*2,UNICODE*2#
+ * #extra = AndSize*2,,#
+ * #type = char*2, Py_UNICODE*2#
+ */
 static PyObject *
 @name@type_@form@(PyObject *self)
 {
@@ -710,9 +774,13 @@
     ip = dptr = Py@Name@_AS_@NAME@(self);
     len = Py@Name@_GET_SIZE(self);
     dptr += len-1;
-    while(len > 0 && *dptr-- == 0) len--;
+    while(len > 0 && *dptr-- == 0) {
+        len--;
+    }
     new = Py@Name@_From@Name@@extra@(ip, len);
-    if (new == NULL) return PyString_FromString("");
+    if (new == NULL) {
+        return PyString_FromString("");
+    }
     ret = Py@Name@_Type.tp_@form@(new);
     Py_DECREF(new);
     return ret;
@@ -737,10 +805,11 @@
  *
  * These functions will return NULL if PyString creation fails.
  */
+
 /**begin repeat
- * #name=float, double, longdouble#
- * #Name=Float, Double, LongDouble#
- * #NAME=FLOAT, DOUBLE, LONGDOUBLE#
+ * #name = float, double, longdouble#
+ * #Name = Float, Double, LongDouble#
+ * #NAME = FLOAT, DOUBLE, LONGDOUBLE#
  */
 /**begin repeat1
  * #kind = str, repr#
@@ -778,38 +847,38 @@
  * float type print (control print a, where a is a float type instance)
  */
 /**begin repeat
- * #name=float, double, longdouble#
- * #Name=Float, Double, LongDouble#
- * #NAME=FLOAT, DOUBLE, LONGDOUBLE#
+ * #name = float, double, longdouble#
+ * #Name = Float, Double, LongDouble#
+ * #NAME = FLOAT, DOUBLE, LONGDOUBLE#
  */
 
 static int
 @name@type_print(PyObject *v, FILE *fp, int flags)
 {
-	char buf[100];
+        char buf[100];
         @name@ val = ((Py@Name@ScalarObject *)v)->obval;
 
-	format_@name@(buf, sizeof(buf), val,
-		      (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@PREC_REPR);
-	Py_BEGIN_ALLOW_THREADS
-	fputs(buf, fp);
-	Py_END_ALLOW_THREADS
-	return 0;
+        format_@name@(buf, sizeof(buf), val,
+                      (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@PREC_REPR);
+        Py_BEGIN_ALLOW_THREADS
+        fputs(buf, fp);
+        Py_END_ALLOW_THREADS
+        return 0;
 }
 
 static int
 c@name@type_print(PyObject *v, FILE *fp, int flags)
 {
         /* Size of buf: twice sizeof(real) + 2 (for the parenthesis) */
-	char buf[202];
+        char buf[202];
         c@name@ val = ((PyC@Name@ScalarObject *)v)->obval;
 
-	format_c@name@(buf, sizeof(buf), val,
-		       (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@PREC_REPR);
-	Py_BEGIN_ALLOW_THREADS
-	fputs(buf, fp);
-	Py_END_ALLOW_THREADS
-	return 0;
+        format_c@name@(buf, sizeof(buf), val,
+                       (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@PREC_REPR);
+        Py_BEGIN_ALLOW_THREADS
+        fputs(buf, fp);
+        Py_END_ALLOW_THREADS
+        return 0;
 }
 
 /**end repeat**/
@@ -821,13 +890,13 @@
  */
 
 /**begin repeat
-
-#name=(int, long, hex, oct, float)*2#
-#KIND=(Long*4, Float)*2#
-#char=,,,,,c*5#
-#CHAR=,,,,,C*5#
-#POST=,,,,,.real*5#
-*/
+ *
+ * #name = (int, long, hex, oct, float)*2#
+ * #KIND = (Long*4, Float)*2#
+ * #char = ,,,,,c*5#
+ * #CHAR = ,,,,,C*5#
+ * #POST = ,,,,,.real*5#
+ */
 static PyObject *
 @char@longdoubletype_@name@(PyObject *self)
 {
@@ -844,46 +913,46 @@
 
 
 static PyNumberMethods gentype_as_number = {
-    (binaryfunc)gentype_add,                    /*nb_add*/
-    (binaryfunc)gentype_subtract,               /*nb_subtract*/
-    (binaryfunc)gentype_multiply,               /*nb_multiply*/
-    (binaryfunc)gentype_divide,                 /*nb_divide*/
-    (binaryfunc)gentype_remainder,              /*nb_remainder*/
-    (binaryfunc)gentype_divmod,                 /*nb_divmod*/
-    (ternaryfunc)gentype_power,                 /*nb_power*/
+    (binaryfunc)gentype_add,                     /*nb_add*/
+    (binaryfunc)gentype_subtract,                /*nb_subtract*/
+    (binaryfunc)gentype_multiply,                /*nb_multiply*/
+    (binaryfunc)gentype_divide,                  /*nb_divide*/
+    (binaryfunc)gentype_remainder,               /*nb_remainder*/
+    (binaryfunc)gentype_divmod,                  /*nb_divmod*/
+    (ternaryfunc)gentype_power,                  /*nb_power*/
     (unaryfunc)gentype_negative,
-    (unaryfunc)gentype_positive,                /*nb_pos*/
-    (unaryfunc)gentype_absolute,                /*(unaryfunc)gentype_abs,*/
-    (inquiry)gentype_nonzero_number,            /*nb_nonzero*/
-    (unaryfunc)gentype_invert,                  /*nb_invert*/
-    (binaryfunc)gentype_lshift,                 /*nb_lshift*/
-    (binaryfunc)gentype_rshift,                 /*nb_rshift*/
-    (binaryfunc)gentype_and,                    /*nb_and*/
-    (binaryfunc)gentype_xor,                    /*nb_xor*/
-    (binaryfunc)gentype_or,                     /*nb_or*/
-    0,                                          /*nb_coerce*/
-    (unaryfunc)gentype_int,                     /*nb_int*/
-    (unaryfunc)gentype_long,                    /*nb_long*/
-    (unaryfunc)gentype_float,                   /*nb_float*/
-    (unaryfunc)gentype_oct,                     /*nb_oct*/
-    (unaryfunc)gentype_hex,                     /*nb_hex*/
-    0,                                          /*inplace_add*/
-    0,                                          /*inplace_subtract*/
-    0,                                          /*inplace_multiply*/
-    0,                                          /*inplace_divide*/
-    0,                                          /*inplace_remainder*/
-    0,                                          /*inplace_power*/
-    0,                                          /*inplace_lshift*/
-    0,                                          /*inplace_rshift*/
-    0,                                          /*inplace_and*/
-    0,                                          /*inplace_xor*/
-    0,                                          /*inplace_or*/
-    (binaryfunc)gentype_floor_divide,           /*nb_floor_divide*/
-    (binaryfunc)gentype_true_divide,            /*nb_true_divide*/
-    0,                                          /*nb_inplace_floor_divide*/
-    0,                                          /*nb_inplace_true_divide*/
+    (unaryfunc)gentype_positive,                 /*nb_pos*/
+    (unaryfunc)gentype_absolute,                 /*(unaryfunc)gentype_abs,*/
+    (inquiry)gentype_nonzero_number,             /*nb_nonzero*/
+    (unaryfunc)gentype_invert,                   /*nb_invert*/
+    (binaryfunc)gentype_lshift,                  /*nb_lshift*/
+    (binaryfunc)gentype_rshift,                  /*nb_rshift*/
+    (binaryfunc)gentype_and,                     /*nb_and*/
+    (binaryfunc)gentype_xor,                     /*nb_xor*/
+    (binaryfunc)gentype_or,                      /*nb_or*/
+    0,                                           /*nb_coerce*/
+    (unaryfunc)gentype_int,                      /*nb_int*/
+    (unaryfunc)gentype_long,                     /*nb_long*/
+    (unaryfunc)gentype_float,                    /*nb_float*/
+    (unaryfunc)gentype_oct,                      /*nb_oct*/
+    (unaryfunc)gentype_hex,                      /*nb_hex*/
+    0,                                           /*inplace_add*/
+    0,                                           /*inplace_subtract*/
+    0,                                           /*inplace_multiply*/
+    0,                                           /*inplace_divide*/
+    0,                                           /*inplace_remainder*/
+    0,                                           /*inplace_power*/
+    0,                                           /*inplace_lshift*/
+    0,                                           /*inplace_rshift*/
+    0,                                           /*inplace_and*/
+    0,                                           /*inplace_xor*/
+    0,                                           /*inplace_or*/
+    (binaryfunc)gentype_floor_divide,            /*nb_floor_divide*/
+    (binaryfunc)gentype_true_divide,             /*nb_true_divide*/
+    0,                                           /*nb_inplace_floor_divide*/
+    0,                                           /*nb_inplace_true_divide*/
 #if PY_VERSION_HEX >= 0x02050000
-    (unaryfunc)NULL,                            /*nb_index*/
+    (unaryfunc)NULL,                             /*nb_index*/
 #endif
 };
 
@@ -894,7 +963,9 @@
     PyObject *arr, *ret;
 
     arr = PyArray_FromScalar(self, NULL);
-    if (arr == NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     ret = arr->ob_type->tp_richcompare(arr, other, cmp_op);
     Py_DECREF(arr);
     return ret;
@@ -917,7 +988,9 @@
 {
     PyObject *flagobj;
     flagobj = PyArrayFlags_Type.tp_alloc(&PyArrayFlags_Type, 0);
-    if (flagobj == NULL) return NULL;
+    if (flagobj == NULL) {
+        return NULL;
+    }
     ((PyArrayFlagsObject *)flagobj)->arr = NULL;
     ((PyArrayFlagsObject *)flagobj)->flags = self->flags;
     return flagobj;
@@ -1016,9 +1089,13 @@
     PyObject *inter;
 
     arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
-    if (arr == NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     inter = PyObject_GetAttrString((PyObject *)arr, "__array_interface__");
-    if (inter != NULL) PyDict_SetItemString(inter, "__ref", (PyObject *)arr);
+    if (inter != NULL) {
+        PyDict_SetItemString(inter, "__ref", (PyObject *)arr);
+    }
     Py_DECREF(arr);
     return inter;
 }
@@ -1076,7 +1153,9 @@
     else if (PyArray_IsScalar(self, Object)) {
         PyObject *obj = ((PyObjectScalarObject *)self)->obval;
         ret = PyObject_GetAttrString(obj, "real");
-        if (ret != NULL) return ret;
+        if (ret != NULL) {
+            return ret;
+        }
         PyErr_Clear();
     }
     Py_INCREF(self);
@@ -1094,8 +1173,7 @@
         char *ptr;
         typecode = _realdescr_fromcomplexscalar(self, &typenum);
         ptr = (char *)scalar_value(self, NULL);
-        ret = PyArray_Scalar(ptr + typecode->elsize,
-                typecode, NULL);
+        ret = PyArray_Scalar(ptr + typecode->elsize, typecode, NULL);
     }
     else if (PyArray_IsScalar(self, Object)) {
         PyObject *obj = ((PyObjectScalarObject *)self)->obval;
@@ -1131,7 +1209,9 @@
     PyObject *ret, *arr;
 
     arr = PyArray_FromScalar(self, NULL);
-    if (arr == NULL) return NULL;
+    if (arr == NULL) {
+        return NULL;
+    }
     ret = PyArray_IterNew(arr);
     Py_DECREF(arr);
     return ret;
@@ -1279,10 +1359,11 @@
 
 
 /**begin repeat
-
-#name=tolist, item, tostring, astype, copy, __deepcopy__, searchsorted, view, swapaxes, conj, conjugate, nonzero, flatten, ravel, fill, transpose, newbyteorder#
-*/
-
+ *
+ * #name = tolist, item, tostring, astype, copy, __deepcopy__, searchsorted,
+ *         view, swapaxes, conj, conjugate, nonzero, flatten, ravel, fill,
+ *         transpose, newbyteorder#
+ */
 static PyObject *
 gentype_@name@(PyObject *self, PyObject *args)
 {
@@ -1300,7 +1381,9 @@
 static PyObject *
 gentype_squeeze(PyObject *self, PyObject *args)
 {
-    if (!PyArg_ParseTuple(args, "")) return NULL;
+    if (!PyArg_ParseTuple(args, "")) {
+        return NULL;
+    }
     Py_INCREF(self);
     return self;
 }
@@ -1313,17 +1396,16 @@
 {
     Bool inplace=FALSE;
 
-    if (!PyArg_ParseTuple(args, "|O&", PyArray_BoolConverter, &inplace))
+    if (!PyArg_ParseTuple(args, "|O&", PyArray_BoolConverter, &inplace)) {
         return NULL;
-
+    }
     if (inplace) {
         PyErr_SetString(PyExc_ValueError,
                 "cannot byteswap a scalar in-place");
         return NULL;
     }
     else {
-        /* get the data, copyswap it and pass it to a new Array scalar
-        */
+        /* get the data, copyswap it and pass it to a new Array scalar */
         char *data;
         int numbytes;
         PyArray_Descr *descr;
@@ -1333,8 +1415,13 @@
         numbytes = gentype_getreadbuf(self, 0, (void **)&data);
         descr = PyArray_DescrFromScalar(self);
         newmem = _pya_malloc(descr->elsize);
-        if (newmem == NULL) {Py_DECREF(descr); return PyErr_NoMemory();}
-        else memcpy(newmem, data, descr->elsize);
+        if (newmem == NULL) {
+            Py_DECREF(descr);
+            return PyErr_NoMemory();
+        }
+        else {
+            memcpy(newmem, data, descr->elsize);
+        }
         byte_swap_vector(newmem, 1, descr->elsize);
         new = PyArray_Scalar(newmem, descr, NULL);
         _pya_free(newmem);
@@ -1345,10 +1432,12 @@
 
 
 /**begin repeat
-
-#name=take, getfield, put, repeat, tofile, mean, trace, diagonal, clip, std, var, sum, cumsum, prod, cumprod, compress, sort, argsort, round, argmax, argmin, max, min, ptp, any, all, resize, reshape, choose#
-*/
-
+ *
+ * #name = take, getfield, put, repeat, tofile, mean, trace, diagonal, clip,
+ *         std, var, sum, cumsum, prod, cumprod, compress, sort, argsort,
+ *         round, argmax, argmin, max, min, ptp, any, all, resize, reshape,
+ *         choose#
+ */
 static PyObject *
 gentype_@name@(PyObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1362,7 +1451,9 @@
     PyObject *ret;
 
     ret = gentype_generic_method((PyObject *)self, args, kwds, "getfield");
-    if (!ret) return ret;
+    if (!ret) {
+        return ret;
+    }
     if (PyArray_IsScalar(ret, Generic) &&   \
             (!PyArray_IsScalar(ret, Void))) {
         PyArray_Descr *new;
@@ -1388,7 +1479,7 @@
 static PyObject *
 voidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
 {
-    PyArray_Descr *typecode=NULL;
+    PyArray_Descr *typecode = NULL;
     int offset = 0;
     PyObject *value, *src;
     int mysize;
@@ -1396,8 +1487,7 @@
     static char *kwlist[] = {"value", "dtype", "offset", 0};
 
     if ((self->flags & WRITEABLE) != WRITEABLE) {
-        PyErr_SetString(PyExc_RuntimeError,
-                "Can't write to memory");
+        PyErr_SetString(PyExc_RuntimeError, "Can't write to memory");
         return NULL;
     }
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&|i", kwlist,
@@ -1432,7 +1522,9 @@
     else {
         /* Copy data from value to correct place in dptr */
         src = PyArray_FromAny(value, typecode, 0, 0, CARRAY, NULL);
-        if (src == NULL) return NULL;
+        if (src == NULL) {
+            return NULL;
+        }
         typecode->f->copyswap(dptr, PyArray_DATA(src),
                 !PyArray_ISNBO(self->descr->byteorder),
                 src);
@@ -1446,38 +1538,44 @@
 static PyObject *
 gentype_reduce(PyObject *self, PyObject *NPY_UNUSED(args))
 {
-    PyObject *ret=NULL, *obj=NULL, *mod=NULL;
+    PyObject *ret = NULL, *obj = NULL, *mod = NULL;
     const char *buffer;
     Py_ssize_t buflen;
 
     /* Return a tuple of (callable object, arguments) */
-
     ret = PyTuple_New(2);
-    if (ret == NULL) return NULL;
+    if (ret == NULL) {
+        return NULL;
+    }
     if (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) {
-        Py_DECREF(ret); return NULL;
+        Py_DECREF(ret);
+        return NULL;
     }
     mod = PyImport_ImportModule("numpy.core.multiarray");
-    if (mod == NULL) return NULL;
+    if (mod == NULL) {
+        return NULL;
+    }
     obj = PyObject_GetAttrString(mod, "scalar");
     Py_DECREF(mod);
-    if (obj == NULL) return NULL;
+    if (obj == NULL) {
+        return NULL;
+    }
     PyTuple_SET_ITEM(ret, 0, obj);
     obj = PyObject_GetAttrString((PyObject *)self, "dtype");
     if (PyArray_IsScalar(self, Object)) {
         mod = ((PyObjectScalarObject *)self)->obval;
-        PyTuple_SET_ITEM(ret, 1,
-                Py_BuildValue("NO", obj, mod));
+        PyTuple_SET_ITEM(ret, 1, Py_BuildValue("NO", obj, mod));
     }
     else {
 #ifndef Py_UNICODE_WIDE
-        /* We need to expand the buffer so that we always write
-           UCS4 to disk for pickle of unicode scalars.
-
-           This could be in a unicode_reduce function, but
-           that would require re-factoring.
-           */
-        int alloc=0;
+        /*
+         * We need to expand the buffer so that we always write
+         * UCS4 to disk for pickle of unicode scalars.
+         *
+         * This could be in a unicode_reduce function, but
+         * that would require re-factoring.
+         */
+        int alloc = 0;
         char *tmp;
         int newlen;
 
@@ -1526,13 +1624,16 @@
 static PyObject *
 gentype_dump(PyObject *self, PyObject *args)
 {
-    PyObject *file=NULL;
+    PyObject *file = NULL;
     int ret;
 
-    if (!PyArg_ParseTuple(args, "O", &file))
+    if (!PyArg_ParseTuple(args, "O", &file)) {
         return NULL;
+    }
     ret = PyArray_Dump(self, file, 2);
-    if (ret < 0) return NULL;
+    if (ret < 0) {
+        return NULL;
+    }
     Py_INCREF(Py_None);
     return Py_None;
 }
@@ -1540,15 +1641,17 @@
 static PyObject *
 gentype_dumps(PyObject *self, PyObject *args)
 {
-    if (!PyArg_ParseTuple(args, ""))
+    if (!PyArg_ParseTuple(args, "")) {
         return NULL;
+    }
     return PyArray_Dumps(self, 2);
 }
 
 
 /* setting flags cannot be done for scalars */
 static PyObject *
-gentype_setflags(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args), PyObject *NPY_UNUSED(kwds))
+gentype_setflags(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args),
+        PyObject *NPY_UNUSED(kwds))
 {
     Py_INCREF(Py_None);
     return Py_None;
@@ -1776,7 +1879,9 @@
     }
     flist = self->descr->names;
     m = PyTuple_GET_SIZE(flist);
-    if (n < 0) n += m;
+    if (n < 0) {
+        n += m;
+    }
     if (n < 0 || n >= m) {
         PyErr_Format(PyExc_IndexError, "invalid index (%d)", (int) n);
         return NULL;
@@ -1803,14 +1908,17 @@
     if (PyString_Check(ind) || PyUnicode_Check(ind)) {
         /* look up in fields */
         fieldinfo = PyDict_GetItem(self->descr->fields, ind);
-        if (!fieldinfo) goto fail;
+        if (!fieldinfo) {
+            goto fail;
+        }
         return voidtype_getfield(self, fieldinfo, NULL);
     }
 
     /* try to convert it to a number */
     n = PyArray_PyIntAsIntp(ind);
-    if (error_converting(n)) goto fail;
-
+    if (error_converting(n)) {
+        goto fail;
+    }
     return voidtype_item(self, (Py_ssize_t)n);
 
 fail:
@@ -1833,8 +1941,12 @@
 
     flist = self->descr->names;
     m = PyTuple_GET_SIZE(flist);
-    if (n < 0) n += m;
-    if (n < 0 || n >= m) goto fail;
+    if (n < 0) {
+        n += m;
+    }
+    if (n < 0 || n >= m) {
+        goto fail;
+    }
     fieldinfo = PyDict_GetItem(self->descr->fields,
             PyTuple_GET_ITEM(flist, n));
     newtup = Py_BuildValue("(OOO)", val,
@@ -1842,7 +1954,9 @@
             PyTuple_GET_ITEM(fieldinfo, 1));
     res = voidtype_setfield(self, newtup, NULL);
     Py_DECREF(newtup);
-    if (!res) return -1;
+    if (!res) {
+        return -1;
+    }
     Py_DECREF(res);
     return 0;
 
@@ -1868,20 +1982,26 @@
     if (PyString_Check(ind) || PyUnicode_Check(ind)) {
         /* look up in fields */
         fieldinfo = PyDict_GetItem(self->descr->fields, ind);
-        if (!fieldinfo) goto fail;
+        if (!fieldinfo) {
+            goto fail;
+        }
         newtup = Py_BuildValue("(OOO)", val,
                 PyTuple_GET_ITEM(fieldinfo, 0),
                 PyTuple_GET_ITEM(fieldinfo, 1));
         res = voidtype_setfield(self, newtup, NULL);
         Py_DECREF(newtup);
-        if (!res) return -1;
+        if (!res) {
+            return -1;
+        }
         Py_DECREF(res);
         return 0;
     }
 
     /* try to convert it to a number */
     n = PyArray_PyIntAsIntp(ind);
-    if (error_converting(n)) goto fail;
+    if (error_converting(n)) {
+        goto fail;
+    }
     return voidtype_ass_item(self, (Py_ssize_t)n, val);
 
 fail:
@@ -1891,35 +2011,35 @@
 
 static PyMappingMethods voidtype_as_mapping = {
 #if PY_VERSION_HEX >= 0x02050000
-    (lenfunc)voidtype_length,                   /*mp_length*/
+    (lenfunc)voidtype_length,                    /*mp_length*/
 #else
-    (inquiry)voidtype_length,                   /*mp_length*/
+    (inquiry)voidtype_length,                    /*mp_length*/
 #endif
-    (binaryfunc)voidtype_subscript,             /*mp_subscript*/
-    (objobjargproc)voidtype_ass_subscript,      /*mp_ass_subscript*/
+    (binaryfunc)voidtype_subscript,              /*mp_subscript*/
+    (objobjargproc)voidtype_ass_subscript,       /*mp_ass_subscript*/
 };
 
 
 static PySequenceMethods voidtype_as_sequence = {
 #if PY_VERSION_HEX >= 0x02050000
-    (lenfunc)voidtype_length,                   /*sq_length*/
-    0,                                          /*sq_concat*/
-    0,                                          /*sq_repeat*/
-    (ssizeargfunc)voidtype_item,                /*sq_item*/
-    0,                                          /*sq_slice*/
-    (ssizeobjargproc)voidtype_ass_item,         /*sq_ass_item*/
+    (lenfunc)voidtype_length,                    /*sq_length*/
+    0,                                           /*sq_concat*/
+    0,                                           /*sq_repeat*/
+    (ssizeargfunc)voidtype_item,                 /*sq_item*/
+    0,                                           /*sq_slice*/
+    (ssizeobjargproc)voidtype_ass_item,          /*sq_ass_item*/
 #else
-        (inquiry)voidtype_length,               /*sq_length*/
-    0,                                          /*sq_concat*/
-    0,                                          /*sq_repeat*/
-    (intargfunc)voidtype_item,                  /*sq_item*/
-    0,                                          /*sq_slice*/
-    (intobjargproc)voidtype_ass_item,           /*sq_ass_item*/
+        (inquiry)voidtype_length,                /*sq_length*/
+    0,                                           /*sq_concat*/
+    0,                                           /*sq_repeat*/
+    (intargfunc)voidtype_item,                   /*sq_item*/
+    0,                                           /*sq_slice*/
+    (intobjargproc)voidtype_ass_item,            /*sq_ass_item*/
 #endif
-    0,                                          /* ssq_ass_slice */
-    0,                                          /* sq_contains */
-    0,                                          /* sq_inplace_concat */
-    0,                                          /* sq_inplace_repeat */
+    0,                                           /* ssq_ass_slice */
+    0,                                           /* sq_contains */
+    0,                                           /* sq_inplace_concat */
+    0,                                           /* sq_inplace_repeat */
 };
 
 
@@ -1970,9 +2090,10 @@
 static Py_ssize_t
 gentype_getcharbuf(PyObject *self, Py_ssize_t segment, constchar **ptrptr)
 {
-    if (PyArray_IsScalar(self, String) ||   \
-            PyArray_IsScalar(self, Unicode))
+    if (PyArray_IsScalar(self, String) ||
+            PyArray_IsScalar(self, Unicode)) {
         return gentype_getreadbuf(self, segment, (void **)ptrptr);
+    }
     else {
         PyErr_SetString(PyExc_TypeError,
                 "Non-character array cannot be interpreted "\
@@ -1983,10 +2104,10 @@
 
 
 static PyBufferProcs gentype_as_buffer = {
-    gentype_getreadbuf,         /*bf_getreadbuffer*/
-    NULL,                       /*bf_getwritebuffer*/
-    gentype_getsegcount,        /*bf_getsegcount*/
-    gentype_getcharbuf,         /*bf_getcharbuffer*/
+    gentype_getreadbuf,                          /* bf_getreadbuffer*/
+    NULL,                                        /* bf_getwritebuffer*/
+    gentype_getsegcount,                         /* bf_getsegcount*/
+    gentype_getcharbuf,                          /* bf_getcharbuffer*/
 };
 
 
@@ -1995,69 +2116,70 @@
 
 static PyTypeObject PyGenericArrType_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                          /*ob_size*/
-    "numpy.generic",            /*tp_name*/
-    sizeof(PyObject),           /*tp_basicsize*/
-    0,   /* tp_itemsize */
+    0,                                           /* ob_size*/
+    "numpy.generic",                             /* tp_name*/
+    sizeof(PyObject),                            /* tp_basicsize*/
+    0,                                           /* tp_itemsize */
     /* methods */
-    0,   /* tp_dealloc */
-    0,   /* tp_print */
-    0,   /* tp_getattr */
-    0,   /* tp_setattr */
-    0,   /* tp_compare */
-    0,   /* tp_repr */
-    0,   /* tp_as_number */
-    0,   /* tp_as_sequence */
-    0,   /* tp_as_mapping */
-    0,   /* tp_hash */
-    0,   /* tp_call */
-    0,   /* tp_str */
-    0,   /* tp_getattro */
-    0,   /* tp_setattro */
-    0,   /* tp_as_buffer */
-    0,   /* tp_flags */
-    0,   /* tp_doc */
-    0,   /* tp_traverse */
-    0,   /* tp_clear */
-    0,   /* tp_richcompare */
-    0,   /* tp_weaklistoffset */
-    0,   /* tp_iter */ 
-    0,   /* tp_iternext */ 
-    0,   /* tp_methods */
-    0,   /* tp_members */
-    0,   /* tp_getset */
-    0,   /* tp_base */
-    0,   /* tp_dict */
-    0,   /* tp_descr_get */
-    0,   /* tp_descr_set */
-    0,   /* tp_dictoffset */
-    0,   /* tp_init */
-    0,   /* tp_alloc */
-    0,   /* tp_new */
-    0,   /* tp_free */
-    0,   /* tp_is_gc */
-    0,   /* tp_bases */
-    0,   /* tp_mro */
-    0,   /* tp_cache */
-    0,   /* tp_subclasses */
-    0,   /* tp_weaklist */
-    0,   /* tp_del */
+    0,                                           /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    0,                                           /* tp_as_sequence */
+    0,                                           /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    0,                                           /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    0,                                           /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    0,                                           /* tp_iternext */
+    0,                                           /* tp_methods */
+    0,                                           /* tp_members */
+    0,                                           /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    0,                                           /* tp_init */
+    0,                                           /* tp_alloc */
+    0,                                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 
 #ifdef COUNT_ALLOCS
-	/* these must be last and never explicitly initialized */
-    0, /* tp_allocs */
-    0, /* tp_frees */
-    0, /* tp_maxalloc */
-    0, /* tp_prev */
-    0, /* *tp_next */
+    /* these must be last and never explicitly initialized */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 
 static void
 void_dealloc(PyVoidScalarObject *v)
 {
-    if (v->flags & OWNDATA)
+    if (v->flags & OWNDATA) {
         PyDataMem_FREE(v->obval);
+    }
     Py_XDECREF(v->descr);
     Py_XDECREF(v->base);
     v->ob_type->tp_free(v);
@@ -2070,11 +2192,13 @@
     v->ob_type->tp_free(v);
 }
 
-/* string and unicode inherit from Python Type first and so GET_ITEM is different to get to the Python Type.
+/*
+ * string and unicode inherit from Python Type first and so GET_ITEM
+ * is different to get to the Python Type.
+ *
+ * ok is a work-around for a bug in complex_new that doesn't allocate
+ *  memory from the sub-types memory allocator.
  */
-/* ok is a work-around for a bug in complex_new that doesn't allocate
-   memory from the sub-types memory allocator.
-*/
 
 #define _WORK(num)  \
     if (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) { \
@@ -2093,14 +2217,18 @@
 #define _WORKz _WORK(0)
 #define _WORK0
 
-/**begin repeat1
-#name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object#
-#TYPE=BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT#
-#work=0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,z,z,0#
-#default=0*16,1*2,2#
-*/
+/**begin repeat
+ * #name = byte, short, int, long, longlong, ubyte, ushort, uint, ulong,
+ *         ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble,
+ *         string, unicode, object#
+ * #TYPE = BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG,
+ *         ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE,
+ *         STRING, UNICODE, OBJECT#
+ * #work = 0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,z,z,0#
+ * #default = 0*16,1*2,2#
+ */
 
-#define _NPY_UNUSED2_1 
+#define _NPY_UNUSED2_1
 #define _NPY_UNUSED2_z
 #define _NPY_UNUSED2_0 NPY_UNUSED
 #define _NPY_UNUSED1_0
@@ -2119,17 +2247,20 @@
     void *dest, *src;
 #endif
 
-    /* allow base-class (if any) to do conversion */
-    /* If successful, this will jump to finish: */
+    /*
+     * allow base-class (if any) to do conversion
+     * If successful, this will jump to finish:
+     */
     _WORK@work@
 
     if (!PyArg_ParseTuple(args, "|O", &obj)) {
         return NULL;
     }
     typecode = PyArray_DescrFromType(PyArray_@TYPE@);
-    /* typecode is new reference and stolen by
-       PyArray_FromAny but not PyArray_Scalar
-    */
+    /*
+     * typecode is new reference and stolen by
+     * PyArray_FromAny but not PyArray_Scalar
+     */
     if (obj == NULL) {
 #if @default@ == 0
         char *mem = malloc(sizeof(@name@));
@@ -2140,30 +2271,32 @@
 #elif @default@ == 1
         robj = PyArray_Scalar(NULL, typecode, NULL);
 #elif @default@ == 2
-	Py_INCREF(Py_None);
-	robj = Py_None;
+        Py_INCREF(Py_None);
+        robj = Py_None;
 #endif
-	Py_DECREF(typecode);
+        Py_DECREF(typecode);
         goto finish;
     }
 
-    /* It is expected at this point that robj is a PyArrayScalar 
-       (even for Object Data Type)
-    */
+    /*
+     * It is expected at this point that robj is a PyArrayScalar
+     * (even for Object Data Type)
+     */
     arr = PyArray_FromAny(obj, typecode, 0, 0, FORCECAST, NULL);
     if ((arr == NULL) || (PyArray_NDIM(arr) > 0)) {
         return arr;
     }
     /* 0-d array */
     robj = PyArray_ToScalar(PyArray_DATA(arr), (NPY_AO *)arr);
-    Py_DECREF(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 
-		       */
+    /*
+     * In OBJECT case, robj is no longer a
+     * PyArrayScalar at this point but the
+     * remaining code assumes it is
+     */
+#if @default@ == 2
     return robj;
 #else
     /* Normal return */
@@ -2171,9 +2304,11 @@
         return robj;
     }
 
-    /* This return path occurs when the requested type is not created
-       but another scalar object is created instead (i.e. when
-       the base-class does the conversion in _WORK macro) */
+    /*
+     * This return path occurs when the requested type is not created
+     * but another scalar object is created instead (i.e. when
+     * the base-class does the conversion in _WORK macro)
+     */
 
     /* Need to allocate new type and copy data-area over */
     if (type->tp_itemsize) {
@@ -2196,7 +2331,7 @@
     *((npy_@name@ *)dest) = *((npy_@name@ *)src);
 #elif @default@ == 1 /* unicode and strings */
     if (itemsize == 0) { /* unicode */
-	itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE);
+        itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE);
     }
     memcpy(dest, src, itemsize);
     /* @default@ == 2 won't get here */
@@ -2216,16 +2351,21 @@
 static PyObject *
 bool_arrtype_new(PyTypeObject *NPY_UNUSED(type), PyObject *args, PyObject *NPY_UNUSED(kwds))
 {
-    PyObject *obj=NULL;
+    PyObject *obj = NULL;
     PyObject *arr;
 
-    if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL;
-    if (obj == NULL)
+    if (!PyArg_ParseTuple(args, "|O", &obj)) {
+        return NULL;
+    }
+    if (obj == NULL) {
         PyArrayScalar_RETURN_FALSE;
-    if (obj == Py_False)
+    }
+    if (obj == Py_False) {
         PyArrayScalar_RETURN_FALSE;
-    if (obj == Py_True)
+    }
+    if (obj == Py_True) {
         PyArrayScalar_RETURN_TRUE;
+    }
     arr = PyArray_FROM_OTF(obj, PyArray_BOOL, FORCECAST);
     if (arr && 0 == PyArray_NDIM(arr)) {
         Bool val = *((Bool *)PyArray_DATA(arr));
@@ -2238,27 +2378,30 @@
 static PyObject *
 bool_arrtype_and(PyObject *a, PyObject *b)
 {
-    if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool))
+    if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) {
         PyArrayScalar_RETURN_BOOL_FROM_LONG
             ((a == PyArrayScalar_True)&(b == PyArrayScalar_True));
+    }
     return PyGenericArrType_Type.tp_as_number->nb_and(a, b);
 }
 
 static PyObject *
 bool_arrtype_or(PyObject *a, PyObject *b)
 {
-    if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool))
+    if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) {
         PyArrayScalar_RETURN_BOOL_FROM_LONG
             ((a == PyArrayScalar_True)|(b == PyArrayScalar_True));
+    }
     return PyGenericArrType_Type.tp_as_number->nb_or(a, b);
 }
 
 static PyObject *
 bool_arrtype_xor(PyObject *a, PyObject *b)
 {
-    if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool))
+    if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) {
         PyArrayScalar_RETURN_BOOL_FROM_LONG
             ((a == PyArrayScalar_True)^(b == PyArrayScalar_True));
+    }
     return PyGenericArrType_Type.tp_as_number->nb_xor(a, b);
 }
 
@@ -2270,10 +2413,13 @@
 
 #if PY_VERSION_HEX >= 0x02050000
 /**begin repeat
-#name=byte, short, int, long, ubyte, ushort, longlong, uint, ulong, ulonglong#
-#Name=Byte, Short, Int, Long, UByte, UShort, LongLong, UInt, ULong, ULongLong#
-#type=PyInt_FromLong*6, PyLong_FromLongLong*1, PyLong_FromUnsignedLong*2, PyLong_FromUnsignedLongLong#
-*/
+ * #name = byte, short, int, long, ubyte, ushort, longlong, uint, ulong,
+ *         ulonglong#
+ * #Name = Byte, Short, Int, Long, UByte, UShort, LongLong, UInt, ULong,
+ *         ULongLong#
+ * #type = PyInt_FromLong*6, PyLong_FromLongLong*1, PyLong_FromUnsignedLong*2,
+ *         PyLong_FromUnsignedLongLong#
+ */
 static PyNumberMethods @name@_arrtype_as_number;
 static PyObject *
 @name@_index(PyObject *self)
@@ -2281,6 +2427,7 @@
     return @type@(PyArrayScalar_VAL(self, @Name@));
 }
 /**end repeat**/
+
 static PyObject *
 bool_index(PyObject *a)
 {
@@ -2290,50 +2437,50 @@
 
 /* Arithmetic methods -- only so we can override &, |, ^. */
 static PyNumberMethods bool_arrtype_as_number = {
-    0,                                      /* nb_add */
-    0,                                      /* nb_subtract */
-    0,                                      /* nb_multiply */
-    0,                                      /* nb_divide */
-    0,                                      /* nb_remainder */
-    0,                                      /* nb_divmod */
-    0,                                      /* nb_power */
-    0,                                      /* nb_negative */
-    0,                                      /* nb_positive */
-    0,                                      /* nb_absolute */
-    (inquiry)bool_arrtype_nonzero,          /* nb_nonzero */
-    0,                                      /* nb_invert */
-    0,                                      /* nb_lshift */
-    0,                                      /* nb_rshift */
-    (binaryfunc)bool_arrtype_and,           /* nb_and */
-    (binaryfunc)bool_arrtype_xor,           /* nb_xor */
-    (binaryfunc)bool_arrtype_or,            /* nb_or */
-    0,	/* nb_coerce */
-    0,  /* nb_int */
-    0,  /* nb_long */
-    0,  /* nb_float */
-    0,  /* nb_oct */
-    0,  /* nb_hex */
+    0,                                           /* nb_add */
+    0,                                           /* nb_subtract */
+    0,                                           /* nb_multiply */
+    0,                                           /* nb_divide */
+    0,                                           /* nb_remainder */
+    0,                                           /* nb_divmod */
+    0,                                           /* nb_power */
+    0,                                           /* nb_negative */
+    0,                                           /* nb_positive */
+    0,                                           /* nb_absolute */
+    (inquiry)bool_arrtype_nonzero,               /* nb_nonzero */
+    0,                                           /* nb_invert */
+    0,                                           /* nb_lshift */
+    0,                                           /* nb_rshift */
+    (binaryfunc)bool_arrtype_and,                /* nb_and */
+    (binaryfunc)bool_arrtype_xor,                /* nb_xor */
+    (binaryfunc)bool_arrtype_or,                 /* nb_or */
+    0,                                           /* nb_coerce */
+    0,                                           /* nb_int */
+    0,                                           /* nb_long */
+    0,                                           /* nb_float */
+    0,                                           /* nb_oct */
+    0,                                           /* nb_hex */
     /* Added in release 2.0 */
-    0, 	/* nb_inplace_add */
-    0,	/* nb_inplace_subtract */
-    0,	/* nb_inplace_multiply */
-    0,	/* nb_inplace_divide */
-    0,	/* nb_inplace_remainder */
-    0,	/* nb_inplace_power */
-    0,	/* nb_inplace_lshift */
-    0,	/* nb_inplace_rshift */
-    0,	/* nb_inplace_and */
-    0,	/* nb_inplace_xor */
-    0,	/* nb_inplace_or */
+    0,                                           /* nb_inplace_add */
+    0,                                           /* nb_inplace_subtract */
+    0,                                           /* nb_inplace_multiply */
+    0,                                           /* nb_inplace_divide */
+    0,                                           /* nb_inplace_remainder */
+    0,                                           /* nb_inplace_power */
+    0,                                           /* nb_inplace_lshift */
+    0,                                           /* nb_inplace_rshift */
+    0,                                           /* nb_inplace_and */
+    0,                                           /* nb_inplace_xor */
+    0,                                           /* nb_inplace_or */
     /* Added in release 2.2 */
     /* The following require the Py_TPFLAGS_HAVE_CLASS flag */
-    0, 	/* nb_floor_divide */
-    0, 	/* nb_true_divide */
-    0, 	/* nb_inplace_floor_divide */
-    0, 	/* nb_inplace_true_divide */
+    0,                                           /* nb_floor_divide */
+    0,                                           /* nb_true_divide */
+    0,                                           /* nb_inplace_floor_divide */
+    0,                                           /* nb_inplace_true_divide */
     /* Added in release 2.5 */
 #if PY_VERSION_HEX >= 0x02050000
-    0, 	/* nb_index */
+    0,                                           /* nb_index */
 #endif
 };
 
@@ -2341,18 +2488,20 @@
 void_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *NPY_UNUSED(kwds))
 {
     PyObject *obj, *arr;
-    ulonglong memu=1;
-    PyObject *new=NULL;
+    ulonglong memu = 1;
+    PyObject *new = NULL;
     char *destptr;
 
-    if (!PyArg_ParseTuple(args, "O", &obj)) return NULL;
-    /* For a VOID scalar first see if obj is an integer or long
-       and create new memory of that size (filled with 0) for the scalar
-       */
-
-    if (PyLong_Check(obj) || PyInt_Check(obj) || \
+    if (!PyArg_ParseTuple(args, "O", &obj)) {
+        return NULL;
+    }
+    /*
+     * For a VOID scalar first see if obj is an integer or long
+     * and create new memory of that size (filled with 0) for the scalar
+     */
+    if (PyLong_Check(obj) || PyInt_Check(obj) ||
             PyArray_IsScalar(obj, Integer) ||
-            (PyArray_Check(obj) && PyArray_NDIM(obj)==0 &&      \
+            (PyArray_Check(obj) && PyArray_NDIM(obj)==0 &&
              PyArray_ISINTEGER(obj))) {
         new = obj->ob_type->tp_as_number->nb_long(obj);
     }
@@ -2368,7 +2517,9 @@
             return NULL;
         }
         destptr = PyDataMem_NEW((int) memu);
-        if (destptr == NULL) return PyErr_NoMemory();
+        if (destptr == NULL) {
+            return PyErr_NoMemory();
+        }
         ret = type->tp_alloc(type, 0);
         if (ret == NULL) {
             PyDataMem_FREE(destptr);
@@ -2376,8 +2527,8 @@
         }
         ((PyVoidScalarObject *)ret)->obval = destptr;
         ((PyVoidScalarObject *)ret)->ob_size = (int) memu;
-        ((PyVoidScalarObject *)ret)->descr = \
-                                             PyArray_DescrNewFromType(PyArray_VOID);
+        ((PyVoidScalarObject *)ret)->descr =
+            PyArray_DescrNewFromType(PyArray_VOID);
         ((PyVoidScalarObject *)ret)->descr->elsize = (int) memu;
         ((PyVoidScalarObject *)ret)->flags = BEHAVED | OWNDATA;
         ((PyVoidScalarObject *)ret)->base = NULL;
@@ -2393,8 +2544,8 @@
 /****************  Define Hash functions ********************/
 
 /**begin repeat
-#lname=bool,ubyte,ushort#
-#name=Bool,UByte, UShort#
+ * #lname = bool,ubyte,ushort#
+ * #name = Bool,UByte, UShort#
  */
 static long
 @lname@_arrtype_hash(PyObject *obj)
@@ -2404,14 +2555,16 @@
 /**end repeat**/
 
 /**begin repeat
-#lname=byte,short,uint,ulong#
-#name=Byte,Short,UInt,ULong#
+ * #lname=byte,short,uint,ulong#
+ * #name=Byte,Short,UInt,ULong#
  */
 static long
 @lname@_arrtype_hash(PyObject *obj)
 {
     long x = (long)(((Py@name@ScalarObject *)obj)->obval);
-    if (x == -1) x=-2;
+    if (x == -1) {
+        x = -2;
+    }
     return x;
 }
 /**end repeat**/
@@ -2421,16 +2574,18 @@
 int_arrtype_hash(PyObject *obj)
 {
     long x = (long)(((PyIntScalarObject *)obj)->obval);
-    if (x == -1) x=-2;
+    if (x == -1) {
+        x = -2;
+    }
     return x;
 }
 #endif
 
 /**begin repeat
-#char=,u#
-#Char=,U#
-#ext=&& (x >= LONG_MIN),#
-*/
+ * #char = ,u#
+ * #Char = ,U#
+ * #ext = && (x >= LONG_MIN),#
+ */
 #if SIZEOF_LONG != SIZEOF_LONGLONG
 /* we assume SIZEOF_LONGLONG=2*SIZEOF_LONG */
 static long
@@ -2451,7 +2606,9 @@
         both.v = x;
         y = both.hashvals[0] + (1000003)*both.hashvals[1];
     }
-    if (y == -1) y = -2;
+    if (y == -1) {
+        y = -2;
+    }
     return y;
 }
 #endif
@@ -2462,7 +2619,9 @@
 ulonglong_arrtype_hash(PyObject *obj)
 {
     long x = (long)(((PyULongLongScalarObject *)obj)->obval);
-    if (x == -1) x=-2;
+    if (x == -1) {
+        x = -2;
+    }
     return x;
 }
 #endif
@@ -2470,9 +2629,10 @@
 
 
 /* Wrong thing to do for longdouble, but....*/
+
 /**begin repeat
-#lname=float, longdouble#
-#name=Float, LongDouble#
+ * #lname = float, longdouble#
+ * #name = Float, LongDouble#
  */
 static long
 @lname@_arrtype_hash(PyObject *obj)
@@ -2485,16 +2645,21 @@
 c@lname@_arrtype_hash(PyObject *obj)
 {
     long hashreal, hashimag, combined;
-    hashreal = _Py_HashDouble((double)                              \
+    hashreal = _Py_HashDouble((double)
             (((PyC@name@ScalarObject *)obj)->obval).real);
 
-    if (hashreal == -1) return -1;
-    hashimag = _Py_HashDouble((double)                              \
+    if (hashreal == -1) {
+        return -1;
+    }
+    hashimag = _Py_HashDouble((double)
             (((PyC@name@ScalarObject *)obj)->obval).imag);
-    if (hashimag == -1) return -1;
-
+    if (hashimag == -1) {
+        return -1;
+    }
     combined = hashreal + 1000003 * hashimag;
-    if (combined == -1) combined = -2;
+    if (combined == -1) {
+        combined = -2;
+    }
     return combined;
 }
 /**end repeat**/
@@ -2520,7 +2685,9 @@
     /* first look in object and then hand off to generic type */
 
     res = PyObject_GenericGetAttr(obj->obval, attr);
-    if (res) return res;
+    if (res) {
+        return res;
+    }
     PyErr_Clear();
     return  PyObject_GenericGetAttr((PyObject *)obj, attr);
 }
@@ -2531,7 +2698,9 @@
     /* first look in object and then hand off to generic type */
 
     res = PyObject_GenericSetAttr(obj->obval, attr, val);
-    if (res >= 0) return res;
+    if (res >= 0) {
+        return res;
+    }
     PyErr_Clear();
     return PyObject_GenericSetAttr((PyObject *)obj, attr, val);
 }
@@ -2587,27 +2756,27 @@
 
 static PySequenceMethods object_arrtype_as_sequence = {
 #if PY_VERSION_HEX >= 0x02050000
-    (lenfunc)object_arrtype_length,                     /*sq_length*/
-    (binaryfunc)object_arrtype_concat,                  /*sq_concat*/
-    (ssizeargfunc)object_arrtype_repeat,                /*sq_repeat*/
-    0,                                                  /*sq_item*/
-    0,                                                  /*sq_slice*/
-    0,                                                  /* sq_ass_item */
-    0,                                                  /* sq_ass_slice */
-    (objobjproc)object_arrtype_contains,                /* sq_contains */
-    (binaryfunc)object_arrtype_inplace_concat,          /* sq_inplace_concat */
-    (ssizeargfunc)object_arrtype_inplace_repeat,        /* sq_inplace_repeat */
+    (lenfunc)object_arrtype_length,              /*sq_length*/
+    (binaryfunc)object_arrtype_concat,           /*sq_concat*/
+    (ssizeargfunc)object_arrtype_repeat,         /*sq_repeat*/
+    0,                                           /*sq_item*/
+    0,                                           /*sq_slice*/
+    0,                                           /* sq_ass_item */
+    0,                                           /* sq_ass_slice */
+    (objobjproc)object_arrtype_contains,         /* sq_contains */
+    (binaryfunc)object_arrtype_inplace_concat,   /* sq_inplace_concat */
+    (ssizeargfunc)object_arrtype_inplace_repeat, /* sq_inplace_repeat */
 #else
-    (inquiry)object_arrtype_length,                     /*sq_length*/
-    (binaryfunc)object_arrtype_concat,                  /*sq_concat*/
-    (intargfunc)object_arrtype_repeat,                  /*sq_repeat*/
-    0,                                                  /*sq_item*/
-    0,                                                  /*sq_slice*/
-    0,                                                  /* sq_ass_item */
-    0,                                                  /* sq_ass_slice */
-    (objobjproc)object_arrtype_contains,                /* sq_contains */
-    (binaryfunc)object_arrtype_inplace_concat,          /* sq_inplace_concat */
-    (intargfunc)object_arrtype_inplace_repeat,          /* sq_inplace_repeat */
+    (inquiry)object_arrtype_length,              /*sq_length*/
+    (binaryfunc)object_arrtype_concat,           /*sq_concat*/
+    (intargfunc)object_arrtype_repeat,           /*sq_repeat*/
+    0,                                           /*sq_item*/
+    0,                                           /*sq_slice*/
+    0,                                           /* sq_ass_item */
+    0,                                           /* sq_ass_slice */
+    (objobjproc)object_arrtype_contains,         /* sq_contains */
+    (binaryfunc)object_arrtype_inplace_concat,   /* sq_inplace_concat */
+    (intargfunc)object_arrtype_inplace_repeat,   /* sq_inplace_repeat */
 #endif
 };
 
@@ -2630,14 +2799,14 @@
     int cnt;
     PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer;
 
-    if (pb == NULL || \
-            pb->bf_getsegcount == NULL || \
-            (cnt = (*pb->bf_getsegcount)(self->obval, &newlen)) != 1)
+    if (pb == NULL ||
+            pb->bf_getsegcount == NULL ||
+            (cnt = (*pb->bf_getsegcount)(self->obval, &newlen)) != 1) {
         return 0;
-
-    if (lenp)
+    }
+    if (lenp) {
         *lenp = newlen;
-
+    }
     return cnt;
 }
 
@@ -2646,14 +2815,13 @@
 {
     PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer;
 
-    if (pb == NULL || \
+    if (pb == NULL ||
             pb->bf_getreadbuffer == NULL ||
             pb->bf_getsegcount == NULL) {
         PyErr_SetString(PyExc_TypeError,
                 "expected a readable buffer object");
         return -1;
     }
-
     return (*pb->bf_getreadbuffer)(self->obval, segment, ptrptr);
 }
 
@@ -2662,14 +2830,13 @@
 {
     PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer;
 
-    if (pb == NULL || \
+    if (pb == NULL ||
             pb->bf_getwritebuffer == NULL ||
             pb->bf_getsegcount == NULL) {
         PyErr_SetString(PyExc_TypeError,
                 "expected a writeable buffer object");
         return -1;
     }
-
     return (*pb->bf_getwritebuffer)(self->obval, segment, ptrptr);
 }
 
@@ -2679,14 +2846,13 @@
 {
     PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer;
 
-    if (pb == NULL || \
+    if (pb == NULL ||
             pb->bf_getcharbuffer == NULL ||
             pb->bf_getsegcount == NULL) {
         PyErr_SetString(PyExc_TypeError,
                 "expected a character buffer object");
         return -1;
     }
-
     return (*pb->bf_getcharbuffer)(self->obval, segment, ptrptr);
 }
 
@@ -2707,64 +2873,64 @@
 static PyObject *
 object_arrtype_call(PyObjectScalarObject *obj, PyObject *args, PyObject *kwds)
 {
-        return PyObject_Call(obj->obval, args, kwds);
+    return PyObject_Call(obj->obval, args, kwds);
 }
 
 static PyTypeObject PyObjectArrType_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                        /*ob_size*/
-    "numpy.object_",                          /*tp_name*/
-    sizeof(PyObjectScalarObject),             /*tp_basicsize*/
-    0,                                        /* tp_itemsize */
-    (destructor)object_arrtype_dealloc,       /* tp_dealloc */
-    0,                                        /* tp_print */
-    0,                                        /* tp_getattr */
-    0,                                        /* tp_setattr */
-    0,                                        /* tp_compare */
-    0,                                        /* tp_repr */
-    0,                                        /* tp_as_number */
-    &object_arrtype_as_sequence,              /* tp_as_sequence */
-    &object_arrtype_as_mapping,               /* tp_as_mapping */
-    0,                                        /* tp_hash */
-    (ternaryfunc)object_arrtype_call,         /* tp_call */
-    0,                                        /* tp_str */
-    (getattrofunc)object_arrtype_getattro,    /* tp_getattro */
-    (setattrofunc)object_arrtype_setattro,    /* tp_setattro */
-    &object_arrtype_as_buffer,                /* tp_as_buffer */
-    0,                                        /* tp_flags */
-    0,   				      /* tp_doc */
-    0,   				      /* tp_traverse */
-    0,   				      /* tp_clear */
-    0,   				      /* tp_richcompare */
-    0,   				      /* tp_weaklistoffset */
-    0,   				      /* tp_iter */ 
-    0,   				      /* tp_iternext */ 
-    0,   				      /* tp_methods */
-    0,   				      /* tp_members */
-    0,   				      /* tp_getset */
-    0,   				      /* tp_base */
-    0,   				      /* tp_dict */
-    0,   				      /* tp_descr_get */
-    0,   				      /* tp_descr_set */
-    0,   				      /* tp_dictoffset */
-    0,   				      /* tp_init */
-    0,   				      /* tp_alloc */
-    0,   				      /* tp_new */
-    0,   				      /* tp_free */
-    0,   				      /* tp_is_gc */
-    0,   				      /* tp_bases */
-    0,   				      /* tp_mro */
-    0,   				      /* tp_cache */
-    0,   				      /* tp_subclasses */
-    0,   				      /* tp_weaklist */
-    0,   				      /* tp_del */
+    0,                                           /* ob_size*/
+    "numpy.object_",                             /* tp_name*/
+    sizeof(PyObjectScalarObject),                /* tp_basicsize*/
+    0,                                           /* tp_itemsize */
+    (destructor)object_arrtype_dealloc,          /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    &object_arrtype_as_sequence,                 /* tp_as_sequence */
+    &object_arrtype_as_mapping,                  /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    (ternaryfunc)object_arrtype_call,            /* tp_call */
+    0,                                           /* tp_str */
+    (getattrofunc)object_arrtype_getattro,       /* tp_getattro */
+    (setattrofunc)object_arrtype_setattro,       /* tp_setattro */
+    &object_arrtype_as_buffer,                   /* tp_as_buffer */
+    0,                                           /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    0,                                           /* tp_iternext */
+    0,                                           /* tp_methods */
+    0,                                           /* tp_members */
+    0,                                           /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    0,                                           /* tp_init */
+    0,                                           /* tp_alloc */
+    0,                                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 #ifdef COUNT_ALLOCS
     /* these must be last and never explicitly initialized */
-    0, 					      /* tp_allocs */
-    0, 					      /* tp_frees */
-    0, 					      /* tp_maxalloc */
-    0, 					      /* tp_prev */
-    0, 					      /* *tp_next */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 
@@ -2778,12 +2944,12 @@
 static PyObject *
 gen_arrtype_subscript(PyObject *self, PyObject *key)
 {
-    /* Only [...], [...,<???>], [<???>, ...],
-       is allowed for indexing a scalar
-
-       These return a new N-d array with a copy of
-       the data where N is the number of None's in <???>.
-
+    /*
+     * Only [...], [...,<???>], [<???>, ...],
+     * is allowed for indexing a scalar
+     *
+     * These return a new N-d array with a copy of
+     * the data where N is the number of None's in <???>.
      */
     PyObject *res, *ret;
     int N;
@@ -2797,19 +2963,19 @@
                 "invalid index to scalar variable.");
         return NULL;
     }
-
-    if (key == Py_Ellipsis)
+    if (key == Py_Ellipsis) {
         return res;
-
+    }
     if (key == Py_None) {
         ret = add_new_axes_0d((PyArrayObject *)res, 1);
         Py_DECREF(res);
         return ret;
     }
     /* Must be a Tuple */
-
     N = count_new_axes_0d(key);
-    if (N < 0) return NULL;
+    if (N < 0) {
+        return NULL;
+    }
     ret = add_new_axes_0d((PyArrayObject *)res, N);
     Py_DECREF(res);
     return ret;
@@ -2817,74 +2983,75 @@
 
 
 /**begin repeat
- * #name=bool, string, unicode, void#
- * #NAME=Bool, String, Unicode, Void#
- * #ex=_,_,_,#
+ * #name = bool, string, unicode, void#
+ * #NAME = Bool, String, Unicode, Void#
+ * #ex = _,_,_,#
  */
 static PyTypeObject Py@NAME@ArrType_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                        /*ob_size*/
-    "numpy.@name@@ex@",                       /*tp_name*/
-    sizeof(Py@NAME@ScalarObject),             /*tp_basicsize*/
-    0,                                        /* tp_itemsize */
-    0,       				      /* tp_dealloc */
-    0,                                        /* tp_print */
-    0,                                        /* tp_getattr */
-    0,                                        /* tp_setattr */
-    0,                                        /* tp_compare */
-    0,                                        /* tp_repr */
-    0,                                        /* tp_as_number */
-    0,              			      /* tp_as_sequence */
-    0,               			      /* tp_as_mapping */
-    0,                                        /* tp_hash */
-    0,         				      /* tp_call */
-    0,                                        /* tp_str */
-    0,					      /* tp_getattro */
-    0,					      /* tp_setattro */
-    0,					      /* tp_as_buffer */
-    0,                                        /* tp_flags */
-    0,   				      /* tp_doc */
-    0,   				      /* tp_traverse */
-    0,   				      /* tp_clear */
-    0,   				      /* tp_richcompare */
-    0,   				      /* tp_weaklistoffset */
-    0,   				      /* tp_iter */ 
-    0,   				      /* tp_iternext */ 
-    0,   				      /* tp_methods */
-    0,   				      /* tp_members */
-    0,   				      /* tp_getset */
-    0,   				      /* tp_base */
-    0,   				      /* tp_dict */
-    0,   				      /* tp_descr_get */
-    0,   				      /* tp_descr_set */
-    0,   				      /* tp_dictoffset */
-    0,   				      /* tp_init */
-    0,   				      /* tp_alloc */
-    0,   				      /* tp_new */
-    0,   				      /* tp_free */
-    0,   				      /* tp_is_gc */
-    0,   				      /* tp_bases */
-    0,   				      /* tp_mro */
-    0,   				      /* tp_cache */
-    0,   				      /* tp_subclasses */
-    0,   				      /* tp_weaklist */
-    0,   				      /* tp_del */
+    0,                                           /* ob_size*/
+    "numpy.@name@@ex@",                          /* tp_name*/
+    sizeof(Py@NAME@ScalarObject),                /* tp_basicsize*/
+    0,                                           /* tp_itemsize */
+    0,                                           /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    0,                                           /* tp_as_sequence */
+    0,                                           /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    0,                                           /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    0,                                           /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    0,                                           /* tp_iternext */
+    0,                                           /* tp_methods */
+    0,                                           /* tp_members */
+    0,                                           /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    0,                                           /* tp_init */
+    0,                                           /* tp_alloc */
+    0,                                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 #ifdef COUNT_ALLOCS
     /* these must be last and never explicitly initialized */
-    0, 					      /* tp_allocs */
-    0, 					      /* tp_frees */
-    0, 					      /* tp_maxalloc */
-    0, 					      /* tp_prev */
-    0, 					      /* *tp_next */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 /**end repeat**/
 
 /**begin repeat
-#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble#
-#name=int*5, uint*5, float*3#
-#CNAME=(CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE#
-*/
+ * #NAME = Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong,
+ *         ULongLong, Float, Double, LongDouble#
+ * #name = int*5, uint*5, float*3#
+ * #CNAME = (CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE#
+ */
 #if BITSOF_@CNAME@ == 8
 #define _THIS_SIZE "8"
 #elif BITSOF_@CNAME@ == 16
@@ -2904,59 +3071,59 @@
 #endif
 static PyTypeObject Py@NAME@ArrType_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                          /*ob_size*/
-    "numpy.@name@" _THIS_SIZE,                  /*tp_name*/
-    sizeof(Py@NAME@ScalarObject),               /*tp_basicsize*/
-    0,                                        /* tp_itemsize */
-    0,       				      /* tp_dealloc */
-    0,                                        /* tp_print */
-    0,                                        /* tp_getattr */
-    0,                                        /* tp_setattr */
-    0,                                        /* tp_compare */
-    0,                                        /* tp_repr */
-    0,                                        /* tp_as_number */
-    0,              			      /* tp_as_sequence */
-    0,               			      /* tp_as_mapping */
-    0,                                        /* tp_hash */
-    0,         				      /* tp_call */
-    0,                                        /* tp_str */
-    0,					      /* tp_getattro */
-    0,					      /* tp_setattro */
-    0,					      /* tp_as_buffer */
-    0,                                        /* tp_flags */
-    0,   				      /* tp_doc */
-    0,   				      /* tp_traverse */
-    0,   				      /* tp_clear */
-    0,   				      /* tp_richcompare */
-    0,   				      /* tp_weaklistoffset */
-    0,   				      /* tp_iter */ 
-    0,   				      /* tp_iternext */ 
-    0,   				      /* tp_methods */
-    0,   				      /* tp_members */
-    0,   				      /* tp_getset */
-    0,   				      /* tp_base */
-    0,   				      /* tp_dict */
-    0,   				      /* tp_descr_get */
-    0,   				      /* tp_descr_set */
-    0,   				      /* tp_dictoffset */
-    0,   				      /* tp_init */
-    0,   				      /* tp_alloc */
-    0,   				      /* tp_new */
-    0,   				      /* tp_free */
-    0,   				      /* tp_is_gc */
-    0,   				      /* tp_bases */
-    0,   				      /* tp_mro */
-    0,   				      /* tp_cache */
-    0,   				      /* tp_subclasses */
-    0,   				      /* tp_weaklist */
-    0,   				      /* tp_del */
+    0,                                           /* ob_size*/
+    "numpy.@name@" _THIS_SIZE,                   /* tp_name*/
+    sizeof(Py@NAME@ScalarObject),                /* tp_basicsize*/
+    0,                                           /* tp_itemsize */
+    0,                                           /* tp_dealloc */
+    0,                                           /* tp_print */
+    0,                                           /* tp_getattr */
+    0,                                           /* tp_setattr */
+    0,                                           /* tp_compare */
+    0,                                           /* tp_repr */
+    0,                                           /* tp_as_number */
+    0,                                           /* tp_as_sequence */
+    0,                                           /* tp_as_mapping */
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call */
+    0,                                           /* tp_str */
+    0,                                           /* tp_getattro */
+    0,                                           /* tp_setattro */
+    0,                                           /* tp_as_buffer */
+    0,                                           /* tp_flags */
+    0,                                           /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    0,                                           /* tp_iternext */
+    0,                                           /* tp_methods */
+    0,                                           /* tp_members */
+    0,                                           /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    0,                                           /* tp_init */
+    0,                                           /* tp_alloc */
+    0,                                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 #ifdef COUNT_ALLOCS
     /* these must be last and never explicitly initialized */
-    0, 					      /* tp_allocs */
-    0, 					      /* tp_frees */
-    0, 					      /* tp_maxalloc */
-    0, 					      /* tp_prev */
-    0, 					      /* *tp_next */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 
@@ -2972,10 +3139,10 @@
 
 
 /**begin repeat
-#NAME=CFloat, CDouble, CLongDouble#
-#name=complex*3#
-#CNAME=FLOAT, DOUBLE, LONGDOUBLE#
-*/
+ * #NAME = CFloat, CDouble, CLongDouble#
+ * #name = complex*3#
+ * #CNAME = FLOAT, DOUBLE, LONGDOUBLE#
+ */
 #if BITSOF_@CNAME@ == 16
 #define _THIS_SIZE2 "16"
 #define _THIS_SIZE1 "32"
@@ -2998,65 +3165,69 @@
 #define _THIS_SIZE2 "256"
 #define _THIS_SIZE1 "512"
 #endif
-static PyTypeObject Py@NAME@ArrType_Type = {
+
+#define _THIS_DOC "Composed of two " _THIS_SIZE2 " bit floats"
+
+    static PyTypeObject Py@NAME@ArrType_Type = {
     PyObject_HEAD_INIT(NULL)
-    0,                                              /*ob_size*/
-    "numpy.@name@" _THIS_SIZE1,                     /*tp_name*/
-    sizeof(Py@NAME@ScalarObject),                   /*tp_basicsize*/
-    0,                                              /*tp_itemsize*/
-    0,                                              /*tp_dealloc*/
-    0,                                              /*tp_print*/
-    0,                                              /*tp_getattr*/
-    0,                                              /*tp_setattr*/
-    0,                                              /*tp_compare*/
-    0,                                              /*tp_repr*/
-    0,                                              /*tp_as_number*/
-    0,                                              /*tp_as_sequence*/
-    0,                                              /*tp_as_mapping*/
-    0,                                              /*tp_hash */
-    0,                                              /*tp_call*/
-    0,                                              /*tp_str*/
-    0,                                              /*tp_getattro*/
-    0,                                              /*tp_setattro*/
-    0,                                              /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT,                             /*tp_flags*/
-    "Composed of two " _THIS_SIZE2 " bit floats",   /* tp_doc */
-    0,   				      /* tp_traverse */
-    0,   				      /* tp_clear */
-    0,   				      /* tp_richcompare */
-    0,   				      /* tp_weaklistoffset */
-    0,   				      /* tp_iter */ 
-    0,   				      /* tp_iternext */ 
-    0,   				      /* tp_methods */
-    0,   				      /* tp_members */
-    0,   				      /* tp_getset */
-    0,   				      /* tp_base */
-    0,   				      /* tp_dict */
-    0,   				      /* tp_descr_get */
-    0,   				      /* tp_descr_set */
-    0,   				      /* tp_dictoffset */
-    0,   				      /* tp_init */
-    0,   				      /* tp_alloc */
-    0,   				      /* tp_new */
-    0,   				      /* tp_free */
-    0,   				      /* tp_is_gc */
-    0,   				      /* tp_bases */
-    0,   				      /* tp_mro */
-    0,   				      /* tp_cache */
-    0,   				      /* tp_subclasses */
-    0,   				      /* tp_weaklist */
-    0,   				      /* tp_del */
+    0,                                           /* ob_size*/
+    "numpy.@name@" _THIS_SIZE1,                  /* tp_name*/
+    sizeof(Py@NAME@ScalarObject),                /* tp_basicsize*/
+    0,                                           /* tp_itemsize*/
+    0,                                           /* tp_dealloc*/
+    0,                                           /* tp_print*/
+    0,                                           /* tp_getattr*/
+    0,                                           /* tp_setattr*/
+    0,                                           /* tp_compare*/
+    0,                                           /* tp_repr*/
+    0,                                           /* tp_as_number*/
+    0,                                           /* tp_as_sequence*/
+    0,                                           /* tp_as_mapping*/
+    0,                                           /* tp_hash */
+    0,                                           /* tp_call*/
+    0,                                           /* tp_str*/
+    0,                                           /* tp_getattro*/
+    0,                                           /* tp_setattro*/
+    0,                                           /* tp_as_buffer*/
+    Py_TPFLAGS_DEFAULT,                          /* tp_flags*/
+    _THIS_DOC,                                   /* tp_doc */
+    0,                                           /* tp_traverse */
+    0,                                           /* tp_clear */
+    0,                                           /* tp_richcompare */
+    0,                                           /* tp_weaklistoffset */
+    0,                                           /* tp_iter */
+    0,                                           /* tp_iternext */
+    0,                                           /* tp_methods */
+    0,                                           /* tp_members */
+    0,                                           /* tp_getset */
+    0,                                           /* tp_base */
+    0,                                           /* tp_dict */
+    0,                                           /* tp_descr_get */
+    0,                                           /* tp_descr_set */
+    0,                                           /* tp_dictoffset */
+    0,                                           /* tp_init */
+    0,                                           /* tp_alloc */
+    0,                                           /* tp_new */
+    0,                                           /* tp_free */
+    0,                                           /* tp_is_gc */
+    0,                                           /* tp_bases */
+    0,                                           /* tp_mro */
+    0,                                           /* tp_cache */
+    0,                                           /* tp_subclasses */
+    0,                                           /* tp_weaklist */
+    0,                                           /* tp_del */
 #ifdef COUNT_ALLOCS
     /* these must be last and never explicitly initialized */
-    0, 					      /* tp_allocs */
-    0, 					      /* tp_frees */
-    0, 					      /* tp_maxalloc */
-    0, 					      /* tp_prev */
-    0, 					      /* *tp_next */
+    0,                                           /* tp_allocs */
+    0,                                           /* tp_frees */
+    0,                                           /* tp_maxalloc */
+    0,                                           /* tp_prev */
+    0,                                           /* *tp_next */
 #endif
 };
 #undef _THIS_SIZE1
 #undef _THIS_SIZE2
+#undef _THIS_DOC
 
 /**end repeat**/
 
@@ -3084,12 +3255,15 @@
 
     PyBoolArrType_Type.tp_as_number = &bool_arrtype_as_number;
 #if PY_VERSION_HEX >= 0x02050000
-    /* need to add dummy versions with filled-in nb_index
-       in-order for PyType_Ready to fill in .__index__() method
+    /*
+     * need to add dummy versions with filled-in nb_index
+     * in-order for PyType_Ready to fill in .__index__() method
      */
     /**begin repeat
-#name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong#
-#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong#
+     * #name = byte, short, int, long, longlong, ubyte, ushort,
+     *         uint, ulong, ulonglong#
+     * #NAME = Byte, Short, Int, Long, LongLong, UByte, UShort,
+     *         UInt, ULong, ULongLong#
      */
     Py@NAME@ArrType_Type.tp_as_number = &@name@_arrtype_as_number;
     Py@NAME@ArrType_Type.tp_as_number->nb_index = (unaryfunc)@name@_index;
@@ -3113,15 +3287,19 @@
     PyVoidArrType_Type.tp_as_sequence = &voidtype_as_sequence;
 
     /**begin repeat
-#NAME=Number, Integer, SignedInteger, UnsignedInteger, Inexact, Floating,
-ComplexFloating, Flexible, Character#
+     * #NAME= Number, Integer, SignedInteger, UnsignedInteger, Inexact,
+     *        Floating, ComplexFloating, Flexible, Character#
      */
     Py@NAME@ArrType_Type.tp_flags = BASEFLAGS;
     /**end repeat**/
 
     /**begin repeat
-#name=bool, byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, void, object#
-#NAME=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Void, Object#
+     * #name = bool, byte, short, int, long, longlong, ubyte, ushort, uint,
+     *         ulong, ulonglong, float, double, longdouble, cfloat, cdouble,
+     *         clongdouble, string, unicode, void, object#
+     * #NAME = Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt,
+     *         ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble,
+     *         CLongDouble, String, Unicode, Void, Object#
      */
     Py@NAME@ArrType_Type.tp_flags = BASEFLAGS;
     Py@NAME@ArrType_Type.tp_new = @name@_arrtype_new;
@@ -3129,8 +3307,10 @@
     /**end repeat**/
 
     /**begin repeat
-#name=bool, byte, short, ubyte, ushort, uint, ulong, ulonglong, float, longdouble, cfloat, clongdouble, void, object#
-#NAME=Bool, Byte, Short, UByte, UShort, UInt, ULong, ULongLong, Float, LongDouble, CFloat, CLongDouble, Void, Object#
+     * #name = bool, byte, short, ubyte, ushort, uint, ulong, ulonglong,
+     *         float, longdouble, cfloat, clongdouble, void, object#
+     * #NAME = Bool, Byte, Short, UByte, UShort, UInt, ULong, ULongLong,
+     *         Float, LongDouble, CFloat, CLongDouble, Void, Object#
      */
     Py@NAME@ArrType_Type.tp_hash = @name@_arrtype_hash;
     /**end repeat**/
@@ -3146,7 +3326,7 @@
 #endif
 
     /**begin repeat
-     *#name = repr, str#
+     * #name = repr, str#
      */
     PyFloatArrType_Type.tp_@name@ = floattype_@name@;
     PyCFloatArrType_Type.tp_@name@ = cfloattype_@name@;
@@ -3163,15 +3343,16 @@
     PyCDoubleArrType_Type.tp_print = cdoubletype_print;
     PyCLongDoubleArrType_Type.tp_print = clongdoubletype_print;
 
-    /* These need to be coded specially because getitem does not
-       return a normal Python type
+    /*
+     * These need to be coded specially because getitem does not
+     * return a normal Python type
      */
     PyLongDoubleArrType_Type.tp_as_number = &longdoubletype_as_number;
     PyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number;
 
     /**begin repeat
-     * #name=int, long, hex, oct, float, repr, str#
-     * #kind=tp_as_number->nb*5, tp*2#
+     * #name = int, long, hex, oct, float, repr, str#
+     * #kind = tp_as_number->nb*5, tp*2#
      */
     PyLongDoubleArrType_Type.@kind@_@name@ = longdoubletype_@name@;
     PyCLongDoubleArrType_Type.@kind@_@name@ = clongdoubletype_@name@;
@@ -3225,8 +3406,9 @@
         i++;
     }
 
-    if (!user) return typenum;
-
+    if (!user) {
+        return typenum;
+    }
     /* Search any registered types */
     i = 0;
     while (i < PyArray_NUMUSERTYPES) {
@@ -3267,36 +3449,41 @@
     }
 
     /* Check the generic types */
-    if ((type == (PyObject *) &PyNumberArrType_Type) ||             \
-            (type == (PyObject *) &PyInexactArrType_Type) ||            \
-            (type == (PyObject *) &PyFloatingArrType_Type))
+    if ((type == (PyObject *) &PyNumberArrType_Type) ||
+            (type == (PyObject *) &PyInexactArrType_Type) ||
+            (type == (PyObject *) &PyFloatingArrType_Type)) {
         typenum = PyArray_DOUBLE;
-    else if (type == (PyObject *)&PyComplexFloatingArrType_Type)
+    }
+    else if (type == (PyObject *)&PyComplexFloatingArrType_Type) {
         typenum = PyArray_CDOUBLE;
-    else if ((type == (PyObject *)&PyIntegerArrType_Type) ||        \
-            (type == (PyObject *)&PySignedIntegerArrType_Type))
+    }
+    else if ((type == (PyObject *)&PyIntegerArrType_Type) ||
+            (type == (PyObject *)&PySignedIntegerArrType_Type)) {
         typenum = PyArray_LONG;
-    else if (type == (PyObject *) &PyUnsignedIntegerArrType_Type)
+    }
+    else if (type == (PyObject *) &PyUnsignedIntegerArrType_Type) {
         typenum = PyArray_ULONG;
-    else if (type == (PyObject *) &PyCharacterArrType_Type)
+    }
+    else if (type == (PyObject *) &PyCharacterArrType_Type) {
         typenum = PyArray_STRING;
-    else if ((type == (PyObject *) &PyGenericArrType_Type) || \
-            (type == (PyObject *) &PyFlexibleArrType_Type))
+    }
+    else if ((type == (PyObject *) &PyGenericArrType_Type) ||
+            (type == (PyObject *) &PyFlexibleArrType_Type)) {
         typenum = PyArray_VOID;
+    }
 
     if (typenum != PyArray_NOTYPE) {
         return PyArray_DescrFromType(typenum);
     }
 
-    /* Otherwise --- type is a sub-type of an array scalar
-       not corresponding to a registered data-type object.
+    /*
+     * Otherwise --- type is a sub-type of an array scalar
+     * not corresponding to a registered data-type object.
      */
 
-    /* Do special thing for VOID sub-types
-     */
+    /* Do special thing for VOID sub-types */
     if (PyType_IsSubtype((PyTypeObject *)type, &PyVoidArrType_Type)) {
         new = PyArray_DescrNewFromType(PyArray_VOID);
-
         conv = _arraydescr_fromobj(type);
         if (conv) {
             new->fields = conv->fields;
@@ -3317,8 +3504,8 @@
 }
 
 /*NUMPY_API
-  Return the tuple of ordered field names from a dictionary.
-*/
+ * Return the tuple of ordered field names from a dictionary.
+ */
 static PyObject *
 PyArray_FieldNames(PyObject *fields)
 {
@@ -3332,20 +3519,25 @@
         return NULL;
     }
     _numpy_internal = PyImport_ImportModule("numpy.core._internal");
-    if (_numpy_internal == NULL) return NULL;
+    if (_numpy_internal == NULL) {
+        return NULL;
+    }
     tup = PyObject_CallMethod(_numpy_internal, "_makenames_list", "O", fields);
     Py_DECREF(_numpy_internal);
-    if (tup == NULL) return NULL;
+    if (tup == NULL) {
+        return NULL;
+    }
     ret = PyTuple_GET_ITEM(tup, 0);
     ret = PySequence_Tuple(ret);
     Py_DECREF(tup);
     return ret;
 }
 
-/* New reference */
 /*NUMPY_API
- Return descr object from array scalar.
-*/
+ * Return descr object from array scalar.
+ *
+ * New reference
+ */
 static PyArray_Descr *
 PyArray_DescrFromScalar(PyObject *sc)
 {
@@ -3361,8 +3553,9 @@
     if (descr->elsize == 0) {
         PyArray_DESCR_REPLACE(descr);
         type_num = descr->type_num;
-        if (type_num == PyArray_STRING)
+        if (type_num == PyArray_STRING) {
             descr->elsize = PyString_GET_SIZE(sc);
+        }
         else if (type_num == PyArray_UNICODE) {
             descr->elsize = PyUnicode_GET_DATA_SIZE(sc);
 #ifndef Py_UNICODE_WIDE
@@ -3378,18 +3571,20 @@
                 Py_XDECREF(descr->fields);
                 descr->fields = NULL;
             }
-            if (descr->fields)
+            if (descr->fields) {
                 descr->names = PyArray_FieldNames(descr->fields);
+            }
             PyErr_Clear();
         }
     }
     return descr;
 }
 
-/* New reference */
 /*NUMPY_API
- Get a typeobject from a type-number -- can return NULL.
-*/
+ * Get a typeobject from a type-number -- can return NULL.
+ *
+ * New reference
+ */
 static PyObject *
 PyArray_TypeObjectFromType(int type)
 {
@@ -3397,7 +3592,9 @@
     PyObject *obj;
 
     descr = PyArray_DescrFromType(type);
-    if (descr == NULL) return NULL;
+    if (descr == NULL) {
+        return NULL;
+    }
     obj = (PyObject *)descr->typeobj;
     Py_XINCREF(obj);
     Py_DECREF(descr);

Modified: branches/coremath/numpy/distutils/command/build_ext.py
===================================================================
--- branches/coremath/numpy/distutils/command/build_ext.py	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/distutils/command/build_ext.py	2009-02-22 03:41:06 UTC (rev 6445)
@@ -16,7 +16,7 @@
 from numpy.distutils.system_info import combine_paths
 from numpy.distutils.misc_util import filter_sources, has_f_sources, \
      has_cxx_sources, get_ext_source_files, \
-     get_numpy_include_dirs, is_sequence
+     get_numpy_include_dirs, is_sequence, get_build_architecture
 from numpy.distutils.command.config_compiler import show_fortran_compilers
 
 try:

Modified: branches/coremath/numpy/distutils/fcompiler/compaq.py
===================================================================
--- branches/coremath/numpy/distutils/fcompiler/compaq.py	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/distutils/fcompiler/compaq.py	2009-02-22 03:41:06 UTC (rev 6445)
@@ -79,7 +79,7 @@
             m.initialize()
             ar_exe = m.lib
         except DistutilsPlatformError, msg:
-            print 'Ignoring "%s" (one should fix me in fcompiler/compaq.py)' % (msg)
+			pass
         except AttributeError, msg:
             if '_MSVCCompiler__root' in str(msg):
                 print 'Ignoring "%s" (I think it is msvccompiler.py bug)' % (msg)

Modified: branches/coremath/numpy/distutils/mingw32ccompiler.py
===================================================================
--- branches/coremath/numpy/distutils/mingw32ccompiler.py	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/distutils/mingw32ccompiler.py	2009-02-22 03:41:06 UTC (rev 6445)
@@ -12,6 +12,8 @@
 import subprocess
 import sys
 import log
+import subprocess
+import re
 
 # Overwrite certain distutils.ccompiler functions:
 import numpy.distutils.ccompiler
@@ -29,8 +31,12 @@
 
 from distutils.unixccompiler import UnixCCompiler
 from distutils.msvccompiler import get_build_version as get_build_msvc_version
-from numpy.distutils.misc_util import msvc_runtime_library
+from numpy.distutils.misc_util import msvc_runtime_library, get_build_architecture
 
+# Useful to generate table of symbols from a dll
+_START = re.compile(r'\[Ordinal/Name Pointer\] Table')
+_TABLE = re.compile(r'^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)')
+
 # the same as cygwin plus some additional parameters
 class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):
     """ A modified MingW32 compiler compatible with an MSVC built Python.
@@ -89,17 +95,29 @@
         #                     linker_exe='gcc -mno-cygwin',
         #                     linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s'
         #                                % (self.linker, entry_point))
-        if self.gcc_version <= "3.0.0":
-            self.set_executables(compiler='gcc -mno-cygwin -O2 -w',
-                                 compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',
-                                 linker_exe='g++ -mno-cygwin',
-                                 linker_so='%s -mno-cygwin -mdll -static %s'
-                                 % (self.linker, entry_point))
+
+        # MS_WIN64 should be defined when building for amd64 on windows, but
+        # python headers define it only for MS compilers, which has all kind of
+        # bad consequences, like using Py_ModuleInit4 instead of
+        # Py_ModuleInit4_64, etc... So we add it here
+        if get_build_architecture() == 'AMD64':
+            self.set_executables(
+                    compiler='gcc -DMS_WIN64 -mno-cygwin -O0 -Wall',
+                    compiler_so='gcc -DMS_WIN64 -mno-cygwin -O0 -Wall -Wstrict-prototypes',
+                    linker_exe='gcc -mno-cygwin',
+                    linker_so='gcc -mno-cygwin -shared')
         else:
-            self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall',
-                                 compiler_so='gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes',
-                                 linker_exe='g++ -mno-cygwin',
-                                 linker_so='g++ -mno-cygwin -shared')
+            if self.gcc_version <= "3.0.0":
+                self.set_executables(compiler='gcc -mno-cygwin -O2 -w',
+                                     compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',
+                                     linker_exe='g++ -mno-cygwin',
+                                     linker_so='%s -mno-cygwin -mdll -static %s'
+                                     % (self.linker, entry_point))
+            else:
+                self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall',
+                                     compiler_so='gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes',
+                                     linker_exe='g++ -mno-cygwin',
+                                     linker_so='g++ -mno-cygwin -shared')
         # added for python2.3 support
         # we can't pass it through set_executables because pre 2.2 would fail
         self.compiler_cxx = ['g++']
@@ -191,11 +209,102 @@
     # object_filenames ()
 
 
+def find_python_dll():
+    maj, min, micro = [int(i) for i in sys.version_info[:3]]
+    dllname = 'python%d%d.dll' % (maj, min)
+    print "Looking for %s" % dllname
+
+    # We can't do much here:
+    # - find it in python main dir
+    # - in system32,
+    # - ortherwise (Sxs), I don't know how to get it.
+    lib_dirs = []
+    lib_dirs.append(os.path.join(sys.prefix, 'lib'))
+    try:
+        lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'system32'))
+    except KeyError:
+        pass
+
+    for d in lib_dirs:
+        dll = os.path.join(d, dllname)
+        if os.path.exists(dll):
+            return dll
+
+    raise ValueError("%s not found in %s" % (dllname, lib_dirs))
+
+def dump_table(dll):
+    st = subprocess.Popen(["objdump.exe", "-p", dll], stdout=subprocess.PIPE)
+    return st.stdout.readlines()
+
+def generate_def(dll, dfile):
+    """Given a dll file location,  get all its exported symbols and dump them
+    into the given def file.
+
+    The .def file will be overwritten"""
+    dump = dump_table(dll)
+    for i in range(len(dump)):
+        if _START.match(dump[i]):
+            break
+
+    if i == len(dump):
+        raise ValueError("Symbol table not found")
+
+    syms = []
+    for j in range(i+1, len(dump)):
+        m = _TABLE.match(dump[j])
+        if m:
+            syms.append((int(m.group(1).strip()), m.group(2)))
+        else:
+            break
+
+    if len(syms) == 0:
+        log.warn('No symbols found in %s' % dll)
+
+    d = open(dfile, 'w')
+    d.write('LIBRARY        %s\n' % os.path.basename(dll))
+    d.write(';CODE          PRELOAD MOVEABLE DISCARDABLE\n')
+    d.write(';DATA          PRELOAD SINGLE\n')
+    d.write('\nEXPORTS\n')
+    for s in syms:
+        #d.write('@%d    %s\n' % (s[0], s[1]))
+        d.write('%s\n' % s[1])
+    d.close()
+
 def build_import_library():
+    if os.name != 'nt':
+        return
+
+    arch = get_build_architecture()
+    if arch == 'AMD64':
+        return _build_import_library_amd64()
+    elif arch == 'Intel':
+        return _build_import_library_x86()
+    else:
+        raise ValueError("Unhandled arch %s" % arch)
+
+def _build_import_library_amd64():
+    dll_file = find_python_dll()
+
+    out_name = "libpython%d%d.a" % tuple(sys.version_info[:2])
+    out_file = os.path.join(sys.prefix, 'libs', out_name)
+    if os.path.isfile(out_file):
+        log.debug('Skip building import library: "%s" exists' % (out_file))
+        return
+
+    def_name = "python%d%d.def" % tuple(sys.version_info[:2])
+    def_file = os.path.join(sys.prefix,'libs',def_name)
+
+    log.info('Building import library (arch=AMD64): "%s" (from %s)' \
+             % (out_file, dll_file))
+
+    generate_def(dll_file, def_file)
+
+    cmd = ['dlltool', '-d', def_file, '-l', out_file]
+    subprocess.Popen(cmd)
+
+def _build_import_library_x86():
     """ Build the import libraries for Mingw32-gcc on Windows
     """
-    if os.name != 'nt':
-        return
     lib_name = "python%d%d.lib" % tuple(sys.version_info[:2])
     lib_file = os.path.join(sys.prefix,'libs',lib_name)
     out_name = "libpython%d%d.a" % tuple(sys.version_info[:2])
@@ -206,7 +315,7 @@
     if os.path.isfile(out_file):
         log.debug('Skip building import library: "%s" exists' % (out_file))
         return
-    log.info('Building import library: "%s"' % (out_file))
+    log.info('Building import library (ARCH=x86): "%s"' % (out_file))
 
     from numpy.distutils import lib2def
 
@@ -254,6 +363,9 @@
             _MSVCRVER_TO_FULLVER['90'] = msvcrt.CRT_ASSEMBLY_VERSION
         else:
             _MSVCRVER_TO_FULLVER['90'] = "9.0.21022.8"
+        # I took one version in my SxS directory: no idea if it is the good
+        # one, and we can't retrieve it from python
+        _MSVCRVER_TO_FULLVER['90'] = "8.0.50727.42"
     except ImportError:
         # If we are here, means python was not built with MSVC. Not sure what to do
         # in that case: manifest building will fail, but it should not be used in
@@ -344,7 +456,7 @@
 def generate_manifest(config):
     msver = get_build_msvc_version()
     if msver is not None:
-        if msver >= 8:
+        if msver >= 9:
             check_embedded_msvcr_match_linked(msver)
             ma = int(msver)
             mi = int((msver - ma) * 10)

Modified: branches/coremath/numpy/lib/tests/test_io.py
===================================================================
--- branches/coremath/numpy/lib/tests/test_io.py	2009-02-21 23:54:31 UTC (rev 6444)
+++ branches/coremath/numpy/lib/tests/test_io.py	2009-02-22 03:41:06 UTC (rev 6445)
@@ -6,11 +6,19 @@
 import StringIO
 
 from tempfile import NamedTemporaryFile
-import sys
+import sys, time
+from datetime import datetime
 
 
 MAJVER, MINVER = sys.version_info[:2]
 
+def strptime(s, fmt=None):
+    """This function is available in the datetime module only
+    from Python >= 2.5.
+
+    """
+    return datetime(*time.strptime(s, fmt)[:3])
+
 class RoundtripTest(object):
     def roundtrip(self, save_func, *args, **kwargs):
         """
@@ -538,12 +546,11 @@
 
     def test_converters_cornercases(self):
         "Test the conversion to datetime."
-        from datetime import datetime
-        converter = {'date':lambda s: datetime.strptime(s,'%Y-%m-%d %H:%M:%SZ')}
+        converter = {'date': lambda s: strptime(s, '%Y-%m-%d %H:%M:%SZ')}
         data = StringIO.StringIO('2009-02-03 12:00:00Z, 72214.0')
         test = np.ndfromtxt(data, delimiter=',', dtype=None,
                             names=['date','stid'], converters=converter)
-        control = np.array((datetime(2009,02,03,12,0), 72214.),
+        control = np.array((datetime(2009,02,03), 72214.),
                            dtype=[('date', np.object_), ('stid', float)])
         assert_equal(test, control)
 
@@ -583,11 +590,11 @@
         2; 2002-01-31
         """
         ndtype = [('idx', int), ('code', np.object)]
-        func = lambda s: date(*(time.strptime(s.strip(), "%Y-%m-%d")[:3]))
+        func = lambda s: strptime(s.strip(), "%Y-%m-%d")
         converters = {1: func}
         test = np.genfromtxt(StringIO.StringIO(data), delimiter=";", dtype=ndtype,
                              converters=converters)
-        control = np.array([(1, date(2001,1,1)), (2, date(2002,1,31))],
+        control = np.array([(1, datetime(2001,1,1)), (2, datetime(2002,1,31))],
                            dtype=ndtype)
         assert_equal(test, control)
         #



More information about the Numpy-svn mailing list