Skip to content

[BUG] Fixing bug #1930 with proper syntax #1950

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cngmid
Copy link
Contributor

@cngmid cngmid commented Aug 20, 2025

Reference Issues/PRs

Fixes #1930.

When time_idx or some other integer feature is included in the unknow reals, the dataset/dataloader elements are converted into the wrong dtype.

What does this implement/fix? Explain your changes.

Modify the function the method TimeSeriesDataSet._data_to_tensors._to_tensor()

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

Any other comments?

PR checklist

  • [ x] 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.
  • [x ] Added/modified tests

Copy link

codecov bot commented Aug 20, 2025

Codecov Report

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

Files with missing lines Patch % Lines
pytorch_forecasting/data/timeseries/_timeseries.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1950   +/-   ##
=======================================
  Coverage        ?   87.06%           
=======================================
  Files           ?      136           
  Lines           ?     8626           
  Branches        ?        0           
=======================================
  Hits            ?     7510           
  Misses          ?     1116           
  Partials        ?        0           
Flag Coverage Δ
cpu 87.06% <80.00%> (?)
pytest 87.06% <80.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.

@cngmid cngmid changed the title Fixing bug #1930 with proper syntax [BUG] Fixing bug #1930 with proper syntax Aug 20, 2025
"""
if not isinstance(cols, list) and cols not in data.columns:
return None
if isinstance(cols, list) and len(cols) == 0:
dtypekind = "f"
elif isinstance(cols, list): # and len(cols) > 0
dtypekind = data.dtypes[cols[0]].kind
# dtypekind = data.dtypes[cols[0]].kind
dtypekind = data[cols].to_numpy().dtype.kind
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we doing this? It feels wasteful to do the conversion for the entire data container, instead of looking up the dtype.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I have a question about to_numpy - should we not avoid conversion of the entire data to numpy?

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] TimeSeriesDataSet wrong dtype when time_idx is included
2 participants