Skip to content

[BUG] Fix PyTorch warning when slicing tensor with non-writable numpy arrays#2276

Open
andersendsa wants to merge 1 commit intosktime:mainfrom
andersendsa:pytorch_warning
Open

[BUG] Fix PyTorch warning when slicing tensor with non-writable numpy arrays#2276
andersendsa wants to merge 1 commit intosktime:mainfrom
andersendsa:pytorch_warning

Conversation

@andersendsa
Copy link
Copy Markdown

Reference Issues/PRs

Closes : #2273

What does this implement/fix? Explain your changes.

Replaced .to_numpy() with .tolist() on pandas Series before tensor indexing
in samplers.py and test_timeseries.py. This avoids the PyTorch UserWarning
about non-writable numpy arrays, since .tolist() returns a writable Python
list instead of a read-only numpy view from pandas.

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.
    Installed hooks using pre-commit install and verified with pre-commit run --all-files.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a03b984). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2276   +/-   ##
=======================================
  Coverage        ?   86.93%           
=======================================
  Files           ?      166           
  Lines           ?     9765           
  Branches        ?        0           
=======================================
  Hits            ?     8489           
  Misses          ?     1276           
  Partials        ?        0           
Flag Coverage Δ
cpu 86.93% <100.00%> (?)
pytest 86.93% <100.00%> (?)

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.

@andersendsa
Copy link
Copy Markdown
Author

Hi @phoeenniixx This pr passes all the tests and is ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Non‑writable NumPy array used for tensor slicing triggers PyTorch warning

1 participant