[Numpy-svn] r4143 - trunk/numpy/core

numpy-svn@scip... numpy-svn@scip...
Sun Sep 30 05:48:10 CDT 2007


Author: stefan
Date: 2007-09-30 05:47:58 -0500 (Sun, 30 Sep 2007)
New Revision: 4143

Modified:
   trunk/numpy/core/ma.py
Log:
ma: output of .sum() should be scalar (patch by reggie,
closes ticket #557).


Modified: trunk/numpy/core/ma.py
===================================================================
--- trunk/numpy/core/ma.py	2007-09-30 10:41:27 UTC (rev 4142)
+++ trunk/numpy/core/ma.py	2007-09-30 10:47:58 UTC (rev 4143)
@@ -396,19 +396,20 @@
                 m = make_mask(m, copy=1)
                 m.shape = (1,)
         if m is nomask:
-            return masked_array (self.f.reduce (t, axis))
+            t = self.f.reduce(t, axis)
         else:
             t = masked_array (t, m)
             # XXX: "or t.dtype" below is a workaround for what appears
             # XXX: to be a bug in reduce.
-            t = self.f.reduce(filled(t, self.filly), axis, dtype=dtype or t.dtype)
+            t = self.f.reduce(filled(t, self.filly), axis,
+                              dtype=dtype or t.dtype)
             m = umath.logical_and.reduce(m, axis)
-            if isinstance(t, ndarray):
-                return masked_array(t, m, get_fill_value(target))
-            elif m:
-                return masked
-            else:
-                return t
+        if isinstance(t, ndarray):
+            return masked_array(t, m, get_fill_value(target))
+        elif m:
+            return masked
+        else:
+            return t
 
     def outer (self, a, b):
         "Return the function applied to the outer product of a and b."



More information about the Numpy-svn mailing list