[Scipy-svn] r2900 - in trunk/Lib/sandbox/maskedarray: . tests

scipy-svn@scip... scipy-svn@scip...
Thu Apr 5 17:10:05 CDT 2007


Author: pierregm
Date: 2007-04-05 17:10:01 -0500 (Thu, 05 Apr 2007)
New Revision: 2900

Modified:
   trunk/Lib/sandbox/maskedarray/core.py
   trunk/Lib/sandbox/maskedarray/tests/test_core.py
Log:
core: enable to set mask=False on a scalar array

Modified: trunk/Lib/sandbox/maskedarray/core.py
===================================================================
--- trunk/Lib/sandbox/maskedarray/core.py	2007-04-05 19:53:28 UTC (rev 2899)
+++ trunk/Lib/sandbox/maskedarray/core.py	2007-04-05 22:10:01 UTC (rev 2900)
@@ -1307,8 +1307,11 @@
             if m is nomask:
                 res = self._data
             else:
-                if m.shape == () and m:
-                    return str(f)
+                if m.shape == ():
+                    if m:
+                        return str(f)
+                    else:
+                        return str(self._data)
                 # convert to object array to make filled work
 #CHECK: the two lines below seem more robust than the self._data.astype
 #                res = numeric.empty(self._data.shape, object_)
@@ -2640,33 +2643,3 @@
         y = x + masked
         assert_equal(y.shape, x.shape)
         assert_equal(y._mask, [True, True])
-#    if 0:
-#        a = arange(10)
-#        a[::3] = masked
-#        a.fill_value = 999
-#        a_pickled = cPickle.loads(a.dumps())
-#        assert_equal(a_pickled._mask, a._mask)
-#        assert_equal(a_pickled._data, a._data)
-#        assert_equal(a_pickled.fill_value, 999)
-#        #
-#        a = array(numpy.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)
-#        assert(isinstance(a_pickled._data,numpy.matrix))
-#    #
-#    
-#    #
-#    if 1:
-#        x = marray(numpy.linspace(-1.,1.,31),)
-#        x[:10] = x[-10:] = masked
-#        z = marray(numpy.empty((len(x),3), dtype=numpy.float_))
-#        z[:,0] = x[:]
-#        for i in range(1,3):
-#            idx = numpy.arange(len(x))
-#            numpy.random.shuffle(idx)
-#            z[:,i] = x[idx]
-#        #
-#        z.sort(0)
-#        
-    

Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py
===================================================================
--- trunk/Lib/sandbox/maskedarray/tests/test_core.py	2007-04-05 19:53:28 UTC (rev 2899)
+++ trunk/Lib/sandbox/maskedarray/tests/test_core.py	2007-04-05 22:10:01 UTC (rev 2900)
@@ -612,6 +612,15 @@
         #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx)
         #self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked)
     #........................
+    def check_scalar(self):
+        "Checks masking a scalar"
+        x = masked_array(0)
+        assert_equal(str(x), '0')
+        x = masked_array(0,mask=True)
+        assert_equal(str(x), str(masked_print_option))
+        x = masked_array(0, mask=False)
+        assert_equal(str(x), '0')
+    #........................
     def check_usingmasked(self):
         "Checks that there's no collapsing to masked"        
         x = masked_array([1,2])



More information about the Scipy-svn mailing list