-
Notifications
You must be signed in to change notification settings - Fork 51
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
RFC: define behavior for __setitem__
when the assigned value promotes to the array's dtype
#916
Comments
__setitem__
and in-place ops type promotion rules__setitem__
and in-place ops type promotion rules
In my opinion, the wording should be changed from
to
|
That wording change sounds fine to me. |
Assuming "promote
? If so, maybe the three rules can be summarized
Or maybe that is only the second and third rule. I suppose the first rule is independent, because it defines what can't happen. Footnotes
|
In this case I would favor a little bit of potential redundancy for the sake of clarity.
|
Should the new wording only affect the draft, or also be backported to previous versions? |
__setitem__
and in-place ops type promotion rules__setitem__
when the assigned value promotes to the array's dtype
@crusaderky Only the draft for this one, I think. |
__setitem__
states:https://data-apis.org/array-api/2024.12/API_specification/generated/array_api.array.__setitem__.html#array_api.array.__setitem__
The last line is majorly problematic in my opinion and should be revised.
These use cases are left to the library's discretion:
All these use cases are quietly allowed by numpy.
Sanity would dictate for them to be all disallowed, exactly like in binops.
If the last use case is allowed, it also opens the issue of in-place binops (
__iadd__
) etc.Whereas out-of-place binops unambiguously must cast the smaller dtype to the larger one and then perform the operation, what is the correct process for in-place ones, when lhs has smaller dtype than rhs?
or
which is the same as saying
? the output will subtly differ.
The text was updated successfully, but these errors were encountered: