-
Notifications
You must be signed in to change notification settings - Fork 30
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
divide
and comparisons allow a greater range of Python integer and integer array combinations
#1771
Conversation
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_186 ran successfully. |
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_187 ran successfully. |
This example from gh-1711 still give unexpected result:
|
It won't after Numpy 2, because -2 will no longer be permitted to promote to uint32. In general it may be a good idea to go back and disallow overflows from Python integers in But arguably, this result is "correct" in that it follows the NEP-50 rule (Python scalar value does not determine output dtype), it's just undefined behavior. The alternative would be to cast to int64, but this wouldn't match how it's handled in Numpy 2. |
Indeed, with NumPy 2.0 in run-time environment, I am getting
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_193 ran successfully. |
…_py_ints This new weak type resolver checks if the scalar is outside of the range of the strong data type and if so, returns the minimum scalar type for the value.
c3283f2
to
655a5d9
Compare
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_193 ran successfully. |
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.
Thank you @ndgrigorian ! LGTM
This PR closes #1711 by aligning
divide
with Numpy 2.0 behavior.When a Python integer is out-of-bounds for a (strong, array) integer data type of the other input,
_resolve_weak_types_all_py_ints
usesnp.min_scalar_type
to find the minimum type that will fit it.This does not affect the output type of comparisons or
divide
, and therefore aligns with NEP-50 while permitting such workflows as:This also fixes a bug introduced in #1650 where comparisons between
uint64
data type arrays and Python integers larger than the maximum for the default integral data type no longer worked.