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
Add notes on overwriting gufunc inputs to docs #4957
Conversation
It is possible to write gufuncs that overwrite input arrays, but the new values may not be visible outside the gufunc execution, for example if a temporary array is passed in. This commit adds notes to the documentation warning the user of this case.
Added WIP tag while I see what the build failures are. |
Removed WIP - I see master is broken with the same problem. |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Thanks for the PR. This is a helpful clarification. Couple of minor edits suggested else good to merge. Thanks again!
docs/source/user/vectorize.rst
Outdated
[4.2, 4.2, 4.2], | ||
[4.2, 4.2, 4.2]]) | ||
|
||
This works because Numpy passes a pointer to the input data directly into the |
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.
This works because Numpy passes a pointer to the input data directly into the | |
This works because NumPy can pass the input data directly into the `init_values` function as the data `dtype` matches that of the declared argument. |
Or something like ^. I think this needs to not refer to pointers and note that it's the dtype
match that prevents the copy.
Co-Authored-By: stuartarchibald <stuartarchibald@users.noreply.github.com>
Thanks for the review - all suggestions now applied. I did modify the suggestion about referring to input data rather than pointers, as it left a trailing half-sentence, but otherwise it is applied as you suggested. |
Thanks for the fixes so far, one more |
Co-Authored-By: stuartarchibald <stuartarchibald@users.noreply.github.com>
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.
Thanks for the patch!
As discussed in #4952, one cannot rely on writing to gufunc input values. This PR adds some notes on this to the documentation. I decided against explicitly stating that you shouldn't do it, because I understand it is a "feature" that people make use of from time to time.