Skip to content

Error when using FFT on data with one point #3018

@Python-simulation

Description

@Python-simulation

Activating the FFT transform on data with one point raises the following error:

File ~\anaconda3\lib\site-packages\pyqtgraph\graphicsItems\PlotDataItem.py:1190 in _fourierTransform
uniform = not np.any(np.abs(dx-dx[0]) > (abs(dx[0]) / 1000.))
IndexError: index 0 is out of bounds for axis 0 with size 0

This occurs because dx = np.diff(x) is empty when x is of size 1.

A possible solution is to add the following condition if len(x) == 1: return np.array([0]), abs(y) in the beginning of _fourierTransform in PlotDataItem.py.

  • PyQtGraph version: tested on 0.13.3 but will also raise same error in 0.13.7 has the relevant code has not changed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions