-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG cannot specify second output to ufunc as keyword argument #4752
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
Comments
Currently the only way to specify multiple output arguments is as positional arguments. Using your example:
To add a different behavior (such as the tuple of arrays passed as a kwarg with |
Yeah, we should discuss it on the list, but everyone will be in favor :-) On Fri, Oct 17, 2014 at 2:42 AM, Jaime notifications@github.com wrote:
Nathaniel J. Smith |
I'm sure someone will not like the color of the bike shed... Just pinged the list, lets see if anyone cares. We should take advantage of me having the code of ufunc_object.c still fresh in memory. |
@jaimefrio - this has been quite a while, but maybe you are still well-versed enough in |
It is certainly no longer in the L1 cache, but I will try to find time to take a look again this weekend. If I can make sense of it I'll try pinging the list again: if I remember correctly, there wasn't a single response from the list last time. :-( |
I think this is one of those cases where silence can be read as consent.
|
Seems reasonable to me also. |
I have it working, but am getting this error when I run the tests:
The way I have it set up, it only accepts a single array to |
Should probably check with the list, but I doubt there are many people who There is a functionality benefit to allowing some out= arguments to be The current mechanism for this is ugly though, because you can provide the For the new api, maybe we should require that if a tuple is given, the In the mean time, I guess we should still allow out=arr to be equivalent to Possibly we should deprecate both positional output arguments and the use
|
Agreed with @njsmith - converting to |
I'll make a PR even if it's half cooked only, and we can have the discussion over the code, which will probably explain itself better than me. My current implementation already does what @njsmith proposes: tuple of |
Thanks, @jaimefrio! |
Currently, it does not seem possible to pass on an array to catch the second output of a
ufunc
via a keyword parameter:One can do
np.modf(1.333, out=a1)
, which works as expected. If one gives insteadnp.modf(1.333, out2=a2)
, the first part is assigned toa2
. (Note that the documentation suggests to useout1, out2
, but any characters afterout
simply seem to be skipped.)It would seem good to have the option of giving these as keyword arguments. One solution might be to have it be consistent with the usage in
__numpy_ufunc__
, i.e., one would givenp.modf(values, out=(a1, a2))
.The text was updated successfully, but these errors were encountered: