Skip to content
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

TypeError: list indices must be integers or slices, not tuple when using DummyValueImputation #3041

Closed
FMGS666 opened this issue Nov 2, 2023 · 1 comment

Comments

@FMGS666
Copy link

FMGS666 commented Nov 2, 2023

Description

There is a bug in the DummyValueImputation in the line where the NaN values are imputed. The current implementation calls np.where(np.isnan(values)) to get the indexes of the NaN values of the array.

The file is at https://github.com/awslabs/gluonts/blob/dev/src/gluonts/transform/feature.py and the line I am talking about is line 80

To Reproduce

There is no need to use gluonts to reproduce the issue, we can use numpy itself:

>>> values = [np.NaN, 0, 0]
>>> nan_indices = np.where(np.isnan(values))
>>> values[nan_indices] = 0

Error message or code output

(Paste the complete error message, including stack trace, or the undesired output that the above snippet produces.)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell 10 line 2
      [1](vscode-notebook-cell:/home/example_notebook.ipynb#X32sZmlsZQ%3D%3D?line=0) nan_indices = np.where(np.isnan(values))
----> [2](vscode-notebook-cell:/home/example_notebook.ipynb#X32sZmlsZQ%3D%3D?line=1) values[nan_indices] = 0

TypeError: list indices must be integers or slices, not tuple

Environment

  • Operating system: Kubuntu 23.04
  • Python version: 3.11
  • GluonTS version: 0.14.0

(Add as much information about your environment as possible, e.g. dependencies versions.) No need to do that as it is a numpy related buug

The issue can be fixed by simply substituting line 80 with:

>>> nan_indices = np.isnan(values)

I did a quick fix and modified the file that I have on my machine, but I'll fork the repository and create a new branch from this issue now

Tasks

No tasks being tracked yet.
@FMGS666 FMGS666 added the bug Something isn't working label Nov 2, 2023
@FMGS666
Copy link
Author

FMGS666 commented Nov 2, 2023

I realised that the problem is that the passed values were not arrays.... Im super sorry for this error, but I guess maybe it would be good to raise a TypeError when the passed argument is not an array

@lostella lostella closed this as completed Nov 2, 2023
@lostella lostella removed the bug Something isn't working label Nov 2, 2023
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

No branches or pull requests

2 participants