Skip to content

[BUG]: Fixed the incorrect time propagation#2264

Open
Chetansahney wants to merge 4 commits intosktime:mainfrom
Chetansahney:fix/incorrect-time-propagation
Open

[BUG]: Fixed the incorrect time propagation#2264
Chetansahney wants to merge 4 commits intosktime:mainfrom
Chetansahney:fix/incorrect-time-propagation

Conversation

@Chetansahney
Copy link
Copy Markdown

Reference Issues/PRs

Fixes #2263

What does this fix? Explain your changes.

This fixes an issue where history_time_idx and future_time_idx in pytorch_forecasting/data/_tslib_data_module.py could be generated from synthetic sequential indices (torch.arange(...)) instead of real timesteps.
The implementation now propagates true timesteps from processed_data["timestep"], preserving non-zero and irregular time indices.

What should a reviewer concentrate their feedback on?

  • Correctness of history_time_idx / future_time_idx construction from processed_data["timestep"]
  • Any side effects on window slicing/batching behavior in TSLib v2
  • Regression test coverage for irregular/non-zero time index scenarios

Did you add any tests for the change?

Yes. Added:
pytorch_forecasting/data/tests/test_tslib_data_module.py::test_tslib_dataset_preserves_original_time_idx

Also validated with:

  • ruff check on changed files

Any other comments?

There is a pre-existing unrelated baseline failure in full test_tslib_data_module.py (test_multivariate_target, list-vs-shape assertion), observed prior to this fix.

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

@Chetansahney Chetansahney changed the title Fix/incorrect time propagation [BUG]: Fixed the incorrect time propagation Apr 18, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 55.00000% with 9 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@818a84d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...h_forecasting/data/tests/test_tslib_data_module.py 0.00% 8 Missing ⚠️
pytorch_forecasting/data/_tslib_data_module.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2264   +/-   ##
=======================================
  Coverage        ?   86.93%           
=======================================
  Files           ?      166           
  Lines           ?     9783           
  Branches        ?        0           
=======================================
  Hits            ?     8505           
  Misses          ?     1278           
  Partials        ?        0           
Flag Coverage Δ
cpu 86.93% <55.00%> (?)
pytest 86.93% <55.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.

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] : Incorrect time index propagation in v2 datamodule output

1 participant