API: Do not consider subclasses for NEP 50 weak promotion#26905
API: Do not consider subclasses for NEP 50 weak promotion#26905mattip merged 2 commits intonumpy:mainfrom
Conversation
This disables remaining checks for subclasses of floats. We only apply the weak rules to literals, and thus just ignore subclasses.
1d9b38c to
f3b669d
Compare
mhvk
left a comment
There was a problem hiding this comment.
I guess this is because isinstance(np.float64(1.), float) is True, right? I guess in principle another float subclass might exist for which weak promotion might make sense, and an alternative might be to explicitly exclude np.generic subclasses. But since that only makes things slower, probably best to do what you have here! (We can always revisit if the need arises.)
|
I think the build failures on the OpenBLAS CI are real. Might just be a matter of giving |
|
Fun that it suddenly shows up, it isn't new. Anyway, harmless but not wrong, easy enough to avoid. |
This is a subtlety that we might otherwise run into in Python, I guess. So a bit :).
Either way, in some future a custom DType could probably create custom weak scalars if that comes up. But that would have complicated things (and this was difficult enough). Once legacy promotion paths are gone, I suspect one could attack it. Although, I honestly doubt it is worthwhile to do it even if we can. |
|
Thanks, that all makes sense! |
|
Thanks @seberg |
This disables remaining checks for subclasses of floats. We only
apply the weak rules to literals, and thus just ignore subclasses.
Closes gh-26852
Draft because it is based on gh-26904