-
-
Notifications
You must be signed in to change notification settings - Fork 11k
The type conversion problem of array operations #11485
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
Hmm, that looks like a bug, and maybe a very old one. The array data type should dominate the scalar unless a float is involved. It may be intended behavior, but I cannot think why. |
Its the old problem of "oh a scalar, lets see what the minimum type is when considering the other array", and if the arrays type happens to be good enoug, it uses that... I.e. the |
Arggghhhh, I didn't know that was the policy, that's awful. I thought that within the same kind, the array type was always dominant, which is simple to understand and has the virtue that the output type only depends on the code, not the code and the input values. |
Yeah, that would make more sense, at least for python types (for numpy
types they could just be treated like an array too as an option, I find
it annoying that if I happen to have a 0d array things might suddenly
stop casting as well).
And we can put a warning anyway when the python scalar cannot cast
safely...
There have been a lot of discussions about this IIRC, but they always
somewhat died out from a lack of clarity what is right, and then the
fact that changing things seems tricky, I think the last time it
changed was 1.7, not quite sure what the behaviour was before.
|
Relevant is #10322, which here looks like:
|
Closing, this is effectively fixed by NEP 50 adoption in main/NumPy 2.0. |
The change of the variable type depends on the minimum of the array?
The text was updated successfully, but these errors were encountered: