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

scipy-svn@scip... scipy-svn@scip...
Thu Feb 22 21:25:49 CST 2007


Author: pierregm
Date: 2007-02-22 21:25:46 -0600 (Thu, 22 Feb 2007)
New Revision: 2755

Modified:
   trunk/Lib/sandbox/maskedarray/core.py
   trunk/Lib/sandbox/maskedarray/mrecords.py
Log:
mrecords : fixed _getformats for the case when data is a (subclass of) recarray
core     : in array_finalize, use fromnumeric.reshape instead of setting shape

Modified: trunk/Lib/sandbox/maskedarray/core.py
===================================================================
--- trunk/Lib/sandbox/maskedarray/core.py	2007-02-23 03:16:56 UTC (rev 2754)
+++ trunk/Lib/sandbox/maskedarray/core.py	2007-02-23 03:25:46 UTC (rev 2755)
@@ -1171,7 +1171,7 @@
             else:
                 self._mask.flat = newmask
         if self._mask.shape:
-            self._mask.shape = self.shape
+            self._mask = numeric.reshape(self._mask, self.shape)
     _setmask = __setmask__
     
     def _get_mask(self):

Modified: trunk/Lib/sandbox/maskedarray/mrecords.py
===================================================================
--- trunk/Lib/sandbox/maskedarray/mrecords.py	2007-02-23 03:16:56 UTC (rev 2754)
+++ trunk/Lib/sandbox/maskedarray/mrecords.py	2007-02-23 03:25:46 UTC (rev 2755)
@@ -41,7 +41,7 @@
 def _getformats(data):
     """Returns the formats of each array of arraylist as a comma-separated 
     string."""
-    if isinstance(data, record):
+    if hasattr(data,'dtype'):
         return ",".join([desc[1] for desc in data.dtype.descr])
     
     formats = ''
@@ -644,4 +644,15 @@
     return newdata
         
 ################################################################################
-  
\ No newline at end of file
+if __name__ == '__main__':
+    import numpy as N
+    if 1:
+        d = N.arange(5)
+        m = MA.make_mask([1,0,0,1,1])
+        base_d = N.r_[d,d[::-1]].reshape(2,-1).T
+        base_m = N.r_[[m, m[::-1]]].T
+        base = MA.array(base_d, mask=base_m)    
+        mrecord = fromarrays(base.T,)
+        
+        mrec = MaskedRecords(mrecord)
+        
\ No newline at end of file



More information about the Scipy-svn mailing list