[Numpy-svn] r6476 - in branches/coremath: . numpy numpy/core/src numpy/core/tests numpy/distutils/fcompiler numpy/ma numpy/ma/tests

numpy-svn@scip... numpy-svn@scip...
Thu Feb 26 00:26:07 CST 2009


Author: cdavid
Date: 2009-02-26 00:24:22 -0600 (Thu, 26 Feb 2009)
New Revision: 6476

Modified:
   branches/coremath/
   branches/coremath/numpy/add_newdocs.py
   branches/coremath/numpy/core/src/arraytypes.inc.src
   branches/coremath/numpy/core/src/scalartypes.inc.src
   branches/coremath/numpy/core/tests/test_multiarray.py
   branches/coremath/numpy/core/tests/test_regression.py
   branches/coremath/numpy/core/tests/test_scalarmath.py
   branches/coremath/numpy/core/tests/test_unicode.py
   branches/coremath/numpy/distutils/fcompiler/compaq.py
   branches/coremath/numpy/ma/core.py
   branches/coremath/numpy/ma/tests/test_core.py
Log:
Merged revisions 6463-6466,6469,6472-6475 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk

........
  r6463 | pierregm | 2009-02-24 02:33:11 +0900 (Tue, 24 Feb 2009) | 1 line
  
  * MaskedArray.__setstate__ : fixed for structured array
........
  r6464 | charris | 2009-02-24 04:02:43 +0900 (Tue, 24 Feb 2009) | 4 lines
  
  Coding style cleanups. Start on arraytypes.inc.src.
  I'm a bit hesitant to commit this as tests are lacking
  for the functionality, but I want the changes
  somewhere central.
........
  r6465 | matthew.brett@gmail.com | 2009-02-25 05:53:10 +0900 (Wed, 25 Feb 2009) | 1 line
  
  Added docstring for isbuiltin
........
  r6466 | oliphant | 2009-02-25 14:15:47 +0900 (Wed, 25 Feb 2009) | 1 line
  
  Fix void-scalar element access when data-type contains titles (meta-data).
........
  r6469 | oliphant | 2009-02-25 22:45:30 +0900 (Wed, 25 Feb 2009) | 1 line
  
  Add Error checking.
........
  r6472 | charris | 2009-02-26 01:51:29 +0900 (Thu, 26 Feb 2009) | 1 line
  
  Fix coding style. Fix test_void_scalar_with_titles.
........
  r6473 | cdavid | 2009-02-26 03:27:19 +0900 (Thu, 26 Feb 2009) | 1 line
  
  Trap another kind of exception for MSVC9 in compaq fcompiler.
........
  r6474 | cdavid | 2009-02-26 03:56:15 +0900 (Thu, 26 Feb 2009) | 1 line
  
  Mark mingw-w64 crashing tests as known failures.
........
  r6475 | cdavid | 2009-02-26 04:04:59 +0900 (Thu, 26 Feb 2009) | 1 line
  
  Tag more mingw-w64 failures as such.
........



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-6461
   + /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-6475

Modified: branches/coremath/numpy/add_newdocs.py
===================================================================
--- branches/coremath/numpy/add_newdocs.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/add_newdocs.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -2937,7 +2937,7 @@
 
 add_newdoc('numpy.core.multiarray', 'dtype', ('byteorder',
     '''
-    dt.byteorder
+    byteorder
 
     String giving byteorder of dtype
 
@@ -2995,6 +2995,33 @@
 
 add_newdoc('numpy.core.multiarray', 'dtype', ('isbuiltin',
     """
+    isbuiltin
+
+    Value identifying if numpy dtype is a numpy builtin type
+
+    Read-only
+
+    Returns
+    -------
+    val : {0,1,2}
+       0 if this is a structured array type, with fields
+       1 if this is a dtype compiled into numpy (such as ints, floats etc)
+       2 if the dtype is for a user-defined numpy type
+         A user-defined type uses the numpy C-API machinery to extend
+         numpy to handle a new array type.  See the Guide to Numpy for
+         details.
+
+    Examples
+    --------
+    >>> dt = np.dtype('i2')
+    >>> dt.isbuiltin
+    1
+    >>> dt = np.dtype('f8')
+    >>> dt.isbuiltin
+    1
+    >>> dt = np.dtype([('field1', 'f8')])
+    >>> dt.isbuiltin
+    0
     """))
 
 add_newdoc('numpy.core.multiarray', 'dtype', ('isnative',

Modified: branches/coremath/numpy/core/src/arraytypes.inc.src
===================================================================
--- branches/coremath/numpy/core/src/arraytypes.inc.src	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/core/src/arraytypes.inc.src	2009-02-26 06:24:22 UTC (rev 6476)
@@ -21,10 +21,9 @@
 
 
 /**begin repeat
-#type=long,longlong#
-#Type=Long,LongLong#
-*/
-
+ * #type = long, longlong#
+ * #Type = Long, LongLong#
+ */
 static @type@
 MyPyLong_As@Type@ (PyObject *obj)
 {
@@ -39,7 +38,6 @@
     return ret;
 }
 
-
 static u@type@
 MyPyLong_AsUnsigned@Type@ (PyObject *obj)
 {
@@ -64,15 +62,21 @@
 /****************** getitem and setitem **********************/
 
 /**begin repeat
-
-#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#
-#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#
-#func2=PyObject_IsTrue, MyPyLong_AsLong*6, MyPyLong_AsUnsignedLong*2, MyPyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#
-#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#
-#typ1=long*7, ulong*2, longlong, ulonglong, float, double#
-#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#
+ *
+ * #TYP = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, LONG, UINT, ULONG,
+ *        LONGLONG, ULONGLONG, FLOAT, DOUBLE#
+ * #func1 = PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2,
+ *          PyLong_FromLongLong, PyLong_FromUnsignedLongLong,
+ *          PyFloat_FromDouble*2#
+ * #func2 = PyObject_IsTrue, MyPyLong_AsLong*6, MyPyLong_AsUnsignedLong*2,
+ *          MyPyLong_AsLongLong, MyPyLong_AsUnsignedLongLong,
+ *          MyPyFloat_AsDouble*2#
+ * #typ = Bool, byte, ubyte, short, ushort, int, long, uint, ulong,
+ *        longlong, ulonglong, float, double#
+ * #typ1 = long*7, ulong*2, longlong, ulonglong, float, double#
+ * #kind = Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong,
+ *         LongLong, ULongLong, Float, Double#
 */
-
 static PyObject *
 @TYP@_getitem(char *ip, PyArrayObject *ap) {
     @typ@ t1;
@@ -82,8 +86,7 @@
         return @func1@((@typ1@)t1);
     }
     else {
-        ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),
-                ap);
+        ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap), ap);
         return @func1@((@typ1@)t1);
     }
 }
@@ -92,7 +95,6 @@
 @TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {
     @typ@ temp;  /* ensures alignment */
 
-
     if (PyArray_IsScalar(op, @kind@)) {
         temp = ((Py@kind@ScalarObject *)op)->obval;
     }
@@ -113,19 +115,16 @@
         ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap),
                 ap);
     }
-
     return 0;
 }
 
 /**end repeat**/
 
-
 /**begin repeat
-
-#TYP=CFLOAT,CDOUBLE#
-#typ=float, double#
-*/
-
+ *
+ * #TYP = CFLOAT, CDOUBLE#
+ * #typ = float, double#
+ */
 static PyObject *
 @TYP@_getitem(char *ip, PyArrayObject *ap) {
     @typ@ t1, t2;
@@ -142,14 +141,15 @@
         return PyComplex_FromDoubles((double)t1, (double)t2);
     }
 }
+
 /**end repeat**/
 
 /**begin repeat
-
-#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#
-#typ=float, double, longdouble#
-#kind=CFloat, CDouble, CLongDouble#
-*/
+ *
+ * #TYP = CFLOAT, CDOUBLE, CLONGDOUBLE#
+ * #typ = float, double, longdouble#
+ * #kind = CFloat, CDouble, CLongDouble#
+ */
 static int
 @TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap)
 {
@@ -159,8 +159,8 @@
     int rsize;
 
     if (!(PyArray_IsScalar(op, @kind@))) {
-        if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {
-            op2 = ((PyArrayObject *)op)->descr->f->getitem     \
+        if (PyArray_Check(op) && (PyArray_NDIM(op) == 0)) {
+            op2 = ((PyArrayObject *)op)->descr->f->getitem
                   (((PyArrayObject *)op)->data,
                    (PyArrayObject *)op);
         }
@@ -174,22 +174,24 @@
             oop = PyComplex_AsCComplex (op2);
         }
         Py_DECREF(op2);
-        if (PyErr_Occurred()) return -1;
+        if (PyErr_Occurred()) {
+            return -1;
+        }
         temp.real = (@typ@) oop.real;
         temp.imag = (@typ@) oop.imag;
     }
     else {
         temp = ((Py@kind@ScalarObject *)op)->obval;
     }
-
     memcpy(ov, &temp, ap->descr->elsize);
-    if (!PyArray_ISNOTSWAPPED(ap))
+    if (!PyArray_ISNOTSWAPPED(ap)) {
         byte_swap_vector(ov, 2, sizeof(@typ@));
-
+    }
     rsize = sizeof(@typ@);
     copy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));
     return 0;
 }
+
 /**end repeat**/
 
 static PyObject *
@@ -208,9 +210,12 @@
     else {
         temp = (longdouble) MyPyFloat_AsDouble(op);
     }
-    if (PyErr_Occurred()) return -1;
-    if (ap == NULL || PyArray_ISBEHAVED(ap))
+    if (PyErr_Occurred()) {
+        return -1;
+    }
+    if (ap == NULL || PyArray_ISBEHAVED(ap)) {
         *((longdouble *)ov)=temp;
+    }
     else {
         copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,
                 !PyArray_ISNOTSWAPPED(ap));
@@ -297,8 +302,12 @@
         return -1;
     }
     /* Sequence_Size might have returned an error */
-    if (PyErr_Occurred()) PyErr_Clear();
-    if ((temp=PyObject_Unicode(op)) == NULL) return -1;
+    if (PyErr_Occurred()) {
+        PyErr_Clear();
+    }
+    if ((temp=PyObject_Unicode(op)) == NULL) {
+        return -1;
+    }
     ptr = PyUnicode_AS_UNICODE(temp);
     if ((ptr == NULL) || (PyErr_Occurred())) {
         Py_DECREF(temp);
@@ -317,7 +326,9 @@
             return -1;
         }
     }
-    else buffer = ov;
+    else {
+        buffer = ov;
+    }
     datalen = PyUCS2Buffer_AsUCS4(ptr, (PyArray_UCS4 *)buffer,
             datalen >> 1,
             ap->descr->elsize >> 2);
@@ -331,16 +342,18 @@
     if (ap->descr->elsize > datalen) {
         memset(ov + datalen, 0, (ap->descr->elsize - datalen));
     }
-
-    if (!PyArray_ISNOTSWAPPED(ap))
+    if (!PyArray_ISNOTSWAPPED(ap)) {
         byte_swap_vector(ov, ap->descr->elsize >> 2, 4);
+    }
     Py_DECREF(temp);
     return 0;
 }
 
-/* STRING -- can handle both NULL-terminated and not NULL-terminated cases
-             will truncate all ending NULLs in returned string.
-*/
+/* STRING
+ *
+ * can handle both NULL-terminated and not NULL-terminated cases
+ * will truncate all ending NULLs in returned string.
+ */
 static PyObject *
 STRING_getitem(char *ip, PyArrayObject *ap)
 {
@@ -348,8 +361,10 @@
     char *ptr;
     int size = ap->descr->elsize;
 
-    ptr = ip + size-1;
-    while (*ptr-- == '\0' && size > 0) size--;
+    ptr = ip + size - 1;
+    while (*ptr-- == '\0' && size > 0) {
+        size--;
+    }
     return PyString_FromStringAndSize(ip,size);
 }
 
@@ -358,7 +373,7 @@
 {
     char *ptr;
     Py_ssize_t len;
-    PyObject *temp=NULL;
+    PyObject *temp = NULL;
 
     if (!PyString_Check(op) && !PyUnicode_Check(op) &&
             PySequence_Check(op) && PySequence_Size(op) > 0) {
@@ -367,17 +382,21 @@
         return -1;
     }
     /* Sequence_Size might have returned an error */
-    if (PyErr_Occurred()) PyErr_Clear();
-    if ((temp = PyObject_Str(op)) == NULL) return -1;
-
+    if (PyErr_Occurred()) {
+        PyErr_Clear();
+    }
+    if ((temp = PyObject_Str(op)) == NULL) {
+        return -1;
+    }
     if (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {
         Py_DECREF(temp);
         return -1;
     }
     memcpy(ov, ptr, MIN(ap->descr->elsize,len));
-    /* If string lenth is smaller than room in array
-       Then fill the rest of the element size
-       with NULL */
+    /*
+     * If string lenth is smaller than room in array
+     * Then fill the rest of the element size with NULL
+     */
     if (ap->descr->elsize > len) {
         memset(ov + len, 0, (ap->descr->elsize - len));
     }
@@ -429,7 +448,7 @@
 static PyObject *
 VOID_getitem(char *ip, PyArrayObject *ap)
 {
-    PyObject *u=NULL;
+    PyObject *u = NULL;
     PyArray_Descr* descr;
     int itemsize;
 
@@ -446,29 +465,30 @@
 
         /* get the names from the fields dictionary*/
         names = descr->names;
-        if (!names) goto finish;
+        if (!names) {
+            goto finish;
+        }
         n = PyTuple_GET_SIZE(names);
         ret = PyTuple_New(n);
         savedflags = ap->flags;
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             key = PyTuple_GET_ITEM(names, i);
             tup = PyDict_GetItem(descr->fields, key);
-            if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
-                        &title)) {
+            if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset, &title)) {
                 Py_DECREF(ret);
                 ap->descr = descr;
                 return NULL;
             }
             ap->descr = new;
             /* update alignment based on offset */
-            if ((new->alignment > 1) &&                     \
-                    ((((intp)(ip+offset)) % new->alignment) != 0))
+            if ((new->alignment > 1)
+                    && ((((intp)(ip+offset)) % new->alignment) != 0)) {
                 ap->flags &= ~ALIGNED;
-            else
+            }
+            else {
                 ap->flags |= ALIGNED;
-
-            PyTuple_SET_ITEM(ret, i,                        \
-                    new->f->getitem(ip+offset, ap));
+            }
+            PyTuple_SET_ITEM(ret, i, new->f->getitem(ip+offset, ap));
             ap->flags = savedflags;
         }
         ap->descr = descr;
@@ -477,10 +497,10 @@
 
     if (descr->subarray) {
         /* return an array of the basic type */
-        PyArray_Dims shape={NULL,-1};
+        PyArray_Dims shape = {NULL, -1};
         PyObject *ret;
-        if (!(PyArray_IntpConverter(descr->subarray->shape,
-                        &shape))) {
+
+        if (!(PyArray_IntpConverter(descr->subarray->shape, &shape))) {
             PyDimMem_FREE(shape.ptr);
             PyErr_SetString(PyExc_ValueError,
                     "invalid shape in fixed-type tuple.");
@@ -488,11 +508,12 @@
         }
         Py_INCREF(descr->subarray->base);
         ret = PyArray_NewFromDescr(&PyArray_Type,
-                descr->subarray->base,
-                shape.len, shape.ptr,
+                descr->subarray->base, shape.len, shape.ptr,
                 NULL, ip, ap->flags, NULL);
         PyDimMem_FREE(shape.ptr);
-        if (!ret) return NULL;
+        if (!ret) {
+            return NULL;
+        }
         PyArray_BASE(ret) = (PyObject *)ap;
         Py_INCREF(ap);
         PyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL);
@@ -500,23 +521,27 @@
     }
 
 finish:
-    if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT) ||
-            PyDataType_FLAGCHK(descr, NPY_ITEM_IS_POINTER)) {
+    if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT)
+            || PyDataType_FLAGCHK(descr, NPY_ITEM_IS_POINTER)) {
         PyErr_SetString(PyExc_ValueError,
                 "tried to get void-array with object"
                 " members as buffer.");
         return NULL;
     }
-
-    itemsize=ap->descr->elsize;
-    if (PyArray_ISWRITEABLE(ap))
+    itemsize = ap->descr->elsize;
+    if (PyArray_ISWRITEABLE(ap)) {
         u = PyBuffer_FromReadWriteMemory(ip, itemsize);
-    else
+    }
+    else {
         u = PyBuffer_FromMemory(ip, itemsize);
-    if (u==NULL) goto fail;
-
-    /* default is to return buffer object pointing to current item */
-    /*  a view of it */
+    }
+    if (u == NULL) {
+        goto fail;
+    }
+    /*
+     * default is to return buffer object pointing to
+     * current item a view of it
+     */
     return u;
 
 fail:
@@ -543,6 +568,7 @@
         PyArray_Descr *new;
         int offset;
         int savedflags;
+
         res = -1;
         /* get the names from the fields dictionary*/
         names = descr->names;
@@ -554,26 +580,27 @@
             return -1;
         }
         savedflags = ap->flags;
-        for (i=0; i<n; i++) {
+        for (i = 0; i < n; i++) {
             key = PyTuple_GET_ITEM(names, i);
             tup = PyDict_GetItem(descr->fields, key);
-            if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
-                        &title)) {
+            if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset, &title)) {
                 ap->descr = descr;
                 return -1;
             }
             ap->descr = new;
             /* remember to update alignment flags */
-            if ((new->alignment > 1) &&                     \
-                    ((((intp)(ip+offset)) % new->alignment) != 0))
+            if ((new->alignment > 1)
+                    && ((((intp)(ip+offset)) % new->alignment) != 0)) {
                 ap->flags &= ~ALIGNED;
-            else
+            }
+            else {
                 ap->flags |= ALIGNED;
-
-            res = new->f->setitem(PyTuple_GET_ITEM(op, i),
-                    ip+offset, ap);
+            }
+            res = new->f->setitem(PyTuple_GET_ITEM(op, i), ip+offset, ap);
             ap->flags = savedflags;
-            if (res < 0) break;
+            if (res < 0) {
+                break;
+            }
         }
         ap->descr = descr;
         return res;
@@ -581,10 +608,9 @@
 
     if (descr->subarray) {
         /* copy into an array of the same basic type */
-        PyArray_Dims shape={NULL,-1};
+        PyArray_Dims shape = {NULL, -1};
         PyObject *ret;
-        if (!(PyArray_IntpConverter(descr->subarray->shape,
-                        &shape))) {
+        if (!(PyArray_IntpConverter(descr->subarray->shape, &shape))) {
             PyDimMem_FREE(shape.ptr);
             PyErr_SetString(PyExc_ValueError,
                     "invalid shape in fixed-type tuple.");
@@ -592,11 +618,12 @@
         }
         Py_INCREF(descr->subarray->base);
         ret = PyArray_NewFromDescr(&PyArray_Type,
-                descr->subarray->base,
-                shape.len, shape.ptr,
+                descr->subarray->base, shape.len, shape.ptr,
                 NULL, ip, ap->flags, NULL);
         PyDimMem_FREE(shape.ptr);
-        if (!ret) return -1;
+        if (!ret) {
+            return -1;
+        }
         PyArray_BASE(ret) = (PyObject *)ap;
         Py_INCREF(ap);
         PyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL);
@@ -609,15 +636,17 @@
     {
         const void *buffer;
         Py_ssize_t buflen;
-        if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT) ||
-                PyDataType_FLAGCHK(descr, NPY_ITEM_IS_POINTER)) {
+        if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT)
+                || PyDataType_FLAGCHK(descr, NPY_ITEM_IS_POINTER)) {
             PyErr_SetString(PyExc_ValueError,
                     "tried to set void-array with object"
                     " members using buffer.");
             return -1;
         }
         res = PyObject_AsReadBuffer(op, &buffer, &buflen);
-        if (res == -1) goto fail;
+        if (res == -1) {
+            goto fail;
+        }
         memcpy(ip, buffer, NPY_MIN(buflen, itemsize));
         if (itemsize > buflen) {
             memset(ip+buflen, 0, (itemsize-buflen));
@@ -636,29 +665,58 @@
 
 
 /**begin repeat
-#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#
-#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#
-#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#
-#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#
-#incr= (ip++)*169,(ip+=2)*39#
+ *
+ * #TOTYPE = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
+ *           LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
+ * #totype = byte, ubyte, short, ushort, int, uint, long, ulong,
+ *           longlong, ulonglong, float, double, longdouble#
 */
+
+/**begin repeat1
+ *
+ * #FROMTYPE = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
+ *             LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
+ * #fromtype = byte, ubyte, short, ushort, int, uint, long, ulong,
+ *             longlong, ulonglong, float, double, longdouble#
+ */
 static void
-@from@_to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n,
+@FROMTYPE@_to_@TOTYPE@(@fromtype@ *ip, @totype@ *op, intp n,
                PyArrayObject *NPY_UNUSED(aip), PyArrayObject *NPY_UNUSED(aop))
 {
     while (n--) {
-        *op++ = (@totyp@)*ip;
-        @incr@;
+        *op++ = (@totype@)*ip++;
     }
 }
+/**end repeat1**/
+
+/**begin repeat1
+ *
+ * #FROMTYPE = CFLOAT, CDOUBLE, CLONGDOUBLE#
+ * #fromtype = float, double, longdouble#
+ */
+static void
+@FROMTYPE@_to_@TOTYPE@(@fromtype@ *ip, @totype@ *op, intp n,
+               PyArrayObject *NPY_UNUSED(aip), PyArrayObject *NPY_UNUSED(aop))
+{
+    while (n--) {
+        *op++ = (@totype@)*ip;
+        ip += 2;
+    }
+}
+/**end repeat1**/
+
 /**end repeat**/
 
+
 /**begin repeat
-#from=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE#
-#fromtyp=Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#
+ *
+ * #FROMTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
+ *             LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
+ * #fromtype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
+ *             longlong, ulonglong, float, double, longdouble#
 */
 static void
-@from@_to_BOOL(register @fromtyp@ *ip, register Bool *op, register intp n,
+@FROMTYPE@_to_BOOL(@fromtype@ *ip, Bool *op, intp n,
                PyArrayObject *NPY_UNUSED(aip), PyArrayObject *NPY_UNUSED(aop))
 {
     while (n--) {
@@ -668,87 +726,105 @@
 /**end repeat**/
 
 /**begin repeat
-#from=CFLOAT, CDOUBLE, CLONGDOUBLE#
-#fromtyp=cfloat, cdouble, clongdouble#
+ *
+ * #FROMTYPE = CFLOAT, CDOUBLE, CLONGDOUBLE#
+ * #fromtype = cfloat, cdouble, clongdouble#
 */
 static void
-@from@_to_BOOL(register @fromtyp@ *ip, register Bool *op, register intp n,
+@FROMTYPE@_to_BOOL(@fromtype@ *ip, Bool *op, intp n,
                PyArrayObject *NPY_UNUSED(aip), PyArrayObject *NPY_UNUSED(aop))
 {
     while (n--) {
         *op = (Bool)(((*ip).real != FALSE) || ((*ip).imag != FALSE));
-        op++; ip++;
+        op++;
+        ip++;
     }
 }
 /**end repeat**/
 
 /**begin repeat
-#to=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE#
-#totyp=byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#
+ * #TOTYPE = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
+ *           LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
+ * #totype = byte, ubyte, short, ushort, int, uint, long, ulong,
+ *           longlong, ulonglong, float, double, longdouble#
 */
 static void
-BOOL_to_@to@(register Bool *ip, register @totyp@ *op, register intp n,
+BOOL_to_@TOTYPE@(Bool *ip, @totype@ *op, intp n,
              PyArrayObject *NPY_UNUSED(aip), PyArrayObject *NPY_UNUSED(aop))
 {
     while (n--) {
-        *op++ = (@totyp@)(*ip++ != FALSE);
+        *op++ = (@totype@)(*ip++ != FALSE);
     }
 }
 /**end repeat**/
 
 /**begin repeat
+ *
+ * #TOTYPE = CFLOAT,CDOUBLE,CLONGDOUBLE#
+ * #totype = float, double, longdouble#
+ */
 
-#to=(CFLOAT,CDOUBLE,CLONGDOUBLE)*14#
-#from=BOOL*3,BYTE*3,UBYTE*3,SHORT*3,USHORT*3,INT*3,UINT*3,LONG*3,ULONG*3,LONGLONG*3,ULONGLONG*3,FLOAT*3,DOUBLE*3,LONGDOUBLE*3#
-#fromtyp=Bool*3,byte*3, ubyte*3, short*3, ushort*3, int*3, uint*3, long*3, ulong*3, longlong*3, ulonglong*3, float*3, double*3, longdouble*3#
-#totyp= (float, double, longdouble)*14#
-*/
+/**begin repeat1
+ * #FROMTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
+ *             LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
+ * #fromtype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
+ *             longlong, ulonglong, float, double, longdouble#
+ */
 static void
-@from@_to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n,
+@FROMTYPE@_to_@TOTYPE@(register @fromtype@ *ip, register @totype@ *op, register intp n,
                PyArrayObject *NPY_UNUSED(aip), PyArrayObject *NPY_UNUSED(aop))
 {
     while (n--) {
-        *op++ = (@totyp@)*ip++;
+        *op++ = (@totype@)*ip++;
         *op++ = 0.0;
     }
 
 }
+/**end repeat1**/
 /**end repeat**/
 
 /**begin repeat
+ *
+ * #TOTYPE = CFLOAT,CDOUBLE,CLONGDOUBLE#
+ * #totype = float, double, longdouble#
+ */
 
-#to=(CFLOAT,CDOUBLE,CLONGDOUBLE)*3#
-#from=CFLOAT*3,CDOUBLE*3,CLONGDOUBLE*3#
-#totyp=(float, double, longdouble)*3#
-#fromtyp=float*3, double*3, longdouble*3#
-*/
+/**begin repeat1
+ * #FROMTYPE = CFLOAT,CDOUBLE,CLONGDOUBLE#
+ * #fromtype = float, double, longdouble#
+ */
 static void
-@from@_to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n,
+@FROMTYPE@_to_@TOTYPE@(@fromtype@ *ip, @totype@ *op, intp n,
                PyArrayObject *NPY_UNUSED(aip), PyArrayObject *NPY_UNUSED(aop))
 {
     n <<= 1;
     while (n--) {
-        *op++ = (@totyp@)*ip++;
+        *op++ = (@totype@)*ip++;
     }
+}
 
-}
+/**end repeat1**/
 /**end repeat**/
 
 /**begin repeat
-
-#from=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE, STRING, UNICODE, VOID, OBJECT#
-#fromtyp=Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, char, char, char, PyObject *#
-#skip= 1*17, aip->descr->elsize*3, 1#
-*/
+ *
+ * #FROMTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
+ *             LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
+ *             CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID, OBJECT#
+ * #fromtype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
+ *             longlong, ulonglong, float, double, longdouble,
+ *             cfloat, cdouble, clongdouble, char, char, char, PyObject *#
+ * #skip = 1*17, aip->descr->elsize*3, 1#
+ */
 static void
-@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,
+@FROMTYPE@_to_OBJECT(@fromtype@ *ip, PyObject **op, intp n, PyArrayObject *aip,
                  PyArrayObject *NPY_UNUSED(aop))
 {
-    register intp i;
-    int skip=@skip@;
-    for(i=0;i<n;i++,ip+=skip,op++) {
+    intp i;
+    int skip = @skip@;
+    for (i = 0; i < n; i++, ip +=skip, op++) {
         Py_XDECREF(*op);
-        *op = @from@_getitem((char *)ip, aip);
+        *op = @FROMTYPE@_getitem((char *)ip, aip);
     }
 }
 /**end repeat**/
@@ -770,27 +846,33 @@
 #define _NPY_UNUSEDCFLOAT  NPY_UNUSED
 #define _NPY_UNUSEDCDOUBLE  NPY_UNUSED
 #define _NPY_UNUSEDCLONGDOUBLE  NPY_UNUSED
-#define _NPY_UNUSEDSTRING 
-#define _NPY_UNUSEDVOID 
+#define _NPY_UNUSEDSTRING
+#define _NPY_UNUSEDVOID
 #define _NPY_UNUSEDUNICODE
+
 /**begin repeat
-
-#to=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE, STRING, UNICODE, VOID#
-#totyp=Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, char, char, char#
-#skip= 1*17, aip->descr->elsize*3#
-*/
+ *
+ * #TOTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
+ *           LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
+ *           CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID#
+ * #totype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
+ *           longlong, ulonglong, float, double, longdouble,
+ *           cfloat, cdouble, clongdouble, char, char, char#
+ * #skip = 1*17, aip->descr->elsize*3#
+ */
 static void
-OBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *_NPY_UNUSED@to@(aip),
-                 PyArrayObject *aop)
+OBJECT_to_@TOTYPE@(PyObject **ip, @totype@ *op, intp n,
+        PyArrayObject *_NPY_UNUSED@TOTYPE@(aip), PyArrayObject *aop)
 {
-    register intp i;
-    int skip=@skip@;
-    for(i=0;i<n;i++,ip++,op+=skip) {
+    intp i;
+    int skip = @skip@;
+
+    for (i = 0; i < n; i++, ip++, op += skip) {
         if (*ip == NULL) {
-            @to@_setitem(Py_False, (char *)op, aop);
+            @TOTYPE@_setitem(Py_False, (char *)op, aop);
         }
         else {
-            @to@_setitem(*ip, (char *)op, aop);
+            @TOTYPE@_setitem(*ip, (char *)op, aop);
         }
     }
 }
@@ -798,26 +880,28 @@
 
 
 /**begin repeat
-
-#from=STRING*20, UNICODE*20, VOID*20#
-#fromtyp=char*60#
-#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,STRING,UNICODE,VOID)*3#
-#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, char, char, char)*3#
-#oskip=(1*17,aop->descr->elsize*3)*3#
-#convert=1*17,0*3,1*17,0*3,0*20#
-#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#
+ *
+ * #from = STRING*20, UNICODE*20, VOID*20#
+ * #fromtyp = char*60#
+ * #to = (BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID)*3#
+ * #totyp = (Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, char, char, char)*3#
+ * #oskip = (1*17,aop->descr->elsize*3)*3#
+ * #convert = 1*17, 0*3, 1*17, 0*3, 0*20#
+ * #convstr = (Int*9, Long*2, Float*3, Complex*3, Tuple*3)*3#
 */
 static void
 @from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip,
              PyArrayObject *aop)
 {
     register intp i;
-    PyObject *temp=NULL;
-    int skip=aip->descr->elsize;
-    int oskip=@oskip@;
-    for(i=0; i<n; i++, ip+=skip, op+=oskip) {
+    PyObject *temp = NULL;
+    int skip = aip->descr->elsize;
+    int oskip = @oskip@;
+    for (i = 0; i < n; i++, ip+=skip, op+=oskip) {
         temp = @from@_getitem((char *)ip, aip);
-        if (temp==NULL) return;
+        if (temp == NULL) {
+            return;
+        }
         /* convert from Python object to needed one */
         if (@convert@) {
             PyObject *new, *args;
@@ -826,9 +910,10 @@
             new = Py@convstr@_Type.tp_new(&Py@convstr@_Type, args, NULL);
             Py_DECREF(args);
             temp = new;
-            if (temp==NULL) return;
+            if (temp == NULL) {
+                return;
+            }
         }
-
         @to@_setitem(temp,(char *)op, aop);
         Py_DECREF(temp);
     }
@@ -837,24 +922,23 @@
 /**end repeat**/
 
 /**begin repeat
-
-#to=STRING*17, UNICODE*17, VOID*17#
-#totyp=char*17, char*17, char*17#
-#from=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE)*3#
-#fromtyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble)*3#
-*/
-
+ *
+ * #to = STRING*17, UNICODE*17, VOID*17#
+ * #totyp = char*17, char*17, char*17#
+ * #from = (BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE)*3#
+ * #fromtyp = (Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble)*3#
+ */
 static void
 @from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip,
              PyArrayObject *aop)
 {
-    register intp i;
-    PyObject *temp=NULL;
-    int skip=1;
-    int oskip=aop->descr->elsize;
-    for(i=0; i<n; i++, ip+=skip, op+=oskip) {
+    intp i;
+    PyObject *temp = NULL;
+    int skip = 1;
+    int oskip = aop->descr->elsize;
+    for (i = 0; i < n; i++, ip += skip, op += oskip) {
         temp = @from@_getitem((char *)ip, aip);
-        if (temp==NULL) {
+        if (temp == NULL) {
             Py_INCREF(Py_False);
             temp = Py_False;
         }
@@ -868,31 +952,33 @@
 
 /****************** scan *************************************/
 
-/* The first ignore argument is for backwards compatibility.
-   Should be removed when the API version is bumped up.
+/*
+ * The first ignore argument is for backwards compatibility.
+ * Should be removed when the API version is bumped up.
  */
 
 /**begin repeat
-#fname=SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG#
-#type=short,ushort,int,uint,long,ulong,longlong,ulonglong#
-#format="hd","hu","d","u","ld","lu",LONGLONG_FMT,ULONGLONG_FMT#
-*/
+ * #fname = SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG#
+ * #type = short, ushort, int, uint, long, ulong, longlong, ulonglong#
+ * #format = "hd", "hu", "d", "u", "ld", "lu", LONGLONG_FMT, ULONGLONG_FMT#
+ */
 static int
-@fname@_scan (FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignored))
+@fname@_scan(FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignored))
 {
     return fscanf(fp, "%"@format@, ip);
 }
 /**end repeat**/
 
 /**begin repeat
-#fname=FLOAT,DOUBLE,LONGDOUBLE#
-#type=float,double,longdouble#
-*/
+ * #fname = FLOAT, DOUBLE, LONGDOUBLE#
+ * #type = float, double, longdouble#
+ */
 static int
-@fname@_scan (FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignored))
+@fname@_scan(FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignored))
 {
     double result;
     int ret;
+
     ret = NumPyOS_ascii_ftolf(fp, &result);
     *ip = (@type@) result;
     return ret;
@@ -900,16 +986,17 @@
 /**end repeat**/
 
 /**begin repeat
-#fname=BYTE,UBYTE#
-#type=byte,ubyte#
-#btype=int,uint#
-#format="d","u"#
-*/
+ * #fname = BYTE, UBYTE#
+ * #type = byte, ubyte#
+ * #btype = int, uint#
+ * #format = "d", "u"#
+ */
 static int
-@fname@_scan (FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignore2))
+@fname@_scan(FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignore2))
 {
     @btype@ temp;
     int num;
+
     num = fscanf(fp, "%"@format@, &temp);
     *ip = (@type@) temp;
     return num;
@@ -917,29 +1004,30 @@
 /**end repeat**/
 
 static int
-BOOL_scan (FILE *fp, Bool *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignore2))
+BOOL_scan(FILE *fp, Bool *ip, void *NPY_UNUSED(ignore), PyArray_Descr *NPY_UNUSED(ignore2))
 {
     int temp;
     int num;
+
     num = fscanf(fp, "%d", &temp);
     *ip = (Bool) (temp != 0);
     return num;
 }
 
 /**begin repeat
-#fname=CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#
-*/
+ * #fname = CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID#
+ */
 #define @fname@_scan NULL
 /**end repeat**/
 
 /****************** fromstr *************************************/
 
 /**begin repeat
-#fname=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG#
-#type=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#
-#func=(l,ul)*5#
-#btype=(long,ulong)*5#
-*/
+ * #fname = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG#
+ * #type = byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong#
+ * #func = (l, ul)*5#
+ * #btype = (long, ulong)*5#
+ */
 static int
 @fname@_fromstr(char *str, @type@ *ip, char **endptr, PyArray_Descr *NPY_UNUSED(ignore))
 {
@@ -952,9 +1040,10 @@
 /**end repeat**/
 
 /**begin repeat
-#fname=FLOAT,DOUBLE,LONGDOUBLE#
-#type=float,double,longdouble#
-*/
+ *
+ * #fname=FLOAT,DOUBLE,LONGDOUBLE#
+ * #type=float,double,longdouble#
+ */
 static int
 @fname@_fromstr(char *str, @type@ *ip, char **endptr, PyArray_Descr *NPY_UNUSED(ignore))
 {
@@ -969,8 +1058,8 @@
 
 
 /**begin repeat
-#fname=BOOL,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#
-*/
+ * #fname = BOOL, CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID#
+ */
 #define @fname@_fromstr NULL
 /**end repeat**/
 
@@ -978,11 +1067,11 @@
 /****************** copyswapn *************************************/
 
 /**begin repeat
-
-#fname=SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE#
-#fsize=SHORT,SHORT,INT,INT,LONG,LONG,LONGLONG,LONGLONG,FLOAT,DOUBLE,LONGDOUBLE#
-#type=short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble#
-*/
+ *
+ * #fname = SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
+ * #fsize = SHORT, SHORT, INT, INT, LONG, LONG, LONGLONG, LONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
+ * #type = short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#
+ */
 static void
 @fname@_copyswapn (void *dst, intp dstride, void *src, intp sstride,
                    intp n, int swap, void *NPY_UNUSED(arr))
@@ -1005,11 +1094,13 @@
 @fname@_copyswap (void *dst, void *src, int swap, void *NPY_UNUSED(arr))
 {
 
-    if (src != NULL) /* copy first if needed */
+    if (src != NULL) {
+        /* copy first if needed */
         memcpy(dst, src, sizeof(@type@));
+    }
+    if (swap) {
+        char *a, *b, c;
 
-    if (swap) {
-        register char *a, *b, c;
         a = (char *)dst;
 #if SIZEOF_@fsize@ == 2
         b = a + 1;
@@ -1051,25 +1142,27 @@
         c = *a; *a++ = *b; *b   = c;
 #else
         {
-            register int i, nn;
+            int i, nn;
+
             b = a + (SIZEOF_@fsize@-1);
             nn = SIZEOF_@fsize@ / 2;
-            for (i=0; i<nn; i++) {
-                c=*a; *a++ = *b; *b-- = c;
+            for (i = 0; i < nn; i++) {
+                c = *a;
+                *a++ = *b;
+                *b-- = c;
             }
         }
 #endif
     }
 }
 
-
 /**end repeat**/
 
 /**begin repeat
-
-#fname=BOOL, BYTE, UBYTE#
-#type=Bool, byte, ubyte#
-*/
+ *
+ * #fname = BOOL, BYTE, UBYTE#
+ * #type = Bool, byte, ubyte#
+ */
 static void
 @fname@_copyswapn (void *dst, intp dstride, void *src, intp sstride, intp n,
                    int NPY_UNUSED(swap), void *NPY_UNUSED(arr))
@@ -1089,8 +1182,10 @@
 static void
 @fname@_copyswap (void *dst, void *src, int NPY_UNUSED(swap), void *NPY_UNUSED(arr))
 {
-    if (src != NULL) /* copy first if needed */
+    if (src != NULL) {
+        /* copy first if needed */
         memcpy(dst, src, sizeof(@type@));
+    }
     /* ignore swap */
 }
 
@@ -1099,10 +1194,10 @@
 
 
 /**begin repeat
-
-#fname=CFLOAT,CDOUBLE,CLONGDOUBLE#
-#type=cfloat, cdouble, clongdouble#
-#fsize=FLOAT,DOUBLE,LONGDOUBLE#
+ *
+ * #fname = CFLOAT, CDOUBLE, CLONGDOUBLE#
+ * #type = cfloat,  cdouble,  clongdouble#
+ * #fsize = FLOAT, DOUBLE, LONGDOUBLE#
 */
 static void
 @fname@_copyswapn (void *dst, intp dstride, void *src, intp sstride, intp n,
@@ -2636,22 +2731,22 @@
 #define SETTYPE(name)                           \
     Py_INCREF(&Py##name##ArrType_Type);     \
     PyDict_SetItemString(infodict, #name,   \
-            (PyObject *)&Py##name##ArrType_Type);
+            (PyObject *)&Py##name##ArrType_Type)
 
-    SETTYPE(Generic)
-        SETTYPE(Number)
-        SETTYPE(Integer)
-        SETTYPE(Inexact)
-        SETTYPE(SignedInteger)
-        SETTYPE(UnsignedInteger)
-        SETTYPE(Floating)
-        SETTYPE(ComplexFloating)
-        SETTYPE(Flexible)
-        SETTYPE(Character)
+    SETTYPE(Generic);
+    SETTYPE(Number);
+    SETTYPE(Integer);
+    SETTYPE(Inexact);
+    SETTYPE(SignedInteger);
+    SETTYPE(UnsignedInteger);
+    SETTYPE(Floating);
+    SETTYPE(ComplexFloating);
+    SETTYPE(Flexible);
+    SETTYPE(Character);
 
 #undef SETTYPE
 
-        PyDict_SetItemString(dict, "typeinfo", infodict);
+    PyDict_SetItemString(dict, "typeinfo", infodict);
     Py_DECREF(infodict);
     return 0;
 }

Modified: branches/coremath/numpy/core/src/scalartypes.inc.src
===================================================================
--- branches/coremath/numpy/core/src/scalartypes.inc.src	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/core/src/scalartypes.inc.src	2009-02-26 06:24:22 UTC (rev 6476)
@@ -1448,9 +1448,14 @@
 static PyObject *
 voidtype_getfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
 {
-    PyObject *ret;
+    PyObject *ret, *newargs;
 
-    ret = gentype_generic_method((PyObject *)self, args, kwds, "getfield");
+    newargs = PyTuple_GetSlice(args, 0, 2);
+    if (newargs == NULL) {
+        return NULL;
+    }
+    ret = gentype_generic_method((PyObject *)self, newargs, kwds, "getfield");
+    Py_DECREF(newargs);
     if (!ret) {
         return ret;
     }

Modified: branches/coremath/numpy/core/tests/test_multiarray.py
===================================================================
--- branches/coremath/numpy/core/tests/test_multiarray.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/core/tests/test_multiarray.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -7,6 +7,10 @@
 
 from test_print import in_foreign_locale
 
+def iswin64():
+    import platform
+    return platform.architecture()[0] == "64bit" and sys.platform == "win32"
+
 class TestFlags(TestCase):
     def setUp(self):
         self.a = arange(10)
@@ -556,6 +560,7 @@
 
 
 class TestStringCompare(TestCase):
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_string(self):
         g1 = array(["This","is","example"])
         g2 = array(["This","was","example"])
@@ -566,6 +571,7 @@
         assert_array_equal(g1 < g2, [g1[i] < g2[i] for i in [0,1,2]])
         assert_array_equal(g1 > g2, [g1[i] > g2[i] for i in [0,1,2]])
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_mixed(self):
         g1 = array(["spam","spa","spammer","and eggs"])
         g2 = "spam"
@@ -577,6 +583,7 @@
         assert_array_equal(g1 >= g2, [x >= g2 for x in g1])
 
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_unicode(self):
         g1 = array([u"This",u"is",u"example"])
         g2 = array([u"This",u"was",u"example"])
@@ -796,6 +803,7 @@
             os.unlink(self.filename)
             #tmp_file.close()
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_roundtrip_file(self):
         f = open(self.filename, 'wb')
         self.x.tofile(f)
@@ -807,11 +815,13 @@
         assert_array_equal(y, self.x.flat)
         os.unlink(self.filename)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_roundtrip_filename(self):
         self.x.tofile(self.filename)
         y = np.fromfile(self.filename, dtype=self.dtype)
         assert_array_equal(y, self.x.flat)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_roundtrip_binary_str(self):
         s = self.x.tostring()
         y = np.fromstring(s, dtype=self.dtype)
@@ -821,6 +831,7 @@
         y = np.fromstring(s, dtype=self.dtype)
         assert_array_equal(y, self.x.flatten('F'))
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_roundtrip_str(self):
         x = self.x.real.ravel()
         s = "@".join(map(str, x))
@@ -830,12 +841,14 @@
         assert_array_equal(x[nan_mask], y[nan_mask])
         assert_array_almost_equal(x[~nan_mask], y[~nan_mask], decimal=5)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_roundtrip_repr(self):
         x = self.x.real.ravel()
         s = "@".join(map(repr, x))
         y = np.fromstring(s, sep="@")
         assert_array_equal(x, y)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def _check_from(self, s, value, **kw):
         y = np.fromstring(s, **kw)
         assert_array_equal(y, value)
@@ -846,53 +859,66 @@
         y = np.fromfile(self.filename, **kw)
         assert_array_equal(y, value)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_nan(self):
         self._check_from("nan +nan -nan NaN nan(foo) +NaN(BAR) -NAN(q_u_u_x_)",
                          [nan, nan, nan, nan, nan, nan, nan],
                          sep=' ')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_inf(self):
         self._check_from("inf +inf -inf infinity -Infinity iNfInItY -inF",
                          [inf, inf, -inf, inf, -inf, inf, -inf], sep=' ')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_numbers(self):
         self._check_from("1.234 -1.234 .3 .3e55 -123133.1231e+133",
                          [1.234, -1.234, .3, .3e55, -123133.1231e+133], sep=' ')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_binary(self):
         self._check_from('\x00\x00\x80?\x00\x00\x00@\x00\x00@@\x00\x00\x80@',
                          array([1,2,3,4]),
                          dtype='<f4')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_string(self):
         self._check_from('1,2,3,4', [1., 2., 3., 4.], sep=',')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_counted_string(self):
         self._check_from('1,2,3,4', [1., 2., 3., 4.], count=4, sep=',')
         self._check_from('1,2,3,4', [1., 2., 3.], count=3, sep=',')
         self._check_from('1,2,3,4', [1., 2., 3., 4.], count=-1, sep=',')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_string_with_ws(self):
         self._check_from('1 2  3     4   ', [1, 2, 3, 4], dtype=int, sep=' ')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_counted_string_with_ws(self):
         self._check_from('1 2  3     4   ', [1,2,3], count=3, dtype=int,
                          sep=' ')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_ascii(self):
         self._check_from('1 , 2 , 3 , 4', [1.,2.,3.,4.], sep=',')
         self._check_from('1,2,3,4', [1.,2.,3.,4.], dtype=float, sep=',')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_malformed(self):
         self._check_from('1.234 1,234', [1.234, 1.], sep=' ')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_long_sep(self):
         self._check_from('1_x_3_x_4_x_5', [1,3,4,5], sep='_x_')
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_dtype(self):
         v = np.array([1,2,3,4], dtype=np.int_)
         self._check_from('1,2,3,4', v, sep=',', dtype=np.int_)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_tofile_sep(self):
         x = np.array([1.51, 2, 3.51, 4], dtype=float)
         f = open(self.filename, 'w')
@@ -904,6 +930,7 @@
         assert_equal(s, '1.51,2.0,3.51,4.0')
         os.unlink(self.filename)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_tofile_format(self):
         x = np.array([1.51, 2, 3.51, 4], dtype=float)
         f = open(self.filename, 'w')
@@ -918,6 +945,7 @@
     def _run_in_foreign_locale(self, func, fail=False):
         np.testing.dec.knownfailureif(fail)(func)(self)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_locale(self):
         yield self._run_in_foreign_locale, TestIO.test_numbers
         yield self._run_in_foreign_locale, TestIO.test_nan

Modified: branches/coremath/numpy/core/tests/test_regression.py
===================================================================
--- branches/coremath/numpy/core/tests/test_regression.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/core/tests/test_regression.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -8,6 +8,10 @@
 
 rlevel = 1
 
+def iswin64():
+    import platform
+    return platform.architecture()[0] == "64bit" and sys.platform == "win32"
+
 def assert_valid_refcount(op):
     a = np.arange(100 * 100)
     b = np.arange(100*100).reshape(100, 100)
@@ -283,6 +287,7 @@
         x[0].tolist()
         [i for i in x[0]]
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_unicode_string_comparison(self,level=rlevel):
         """Ticket #190"""
         a = np.array('hello',np.unicode_)
@@ -753,6 +758,7 @@
             x |= y
         self.failUnlessRaises(TypeError,rs)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_unicode_scalar(self, level=rlevel):
         """Ticket #600"""
         import cPickle
@@ -1164,6 +1170,7 @@
         b = np.array(['1','2','3'])
         assert_equal(a,b)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_unaligned_unicode_access(self, level=rlevel) :
         """Ticket #825"""
         for i in range(1,9) :
@@ -1220,5 +1227,13 @@
         n_after = len(gc.get_objects())
         assert n_before >= n_after, (n_before, n_after)
 
+    def test_void_scalar_with_titles(self, level=rlevel):
+        """No ticket"""
+        data = [('john', 4), ('mary', 5)]
+        dtype1 = [(('source:yy', 'name'), 'O'), (('source:xx', 'id'), int)]
+        arr = np.array(data, dtype=dtype1)
+        assert arr[0][0] == 'john'
+        assert arr[0][1] == 4
+
 if __name__ == "__main__":
     run_module_suite()

Modified: branches/coremath/numpy/core/tests/test_scalarmath.py
===================================================================
--- branches/coremath/numpy/core/tests/test_scalarmath.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/core/tests/test_scalarmath.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -1,3 +1,4 @@
+import sys
 from numpy.testing import *
 import numpy as np
 
@@ -6,6 +7,10 @@
          np.single, np.double, np.longdouble, np.csingle,
          np.cdouble, np.clongdouble]
 
+def iswin64():
+    import platform
+    return platform.architecture()[0] == "64bit" and sys.platform == "win32"
+
 # This compares scalarmath against ufuncs.
 
 class TestTypes(TestCase):
@@ -42,6 +47,7 @@
             b = a ** 4
             assert b == 81, "error with %r: got %r" % (t,b)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_large_types(self):
         for t in [np.int32, np.int64, np.float32, np.float64, np.longdouble]:
             a = t(51)

Modified: branches/coremath/numpy/core/tests/test_unicode.py
===================================================================
--- branches/coremath/numpy/core/tests/test_unicode.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/core/tests/test_unicode.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -1,6 +1,12 @@
+import sys
+
 from numpy.testing import *
 from numpy.core import *
 
+def iswin64():
+    import platform
+    return platform.architecture()[0] == "64bit" and sys.platform == "win32"
+
 # Guess the UCS length for this python interpreter
 if len(buffer(u'u')) == 4:
     ucs4 = True
@@ -36,17 +42,20 @@
         else:
             self.assert_(len(buffer(ua_scalar)) == 0)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_zeros0D(self):
         """Check creation of 0-dimensional objects"""
         ua = zeros((), dtype='U%s' % self.ulen)
         self.content_check(ua, ua[()], 4*self.ulen)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_zerosSD(self):
         """Check creation of single-dimensional objects"""
         ua = zeros((2,), dtype='U%s' % self.ulen)
         self.content_check(ua, ua[0], 4*self.ulen*2)
         self.content_check(ua, ua[1], 4*self.ulen*2)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_zerosMD(self):
         """Check creation of multi-dimensional objects"""
         ua = zeros((2,3,4), dtype='U%s' % self.ulen)
@@ -96,17 +105,20 @@
                 # regular 2-byte word
                 self.assert_(len(buffer(ua_scalar)) == 2*self.ulen)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_values0D(self):
         """Check creation of 0-dimensional objects with values"""
         ua = array(self.ucs_value*self.ulen, dtype='U%s' % self.ulen)
         self.content_check(ua, ua[()], 4*self.ulen)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_valuesSD(self):
         """Check creation of single-dimensional objects with values"""
         ua = array([self.ucs_value*self.ulen]*2, dtype='U%s' % self.ulen)
         self.content_check(ua, ua[0], 4*self.ulen*2)
         self.content_check(ua, ua[1], 4*self.ulen*2)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_valuesMD(self):
         """Check creation of multi-dimensional objects with values"""
         ua = array([[[self.ucs_value*self.ulen]*2]*3]*4, dtype='U%s' % self.ulen)
@@ -181,12 +193,14 @@
                 # regular 2-byte word
                 self.assert_(len(buffer(ua_scalar)) == 2*self.ulen)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_values0D(self):
         """Check assignment of 0-dimensional objects with values"""
         ua = zeros((), dtype='U%s' % self.ulen)
         ua[()] = self.ucs_value*self.ulen
         self.content_check(ua, ua[()], 4*self.ulen)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_valuesSD(self):
         """Check assignment of single-dimensional objects with values"""
         ua = zeros((2,), dtype='U%s' % self.ulen)
@@ -195,6 +209,7 @@
         ua[1] = self.ucs_value*self.ulen
         self.content_check(ua, ua[1], 4*self.ulen*2)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_valuesMD(self):
         """Check assignment of multi-dimensional objects with values"""
         ua = zeros((2,3,4), dtype='U%s' % self.ulen)
@@ -248,6 +263,7 @@
 class byteorder_values:
     """Check the byteorder of unicode arrays in round-trip conversions"""
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_values0D(self):
         """Check byteorder of 0-dimensional objects"""
         ua = array(self.ucs_value*self.ulen, dtype='U%s' % self.ulen)
@@ -260,6 +276,7 @@
         # Arrays must be equal after the round-trip
         assert_equal(ua, ua3)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_valuesSD(self):
         """Check byteorder of single-dimensional objects"""
         ua = array([self.ucs_value*self.ulen]*2, dtype='U%s' % self.ulen)
@@ -270,6 +287,7 @@
         # Arrays must be equal after the round-trip
         assert_equal(ua, ua3)
 
+    @dec.knownfailureif(iswin64(), "Crash on win64")
     def test_valuesMD(self):
         """Check byteorder of multi-dimensional objects"""
         ua = array([[[self.ucs_value*self.ulen]*2]*3]*4,

Modified: branches/coremath/numpy/distutils/fcompiler/compaq.py
===================================================================
--- branches/coremath/numpy/distutils/fcompiler/compaq.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/distutils/fcompiler/compaq.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -89,6 +89,10 @@
             if not "vcvarsall.bat" in str(e):
                 print "Unexpected IOError in", __file__
                 raise e
+        except ValueError, e:
+	    if not "path']" in str(e):
+                print "Unexpected ValueError in", __file__
+                raise e
 
     executables = {
         'version_cmd'  : ['<F90>', "/what"],

Modified: branches/coremath/numpy/ma/core.py
===================================================================
--- branches/coremath/numpy/ma/core.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/ma/core.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -3846,7 +3846,7 @@
         """
         (ver, shp, typ, isf, raw, msk, flv) = state
         ndarray.__setstate__(self, (shp, typ, isf, raw))
-        self._mask.__setstate__((shp, np.dtype(bool), isf, msk))
+        self._mask.__setstate__((shp, make_mask_descr(typ), isf, msk))
         self.fill_value = flv
     #
     def __reduce__(self):

Modified: branches/coremath/numpy/ma/tests/test_core.py
===================================================================
--- branches/coremath/numpy/ma/tests/test_core.py	2009-02-25 19:04:59 UTC (rev 6475)
+++ branches/coremath/numpy/ma/tests/test_core.py	2009-02-26 06:24:22 UTC (rev 6476)
@@ -369,14 +369,26 @@
         assert_equal(a_pickled._mask, a._mask)
         assert_equal(a_pickled._data, a._data)
         assert_equal(a_pickled.fill_value, 999)
-        #
+
+    def test_pickling_subbaseclass(self):
+        "Test pickling w/ a subclass of ndarray"
+        import cPickle
         a = array(np.matrix(range(10)), mask=[1,0,1,0,0]*2)
         a_pickled = cPickle.loads(a.dumps())
         assert_equal(a_pickled._mask, a._mask)
         assert_equal(a_pickled, a)
         self.failUnless(isinstance(a_pickled._data,np.matrix))
 
+    def test_pickling_wstructured(self):
+        "Tests pickling w/ structured array"
+        import cPickle
+        a = array([(1, 1.), (2, 2.)], mask=[(0, 0), (0, 1)],
+                  dtype=[('a', int), ('b', float)])
+        a_pickled = cPickle.loads(a.dumps())
+        assert_equal(a_pickled._mask, a._mask)
+        assert_equal(a_pickled, a)
 
+
     def test_single_element_subscript(self):
         "Tests single element subscripts of Maskedarrays."
         a = array([1,3,2])



More information about the Numpy-svn mailing list