taurus-org / taurus_pyqtgraph

Moved to https://gitlab.com/taurus-org/taurus_pyqtgraph
3 stars 14 forks source link

Trend: Select average gives error #73

Closed tiagocoutinho closed 4 years ago

tiagocoutinho commented 4 years ago

tested with:

On a trend, I right click Plot options > Average > Average checkbox I get on the console:

  File "/homelocal/opbl04/miniconda/envs/mspd/lib/python3.7/site-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 421, in avgToggled
    self.recomputeAverages()
  File "/homelocal/opbl04/miniconda/envs/mspd/lib/python3.7/site-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 437, in recomputeAverages
    self.addAvgCurve(c)
  File "/homelocal/opbl04/miniconda/envs/mspd/lib/python3.7/site-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 487, in addAvgCurve
    if plot.yData is not None and y.shape == plot.yData.shape:
AttributeError: 'NoneType' object has no attribute 'shape'
cpascual commented 4 years ago

Confirmed. Needs investigation

tiagocoutinho commented 4 years ago

Thanks for the quick reply @cpascual. Forgot to mention this is just something I noticed when "playing around" with the new gui I am writing.

The feature itself is not being used by my beamline. So for me you can mark it as low priority

cpascual commented 4 years ago

Snippet to reproduce and debug

from taurus.qt.qtgui.application import TaurusApplication
from taurus_pyqtgraph import TaurusTrend

import sys
app = TaurusApplication(cmd_line_parser=None)
w = TaurusTrend()
w.setModel(["eval:2", "eval:3", "eval:[4,11]"])
w.getPlotItem().ctrl.averageGroup.setChecked(True)
w.show()
sys.exit(app.exec_())
cpascual commented 4 years ago

And this one with pure pyqtgraph to better understand how the average works with params:

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
import numpy as np

app = QtGui.QApplication([])
p = pg.PlotWidget()
p.addLegend()

p.plot(y=1*np.ones(9), params={"a":"A"})
p.plot(y=2*np.ones(9), params={"b":"B"})
p.plot(y=6*np.ones(9), params={"c":"C"})
p.show()
p.getPlotItem().ctrl.averageGroup.setChecked(True)
app.exec_()