-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
BUG: Fix weak promotion with some mixed float/int dtypes #24681
Conversation
This reorganizes/simplifies promotion a bit, but unfortunately this means moving the promotion of our concrete DTypes with the abstract "weak" ones into the concrete DTypes making the order of "who deals with whom" fully defined by: complex' > floats > pycomplex > pyfloat > ints > pyint > bool where py<...> is the DType corresponding to the Python type. There are two points here: * "inexact" is the meaningful category not complex * previously, the abstract DTypes `pyfloat`, etc. knew about the concrete ones and there was some special handling for that. (as mentioned above, this is gone now) Why was it this complicated?! I think the initial code wanted to deal with value-based promotion and the abstract DTypes could have had a value attached to them. There was thus more code later on, dealing with abstract DTypes more concretely (rather than identical to the rest). This is now gone, concrete DTypes promote basically the same as their concrete counter-parts. This makes the promotion logic simpler (and I think still just as correct), although the concrete type promotion now needs to know about it.
A bit over my head, but I did check that this branch against SciPy |
@ev-br can you have a look at this one and see if we need to change anything in our implementation? |
Can we please review/merge this? It's a clear bug fix in something that is vital to move forward. (not that it is a big thing in that, but still) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a few small documentation nits. I will merge soon if you want to ignore them.
Co-authored-by: Matti Picus <matti.picus@gmail.com>
Thanks @seberg |
This reorganizes/simplifies promotion a bit, but unfortunately this means moving the promotion of our concrete DTypes with the abstract "weak" ones into the concrete DTypes making the order of "who deals with whom" fully defined by:
where py<...> is the DType corresponding to the Python type. There are two points here:
pyfloat
, etc. knew about the concrete ones and there was some special handling for that. (as mentioned above, this is gone now)Why was it this complicated?! I think the initial code wanted to deal with value-based promotion and the abstract DTypes could have had a value attached to them.
There was thus more code later on, dealing with abstract DTypes more concretely (rather than identical to the rest).
This is now gone, concrete DTypes promote basically the same as their concrete counter-parts. This makes the promotion logic simpler (and I think still just as correct), although the concrete type promotion now needs to know about it.