diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-06-07 03:43:26 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-06-07 03:43:26 +0000 |
commit | 22357e639f2793ca3f2e75ef3b96c70cc406343f (patch) | |
tree | 829d3d7915b732dc19f2f79ed3e2cc7493107ebb /numpy/lib/function_base.py | |
parent | 0db76715c5f019222db48cc28a6a49d086a8a939 (diff) | |
download | numpy-22357e639f2793ca3f2e75ef3b96c70cc406343f.tar.gz |
CLN: Cleanup nanops code a bit. Patch is from Tony Yu.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index d35b0efd2..1a93b5a1d 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1295,15 +1295,15 @@ def _nanop(op, fill, a, axis=None): """ 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) |