8000 Speedup the reduce method of the maximum minimum family of ufuncs. by charris · Pull Request #18 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Speedup the reduce method of the maximum minimum family of ufuncs. #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
ENH: Use fmax.reduce and fmin.reduce to implement nanmax and nanmin.
  • Loading branch information
charris committed Nov 21, 2010
commit f4aec4bec3bd89fea188bfd89d844cb63c22ca1a
20 changes: 14 additions & 6 deletions numpy/lib/function_base.py
5CCE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1469,7 +1468,12 @@ def nanmin(a, axis=None):
-inf

"""
return _nanop(np.min, np.inf, a, axis)
#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):
"""
Expand Down Expand Up @@ -1541,8 +1545,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
--------
Expand All @@ -1562,7 +1565,12 @@ def nanmax(a, axis=None):
inf

"""
return _nanop(np.max, -np.inf, a, axis)
#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):
"""
Expand Down
0