Skip to content

Conversation

@cngmid
Copy link
Contributor

@cngmid cngmid commented Oct 31, 2025

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_write is set to True, 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.py
But the real way to test it is to set globally pd.options.mode.copy_on_write = True and see whther a warning appears somewhere.

Any other comments?

I think pandas v3.0 will enforce this flag.

PR checklist

  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
  • Added/modified tests
  • Used pre-commit hooks when committing to ensure that code is compliant with hooks. Install hooks with pre-commit install.
    To run hooks independent of commit, execute pre-commit run --all-files

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@c78b273). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pytorch_forecasting/data/timeseries/_timeseries.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1989   +/-   ##
=======================================
  Coverage        ?   86.97%           
=======================================
  Files           ?      160           
  Lines           ?     9463           
  Branches        ?        0           
=======================================
  Hits            ?     8230           
  Misses          ?     1233           
  Partials        ?        0           
Flag Coverage Δ
cpu 86.97% <91.66%> (?)
pytest 86.97% <91.66%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fkiraly fkiraly added the bug Something isn't working label Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

[BUG] Torch doesn't support the conversion of non-writeable numpy array

2 participants