8000 ufunc.reduce hides warnings · Issue #8954 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ufunc.reduce hides warnings #8954

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
eric-wieser opened this issue Apr 17, 2017 · 4 comments
Closed

ufunc.reduce hides warnings #8954

eric-wieser opened this issue Apr 17, 2017 · 4 comments

Comments

@eric-wieser
Copy link
Member
eric-wieser commented Apr 17, 2017

Arguments that would cause ufunc.__call__ to throw a warning seem to not do so when passed to ufunc.reduce:

Bug or feature?

In [24]: np.minimum(*[1, np.nan])
RuntimeWarning: invalid value encountered in minimum
Out[24]: nan

In [25]: np.minimum.reduce([1, np.nan])
Out[25]: nan

# not just minimum
In [28]: np.divide(*[1, 0])
RuntimeWarning: divide by zero encountered in true_divide
Out[28]: inf

In [29]: np.divide.reduce([1, 0])
Out[29]: inf
@njsmith
Copy link
Member
njsmith commented Apr 17, 2017 via email

@eric-wieser
Copy link
Member Author
eric-wieser commented Apr 17, 2017

This would be quite a user visible change, as min would all start warning on nans

@njsmith
Copy link
Member
njsmith commented Apr 17, 2017

Yeah. You could check on the list I guess if you're worried. But adding new useful warnings isn't generally a compatibility break, and numpy already provides good tools to control these particular warnings if people don't like the chatter.

@eric-wieser
Copy link
Member Author

This is a bit of a pain - _check_ufunc_fperr is not visible inside reduction.c

eric-wieser added a commit to eric-wieser/numpy that referenced this issue Jun 2, 2017
The two most visible consequences are warnings for:
* np.min and np.max when inputs contain nan
* np.sum when the summation (of floats) overflows

Implementation taken from the code for ufunc.__call__

Fixes numpy#8954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0