-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: __numpy_ufunc__ passes on only a single output argument #4160
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
This looks like a pretty serious bug in |
Yep, 1.9 blocker. The case if multiple output args is ignored in the implementation. How to deal with them is also unspecified in the spec. This is probably simple to fix, however, now that we are not bound by any backward compatibility constraints. |
@pv - the docstrings of both
This would suggest one possible choice, of having Note, though, that one cannot give these as keyword arguments in the direct call either. While
ps. while trying the above, I realised the test on whether something is a keyword argument is simply whether it starts with "out"; |
Iirc the clearer ufunc calling convention is out=(arr1, arr2), so that's The outblahblah thing sounds like a bug too, but a different one - maybe
|
So in the /* If we have more args than nin, the last one must be `out`.*/
if (nargs > nin) {
obj = PyTuple_GET_ITEM(args, nargs - 1);
PyDict_SetItemString(normal_kwds, "out", obj);
} I think what we actually want to do is grab all the positional arguments after the I'll try this out and get back to y'all. edit: |
Here is how I propose we handle output variables:
Note that this does not change the proposed interface. Does this sound okay? cc @njsmith @pv |
See pull 4171. |
Fixed in gh-4171 |
I'm trying to use
__numpy_ufunc__
for theQuantity
subclass in astropy (which adds and propagates units associated with the array), and while mostly it is a joy compared to the previous__array_prepare__
etc tangle, for functions with two outputs there is a problem, in that only one output is passed on among the keyword arguments. This can be seen from the following example:The text was updated successfully, but these errors were encountered: