Non-integer indices in Python 2.7 numpy broken. Fx., broken "Image Export".

13 views
Skip to first unread message

Josh Kaggie

unread,
Mar 28, 2018, 8:37:27 AM3/28/18
to pyqtgraph
Recent versions of Numpy have broken a number of features in several packages by requiring integer indices for indexing or slicing arrays (non-float types!).  Unfortunately there is plenty of software that used this now-deprecated feature, including pyqtgraph.

Is there any plan to update this so that some of these features will work again in Python 2.7? 

For example, when you right click on an image and try to export it, it results in the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/exporters/Exporter.py", line 77, in fileSaveFinished
    self.export(fileName=fileName, **self.fileDialog.opts)
  File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/exporters/ImageExporter.py", line 70, in export
    bg = np.empty((self.params['width'], self.params['height'], 4), dtype=np.ubyte)


I think the fix is straight-forward enough, although tedious to find other areas it applies.  It is probably something like this:

    bg = np.empty((self.params['width'].astype(np.int), self.params['height'].astype(np.int), 4), dtype=np.ubyte)

or

    bg = np.empty((int(self.params['width']), int(self.params['height']), 4), dtype=np.ubyte)


Reply all
Reply to author
Forward
0 new messages