[Scipy-svn] r3233 - trunk/Lib/sandbox/maskedarray

scipy-svn@scip... scipy-svn@scip...
Tue Aug 14 13:29:08 CDT 2007


Author: pierregm
Date: 2007-08-14 13:29:06 -0500 (Tue, 14 Aug 2007)
New Revision: 3233

Modified:
   trunk/Lib/sandbox/maskedarray/mrecords.py
Log:
maskedarray
mrecords : fixed a pb when creating mrecords from a list of tuples

timeseries
lib.moving_funcs : fixed a pb with the mov_xxx functions: the original data	was affected in certain cases

Modified: trunk/Lib/sandbox/maskedarray/mrecords.py
===================================================================
--- trunk/Lib/sandbox/maskedarray/mrecords.py	2007-08-14 18:28:58 UTC (rev 3232)
+++ trunk/Lib/sandbox/maskedarray/mrecords.py	2007-08-14 18:29:06 UTC (rev 3233)
@@ -135,11 +135,22 @@
             else:
                 _fieldmask = mask
         else:
-            _data = recarray(shape, dtype=descr)
-            _fieldmask = recarray(shape, dtype=mdescr)
-            for (n,v) in zip(_names, data):
-                _data[n] = numeric.asarray(v).view(ndarray)
-                _fieldmask[n] = getmaskarray(v)
+            try:
+                data = numeric.array(data, dtype=descr).view(recarray)
+                _data = data
+                if mask is nomask:
+                    _fieldmask = data.astype(mdescr)
+                    _fieldmask.flat = tuple([False]*len(mdescr))
+                else:
+                    _fieldmask = mask
+            except:
+                _data = recarray(shape, dtype=descr)
+                _fieldmask = recarray(shape, dtype=mdescr)
+                for (n,v) in zip(_names, data):
+                    print n, v
+                    print _data[n]
+                    _data[n] = numeric.asarray(v).view(ndarray)
+                    _fieldmask[n] = getmaskarray(v)
         #........................................
         _data = _data.view(cls)
         _data._fieldmask = _fieldmask
@@ -653,7 +664,7 @@
 if __name__ == '__main__':
     import numpy as N
     from maskedarray.testutils import assert_equal
-    if 1:
+    if 0:
         d = N.arange(5)
         m = MA.make_mask([1,0,0,1,1])
         base_d = N.r_[d,d[::-1]].reshape(2,-1).T



More information about the Scipy-svn mailing list