[BUG] Torch doesn't support the conversion of non-writeable numpyFix non-writeable encoder issue and update tests #1989
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Fixes #1987
What does this implement/fix? Explain your changes.
When converting pandas objects to numpy, the resulting arrays are non-writeable if the option
pd.options.mode.copy_on_writeis set toTrue, which will be the default in future pandas versions.PyTorch does not support non-writable tensors. It warns that "writing to this tensor will result in undefined behavior".
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
Added test function to
tests/test_data/test_timeseries.pyBut the real way to test it is to set globally
pd.options.mode.copy_on_write = Trueand see whther a warning appears somewhere.Any other comments?
I think pandas v3.0 will enforce this flag.
PR checklist
pre-commit install.To run hooks independent of commit, execute
pre-commit run --all-files