diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-11-21 14:39:12 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-03-07 21:09:53 -0700 |
commit | 7fa628494443fb18afb7aed3061b267b42177a83 (patch) | |
tree | aecad61f124b5b9ebd686e64d466a0504ddc3d96 /numpy/lib/function_base.py | |
parent | c199d963e480667631c67d7a7956c195a5686c40 (diff) | |
download | numpy-7fa628494443fb18afb7aed3061b267b42177a83.tar.gz |
ENH: Use fmax.reduce and fmin.reduce to implement nanmax and nanmin.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index b2d2856d6..dd792c509 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1447,8 +1447,7 @@ def nanmin(a, axis=None): Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number. - If the input has a integer type, an integer type is returned unless - the input contains NaNs and infinity. + If the input has a integer type the function is equivalent to np.min. Examples @@ -1469,7 +1468,11 @@ def nanmin(a, axis=None): -inf """ - return _nanop(np.min, np.inf, a, axis) + a = np.asanyarray(a) + if axis is not None: + return np.fmin.reduce(a, axis) + else: + return np.fmin.reduce(a.flat) def nanargmin(a, axis=None): """ @@ -1541,8 +1544,7 @@ def nanmax(a, axis=None): Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number. - If the input has a integer type, an integer type is returned unless - the input contains NaNs and infinity. + If the input has a integer type the function is equivalent to np.max. Examples -------- @@ -1562,7 +1564,11 @@ def nanmax(a, axis=None): inf """ - return _nanop(np.max, -np.inf, a, axis) + a = np.asanyarray(a) + if axis is not None: + return np.fmax.reduce(a, axis) + else: + return np.fmax.reduce(a.flat) def nanargmax(a, axis=None): """ |