-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
ENH: add warning when calling ufunc with 'where' and without 'out' #29813
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I assume this is rare enough that introducing a warning is not a problem and it is very simple to remove the warning after all.
So I am in favor of trying this, approving, but the comments should be (mostly) addressed.
Test changes look good, the only ones I would worry about would be __array_wrap__
related, and those don't seem touched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, nice; we really should have done this earlier...
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! (I think my last comment was wrong, though)
Is it possible to add a stacklevel value to the warning, because it'd be nice to see the warnings caller. |
The warning already has the best possible stacklevel since it's in C (so no need to add one). But of course sometimes ufuncs are called indirectly (e.g. mean/var maybe). I am not sure if there is a nice way to add |
…umpy#29813) * add warning when calling ufunc with 'where' and without 'out' * DOC: add a release note Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
Closes #29804, related to # #17192, #29561 and maybe more
Users naively add a
where
argument without a properout
argument, and are surprised when theFalse
values of the where mask are uninitialized. This PR adds a warning. The warning can be surpressed by usingwhere=mask, out=None
. That came in handy in some obscure tests.