BUG: don't silence warnings in ufunc.reduce#9020
Conversation
8273a08 to
9794fd1
Compare
|
Tests fail right now because we're now being warned about more things. Most of these are correct (ie, testing nan behavior), and need test updates. I don't think these should warn at all when invoked with
Also, one test fails due to an overflow that was silenced! Which raises a good point - overflow in |
c00d928 to
06bbb23
Compare
|
Ok, all fixed I think. Probably easiest to review this commit-by-commit, since the first refactor is noisy |
|
maximum/minimum should warn, nan's may lead to unexpected results. We also have the nanmax/nanmin functions for these. |
|
What's the history behind having both |
06bbb23 to
9ef93b5
Compare
|
@juliantaylor: Ok, warnings are now only squashed in fmin and fmax |
This comment has been minimized.
This comment has been minimized.
1656520 to
33c269c
Compare
This comment has been minimized.
This comment has been minimized.
|
Needs rebase. |
|
|
@charris: Rebased |
mhvk
left a comment
There was a problem hiding this comment.
Mostly nitpicks, but also warnings in the compilation:
numpy/core/src/umath/ufunc_object.c:3619:15: warning: unused variable 'out_obj' [-Wunused-variable]
numpy/core/src/umath/reduction.c:562:5: warning: implicit declaration of function 'PyUFunc_clearfperr' [-Wimplicit-function-declaration]
I think the first is likely a result of the rebase; the definition can be removed from l.3619, as it is moved to 3655.
The second I'm not sure about; a missing include perhaps?
numpy/core/src/umath/extobj.c
Outdated
numpy/core/src/umath/extobj.h
Outdated
numpy/core/src/umath/reduction.c
Outdated
There was a problem hiding this comment.
Since it comes after funcname in the signature, move it below it here as well.
numpy/core/src/umath/reduction.h
Outdated
There was a problem hiding this comment.
Add errormask to the description above as well.
|
Don't understand how this patch could have introduced the warning about |
This makes it visible inside other files, like reduction.c Apart from the includes, everything here is just a direct move - there are no code changes
Previously, these would do so when encountering nans
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
|
Nitpicks addressed, but still not sure about that missing function prototype. Works fine on MSVC though... |
|
This now looks all OK. The one remaining question is whether this is worth backporting. Including the MAINT commits, it is a bit of a large code shuffle, but it does fix a bug. @charris? |
|
@mhvk That's a lot of code. If the bug is long standing I would leave it for 1.14. I'm OK with backporting fixes to I'm going to release the 1.13.0 final at the beginning of next week. |
Not really - almost all of it (ie, the first MAINT commit) is just moving code from one file to another. I agree though, this isn't terribly deserving of a backport |
|
|
||
| #include "ufunc_object.h" /* for npy_um_str_pyvals_name */ | ||
|
|
||
| #if USE_USE_DEFAULTS==1 |
There was a problem hiding this comment.
Again, this is verbatim from the other file.
| int res; | ||
|
|
||
| PyUFunc_NUM_NODEFAULTS += 1; | ||
| res = PyUFunc_GetPyValues("test", &bufsize, &errmask, &errobj); |
There was a problem hiding this comment.
Beats me - again, just a maintenance change, moving this from the other file
| return 0; | ||
| } | ||
|
|
||
| NPY_ALLOW_C_API; |
There was a problem hiding this comment.
Does this buy anything? A small speedup in error handling, which should be rare, doesn't seem worth it.
|
Quoting the first commit:
I'd rather not open the can of poorly-documented worms that is how |
|
@charris: Any other remarks here? |
|
Nope, might as well put it in. Thanks Eric. |
|
Please do not backport this - no need, and it will show warnings in the scipy test suite (and other packages probably) for released versions of scipy for which the test suite should be clean. |
Needed a file of helper functions so that this was actually visible in
reduction.c. This move is in the first commit.Fix itself is trivial once things are visible.
Fixes #8954