From 3edbef6c57702fc77acf2d60980c74a58ab84fc5 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 9 Jul 2016 20:25:52 -0400 Subject: [PATCH 1/3] Ensure exported images use integer dimensions. It seems that the parameter tree doesn't enforce the int type very strongly. Also, use some local variables more often. --- pyqtgraph/exporters/ImageExporter.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pyqtgraph/exporters/ImageExporter.py b/pyqtgraph/exporters/ImageExporter.py index 69c02508..e600afc9 100644 --- a/pyqtgraph/exporters/ImageExporter.py +++ b/pyqtgraph/exporters/ImageExporter.py @@ -58,17 +58,17 @@ class ImageExporter(Exporter): filter.insert(0, p) self.fileSaveDialog(filter=filter) return - - targetRect = QtCore.QRect(0, 0, self.params['width'], self.params['height']) - sourceRect = self.getSourceRect() - - - #self.png = QtGui.QImage(targetRect.size(), QtGui.QImage.Format_ARGB32) - #self.png.fill(pyqtgraph.mkColor(self.params['background'])) - w, h = self.params['width'], self.params['height'] + + w = int(self.params['width']) + h = int(self.params['height']) if w == 0 or h == 0: - raise Exception("Cannot export image with size=0 (requested export size is %dx%d)" % (w,h)) - bg = np.empty((self.params['height'], self.params['width'], 4), dtype=np.ubyte) + raise Exception("Cannot export image with size=0 (requested " + "export size is %dx%d)" % (w, h)) + + targetRect = QtCore.QRect(0, 0, w, h) + sourceRect = self.getSourceRect() + + bg = np.empty((h, w, 4), dtype=np.ubyte) color = self.params['background'] bg[:,:,0] = color.blue() bg[:,:,1] = color.green() From d726a9693ec73c863b761fa9cadaac6ba32de971 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 9 Sep 2019 00:27:29 -0400 Subject: [PATCH 2/3] Fix UnboundLocalError in VideoSpeedTest. --- examples/VideoSpeedTest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/VideoSpeedTest.py b/examples/VideoSpeedTest.py index f123ccc3..7131f9d1 100644 --- a/examples/VideoSpeedTest.py +++ b/examples/VideoSpeedTest.py @@ -103,6 +103,7 @@ def mkData(): dt = np.float loc = 1.0 scale = 0.1 + mx = 1.0 if ui.rgbCheck.isChecked(): data = np.random.normal(size=(frames,width,height,3), loc=loc, scale=scale) From 2e900898904ba1ec903d83c4d24114f4dc3b34e4 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 9 Sep 2019 00:28:19 -0400 Subject: [PATCH 3/3] Fix undefined reduce call. --- pyqtgraph/opengl/items/GLBarGraphItem.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/opengl/items/GLBarGraphItem.py b/pyqtgraph/opengl/items/GLBarGraphItem.py index b3060dc9..42d05fb7 100644 --- a/pyqtgraph/opengl/items/GLBarGraphItem.py +++ b/pyqtgraph/opengl/items/GLBarGraphItem.py @@ -8,7 +8,7 @@ class GLBarGraphItem(GLMeshItem): pos is (...,3) array of the bar positions (the corner of each bar) size is (...,3) array of the sizes of each bar """ - nCubes = reduce(lambda a,b: a*b, pos.shape[:-1]) + nCubes = np.prod(pos.shape[:-1]) cubeVerts = np.mgrid[0:2,0:2,0:2].reshape(3,8).transpose().reshape(1,8,3) cubeFaces = np.array([ [0,1,2], [3,2,1], @@ -22,8 +22,5 @@ class GLBarGraphItem(GLMeshItem): verts = cubeVerts * size + pos faces = cubeFaces + (np.arange(nCubes) * 8).reshape(nCubes,1,1) md = MeshData(verts.reshape(nCubes*8,3), faces.reshape(nCubes*12,3)) - - GLMeshItem.__init__(self, meshdata=md, shader='shaded', smooth=False) - - \ No newline at end of file + GLMeshItem.__init__(self, meshdata=md, shader='shaded', smooth=False)