-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG __numpy_ufunc__ does not properly deal with NotImplemented #5074
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
The behavior you are seeing does not appear to be due to
|
The problem in this case is that a part of the Python binop gh-4815 does not seem to be directly related to this, as it's about precedence of Python binops vs. ufuncs. |
@pv - I'm afraid your explanation still leaves me a bit confused: why is the |
The documentation is here: |
The documentation would certainly not lead one to predict the behaviour seen 😄 The clue would seem to be what you mentioned above, that the binop Or is the problem perhaps that in this case the list is interpreted as an Hmm, yes, a simple test would seem to confirm that:
Rather presumptive of ndarray to think I wanted an ndarray class back! Is solving this an option at all, or is there so much legacy based on this that one better not even attempt it? |
Oops, sorry, I now see you sent a much longer explanation. This does clarify it. I guess this really only leaves the question whether there so much legacy based on this that one better not even attempt trying move the binop stuff out of the ufunc. |
In principle moving the logic around is possible --- it's just somewhat |
I'm closing this one, since it is, effectively, a duplicate of #5844. |
In continuing to try to get astropy's
Quantity
to behave with__numpy_ufunc__
, I found what probably is another bug. One of our tests checks that an integer can be used as an__index__
to, e.g., multiply a list, as in:(which yields
['a', 'b', 'a', 'b']
).But if I make a trivial class that implements
__numpy_ufunc__
, theNotImplemented
does not seem to be passed on correctly:yields
p.s. This may be related to #4815
The text was updated successfully, but these errors were encountered: