[Numpy-svn] r4015 - in trunk/numpy/core: include/numpy src tests

numpy-svn@scip... numpy-svn@scip...
Sun Aug 26 20:43:51 CDT 2007


Author: stefan
Date: 2007-08-26 20:43:26 -0500 (Sun, 26 Aug 2007)
New Revision: 4015

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/src/arraytypes.inc.src
   trunk/numpy/core/src/multiarraymodule.c
   trunk/numpy/core/tests/test_multiarray.py
Log:
Remove hack to fix putmask and apply Eric's patch instead.


Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2007-08-26 09:24:39 UTC (rev 4014)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2007-08-27 01:43:26 UTC (rev 4015)
@@ -1050,7 +1050,7 @@
 typedef void (PyArray_FastClipFunc)(void *in, npy_intp n_in, void *min,
                                     void *max, void *out);
 typedef void (PyArray_FastPutmaskFunc)(void *in, void *mask, npy_intp n_in,
-                                       void *values, npy_intp nv, npy_intp swap);
+                                       void *values, npy_intp nv);
 
 typedef struct {
         npy_intp *ptr;

Modified: trunk/numpy/core/src/arraytypes.inc.src
===================================================================
--- trunk/numpy/core/src/arraytypes.inc.src	2007-08-26 09:24:39 UTC (rev 4014)
+++ trunk/numpy/core/src/arraytypes.inc.src	2007-08-27 01:43:26 UTC (rev 4015)
@@ -2109,18 +2109,16 @@
 #type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble,cfloat, cdouble, clongdouble#
 */
 static void
-@name@_fastputmask(@type@ *in, Bool *mask, intp ni, @type@ *vals, intp nv, int swap)
+@name@_fastputmask(@type@ *in, Bool *mask, intp ni, @type@ *vals, intp nv)
 {
         register npy_intp i;
         @type@ s_val;
-        int elsize = sizeof(@type@);
 
         if (nv == 1) {
                 s_val = *vals;
                 for (i = 0; i < ni; i++) {
                         if (mask[i]) {
                                 in[i] = s_val;
-                                if (swap) byte_swap_vector(in+i, 1, elsize);
                         }
                 }
         }
@@ -2128,7 +2126,6 @@
                 for (i = 0; i < ni; i++) {
                         if (mask[i]) {
                                 in[i] = vals[i%nv];
-                                if (swap) byte_swap_vector(in+i, 1, elsize);
                         }
                 }
         }

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2007-08-26 09:24:39 UTC (rev 4014)
+++ trunk/numpy/core/src/multiarraymodule.c	2007-08-27 01:43:26 UTC (rev 4015)
@@ -4104,9 +4104,9 @@
                         "the same size");
         goto fail;
     }
-
+    Py_INCREF(self->descr);
     values = (PyArrayObject *)\
-        PyArray_ContiguousFromAny(values0, self->descr->type_num, 0, 0);
+        PyArray_FromAny(values0, self->descr, 0, 0, NPY_CARRAY, NULL);
     if (values == NULL) goto fail;
     nv = PyArray_SIZE(values);        /* zero if null array */
     if (nv <= 0) {
@@ -4138,8 +4138,7 @@
             }
         }
         else {
-            func(dest, mask->data, ni, values->data, nv,
-                             !PyArray_ISNOTSWAPPED(self));
+            func(dest, mask->data, ni, values->data, nv);
         }
     }
 

Modified: trunk/numpy/core/tests/test_multiarray.py
===================================================================
--- trunk/numpy/core/tests/test_multiarray.py	2007-08-26 09:24:39 UTC (rev 4014)
+++ trunk/numpy/core/tests/test_multiarray.py	2007-08-27 01:43:26 UTC (rev 4015)
@@ -404,7 +404,7 @@
         return x
 
     def check_basic(self):
-        for inplace in [False, True]: 
+        for inplace in [False, True]:
             self._clip_type('float',1024,-12.8,100.2, inplace=inplace)
             self._clip_type('float',1024,0,0, inplace=inplace)
 
@@ -452,13 +452,13 @@
         return ((self.tst_byteorder,dtype) for dtype in ('>i4','<i4'))
 
     def test_record_array(self):
-##         Not supported yet
-##
-##         rec = N.array([(-5, 2.0, 3.0), (5.0, 4.0, 3.0)],
-##                       dtype=[('x', '<f8'), ('y', '<f8'), ('z', '<f8')])
-##         N.putmask(rec['x'],[True,False],10)
-##         assert_array_equal(rec['x'],[10,5])
-        pass
+        # Note mixed byteorder.
+        rec = N.array([(-5, 2.0, 3.0), (5.0, 4.0, 3.0)],
+                      dtype=[('x', '<f8'), ('y', '>f8'), ('z', '<f8')])
+        N.putmask(rec['x'],[True,False],10)
+        assert_array_equal(rec['x'],[10,5])
+        N.putmask(rec['y'],[True,False],10)
+        assert_array_equal(rec['y'],[10,4])
 
     def test_masked_array(self):
         ## x = N.array([1,2,3])



More information about the Numpy-svn mailing list