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

pyqtgraph related exceptions - traceback not helping #28

Open
fredericpoitevin opened this issue Jan 15, 2021 · 8 comments
Open

pyqtgraph related exceptions - traceback not helping #28

fredericpoitevin opened this issue Jan 15, 2021 · 8 comments

Comments

@fredericpoitevin
Copy link
Contributor

fredericpoitevin commented Jan 15, 2021

On 1/4/21, we started noticing that psocake on ana-4.0.5 was throwing multiple exceptions; they are ignored and do not prevent some of the usage of psocake. They however mess with the display of histograms and small data.

Two TypeErrors messages appear repeatedly in the Traceback:

  • Error 1:
File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.5/lib/python2.7/site-packages/pyqtgraph/functions.py", line 1504, in arrayToQPath
isfinite = np.isfinite(x) & np.isfinite(y)
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
  • Error 2:
File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.5/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
 w *= px
TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

In addition, when psocake is run in verbose mode (-v 1), an additional error shows up:

  • Error 3:
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast

It seems that all errors are somewhat related to pyqtgraph, yet the traceback does not really tell us which call triggered what error, which would help hone in on a particular function to debug.

To that effect, we tried the idea explained in this blog post found by Chris: https://fman.io/blog/pyqt-excepthook/
The script was slightly edited to make it look like what is done in psocake:
fman.py.zip

Interestingly, running this script in ana-4.0.5 still results in Error3:

(ana-4.0.5) [fpoitevi@psanagpu108 debug]$ python fman.py
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
[… the GUI displays OK…]

Adding the idea of that script to gui.py in psocake unfortunately did not result in a more informative traceback...

@valmar
Copy link

valmar commented Jan 15, 2021

Does the version that come with the environment work? (Trying to figure out if the error originates from psocake or pyqtgraph)

@fredericpoitevin
Copy link
Contributor Author

Unfortunately it throws the same errors

@valmar
Copy link

valmar commented Jan 15, 2021

Ok, it must be the library then. That's actually good news. Someone was posting in an email a minimal snippet that could reproduce the error. Do you remember where we can find it please?

@fredericpoitevin
Copy link
Contributor Author

fredericpoitevin commented Jan 15, 2021

If you mean for Error 3, it must be this:

(ana-4.0.5) [fpoitevi@psanagpu108 psocake]$ ipython
In [1]: import pyqtgraph as pg
In [2]: pg.plot([1.,2.], [1.,2.], pen=None, symbol='o')
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
Out[2]: <pyqtgraph.graphicsWindows.PlotWindow at 0x7f053dbc6348>
In [3]: pg.plot([1.,2.], [1.,2.], pen=(1,3), symbol='o')
Out[3]: <pyqtgraph.graphicsWindows.PlotWindow at 0x7f053cea3b00>
In [4]: pg.plot([1.,2.], [1.,int(2.)], pen=(1,3), symbol='o')
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
Out[4]: <pyqtgraph.graphicsWindows.PlotWindow at 0x7ff97bb19218>
In [5]: quit()

@valmar
Copy link

valmar commented Jan 15, 2021

I think that error just means that hardware acceleration could not be enabled

@chuckie82
Copy link
Contributor

Here's the actual error (below). I've started porting psocake to python3 today, so let me see what I can do. We won't need to worry about this if I get it done.

@fredericpoitevin: if you want to get rid of libGL errors, you will need to do something like:
yum install mesa-libGLU*.i686 mesa-libGLU*.x86_64

(ana-4.0.9) [yoon82@psanagpu103 psocake]$ python
Python 2.7.15 | packaged by conda-forge | (default, Mar 5 2020, 14:56:06)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pyqtgraph as pg
pg.plot([1.,2.], [1.,2.], pen=None, symbol='o')
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
<pyqtgraph.graphicsWindows.PlotWindow object at 0x7fd76c8a79d0>
[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

@fredericpoitevin
Copy link
Contributor Author

Ah yes I tried to extract the relevant part from the whole traceback, but the actual error actually keeps throwing exceptions as we use the GUI. OK will be in standby

@detlevn
Copy link

detlevn commented Mar 7, 2022

After replacing w *= px and h *= py with w = w * px resp. h = h * py all symbol related properties of ScatterPlotItem will work

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

4 participants