[Numpy-svn] r8459 - trunk/numpy/lib

numpy-svn@scip... numpy-svn@scip...
Sun Jun 6 22:43:26 CDT 2010


Author: charris
Date: 2010-06-06 22:43:26 -0500 (Sun, 06 Jun 2010)
New Revision: 8459

Modified:
   trunk/numpy/lib/function_base.py
Log:
CLN: Cleanup nanops code a bit. Patch is from Tony Yu.

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2010-06-07 03:43:19 UTC (rev 8458)
+++ trunk/numpy/lib/function_base.py	2010-06-07 03:43:26 UTC (rev 8459)
@@ -1295,15 +1295,15 @@
 
     """
     y = array(a, subok=True)
-    mask = isnan(a)
 
     # We only need to take care of NaN's in floating point arrays
-    if not np.issubdtype(y.dtype, np.integer):
-        # y[mask] = fill
-        # We can't use fancy indexing here as it'll mess w/ MaskedArrays
-        # Instead, let's fill the array directly...
-        np.putmask(y, mask, fill)
-
+    if np.issubdtype(y.dtype, np.integer):
+        return op(y, axis=axis)
+    mask = isnan(a)
+    # y[mask] = fill
+    # We can't use fancy indexing here as it'll mess w/ MaskedArrays
+    # Instead, let's fill the array directly...
+    np.putmask(y, mask, fill)
     res = op(y, axis=axis)
     mask_all_along_axis = mask.all(axis=axis)
 



More information about the Numpy-svn mailing list