Skip to content

[BUG] Fix issue with plot_prediction_actual_by_variable unsupported operand type(s) for *: 'numpy.ndarray' and 'Tensor' #1903

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 7 commits into
base: main
Choose a base branch
from

Conversation

fnhirwa
Copy link
Member

@fnhirwa fnhirwa commented Jun 26, 2025

fixes #1822

This PR fixes the issue with plot_prediction_actual_by_variable where the input np.ndarray was being multiplied to torch.Tensor in TorchNormalizer __call__

Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@cc6a3d7). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pytorch_forecasting/data/encoders.py 75.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1903   +/-   ##
=======================================
  Coverage        ?   86.28%           
=======================================
  Files           ?       96           
  Lines           ?     7775           
  Branches        ?        0           
=======================================
  Hits            ?     6709           
  Misses          ?     1066           
  Partials        ?        0           
Flag Coverage Δ
cpu 86.28% <75.00%> (?)
pytest 86.28% <75.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.

@fnhirwa fnhirwa marked this pull request as ready for review June 26, 2025 16:41
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.

we should add a test for this, if it fixes a bug

@fnhirwa fnhirwa requested a review from fkiraly July 3, 2025 12:56
@fkiraly
Copy link
Collaborator

fkiraly commented Jul 3, 2025

Can you explain why we are changing tests, and not adding one? I was expecting a new tests.

In either case, I may need an explanation on your changes to the tests, that would be appreciated.

@fkiraly fkiraly added the bug Something isn't working label Jul 3, 2025
@fnhirwa
Copy link
Member Author

fnhirwa commented Jul 3, 2025

Can you explain why we are changing tests, and not adding one? I was expecting a new tests.

In either case, I may need an explanation on your changes to the tests, that would be appreciated.

In the old test cases we were defaulting to torch.Tensor as a testing example

kwargs.setdefault("data", torch.rand(100))

With this modification we can cover both np.ndarray, pd.Series and torch.Tensor as inputs to the Normalizer.

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.

oh, you just moved it to the mark.parametrize, and added code to translate string to the object, is that correct?

Minor, non-blocking comment: my gut feeling says pytest.fixture in this case, for the str-to-object code, but it is clear enough what is happening (so, not blocking)

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] plot_prediction_actual_by_variable feeds a numpy.ndarray to TorchNormalizer.inverse_transform
2 participants