-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
nditer "out" operands are not always accessible #10956
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
I am thinking the solution is to make the |
Not clear. What should operands point to if dtype is specified:
If Maybe the issue is more "what do we mean by operands" When using
or using close:
|
I should have addressed the original issue and not diverged into discussion of
I am reasonably sure this could not happen when the out array is specified as None.
Replace that with "cannot be accessed once the writeback has occurred" and the issue no longer is specific to the new code, it existed before as well since the only way to trigger the writeback was via Changing
This is used in the C level by einsum, as I discovered when fixing a related issue #11381, see the use of If desired, one could always access the |
True, that would break. On the other hand, if you added a By the way, Just to avoid confusing myself, there are three arrays we are discussing: The "original array" operand, the "temp array" operand currently accessible as The issue here is that What about simply adding a new attribute, |
See some discussion in #10951.
The issue is that the nditer
operands
attribute does not always refer to the actual operand array, but rather to the temporary buffer/copy of the operand array, despite what the nditer docstring says.This is a problem for code like:
since the returned value could in principle be a temporary buffer, rather than the newly created 'out' array. In practice, this hasn't been a problem because the out arrays are never buffered, I think.
Because of our recent improvements to the nditer as a context manager, and #10951, there is a second problem that the operands cannot be accessed once the iterator context is exited. For instance, this means the
return
statement above can't currently be placed outside the with statement, even though in principle that is where it should go because the operand is only "written back to" at context exit.The text was updated successfully, but these errors were encountered: