-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Attempt to fix bug with Quantity.__rmul__ and Numpy arrays #899
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
… when the array is the left hand side operand (this does not work yet, because Quantity also has an __array__ method which appears to take precedence).
|
I've reported this as a possible issue on Numpy: numpy/numpy#3164 |
|
The only solution I can think of for now is to actually remove the but at least that won't raise a warning, so maybe it's not such a bad thing? |
|
Removing |
|
I don't understand--what's the point of |
|
@iguananaut - |
|
Ah, I understand now. Hm. That's annoying. Will have to think on this a bit. |
|
Apologies for ignorance of the design history of |
|
@taldcroft - |
|
I think we could do that so long as Quantity can be an array-scalar (curse Numpy for even coming up with such a concept ;) |
|
Even though the array scalar has caused me many pains, now that I'm used to it I have a grudging respect. I think there would be just be some different problems if there were no array scalar. For the purposes of Quantity and the possibility of subclassing ndarray, here is what So there is an array scalar that comes out, but it lost its Column-ness. If I recall that was on purpose, but for Quantity obviously the array scalar still needs to be a Quantity. Something I have lurking in the back of my mind always is integrating Quantity and Table Columns. You should be able to have a Table column act like a quantity. But honestly I don't quite know how to make this work nicely. |
|
@taldcroft I agree--eventually these concepts need to start coming together more cohesively, with nddata in the mix too. |
|
See #929 for the start of an implementation in which |
|
Fixed in #929! |
The current behavior of multiplying arrays with quantities is inconsistent:
the first behavior is correct. The problem is that the
Quantityclass needs__array_priority__to be set likeUnithas, and this PR does this.However, note that this doesn't yet work, because it seems that the
__array__method takes precedence over even checking__array_priority__. I'll look into it a bit more, but if anyone has any ideas, please let me know!