From 20bcc39eb1039987fa411821a440ee1323dd3a63 Mon Sep 17 00:00:00 2001 From: "Ilya A. Kriveshko" Date: Fri, 30 Mar 2018 14:48:05 -0400 Subject: [PATCH] examples: use integer division in indexing In python3 / operator produces a float, which is not a valid index. Replace with // integer division. --- examples/GLImageItem.py | 6 +++--- examples/isocurve.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/GLImageItem.py b/examples/GLImageItem.py index 581474fd..70bf5306 100644 --- a/examples/GLImageItem.py +++ b/examples/GLImageItem.py @@ -26,9 +26,9 @@ data += pg.gaussianFilter(np.random.normal(size=shape), (15,15,15))*15 ## slice out three planes, convert to RGBA for OpenGL texture levels = (-0.08, 0.08) -tex1 = pg.makeRGBA(data[shape[0]/2], levels=levels)[0] # yz plane -tex2 = pg.makeRGBA(data[:,shape[1]/2], levels=levels)[0] # xz plane -tex3 = pg.makeRGBA(data[:,:,shape[2]/2], levels=levels)[0] # xy plane +tex1 = pg.makeRGBA(data[shape[0]//2], levels=levels)[0] # yz plane +tex2 = pg.makeRGBA(data[:,shape[1]//2], levels=levels)[0] # xz plane +tex3 = pg.makeRGBA(data[:,:,shape[2]//2], levels=levels)[0] # xy plane #tex1[:,:,3] = 128 #tex2[:,:,3] = 128 #tex3[:,:,3] = 128 diff --git a/examples/isocurve.py b/examples/isocurve.py index 6d89bbec..63b1699e 100644 --- a/examples/isocurve.py +++ b/examples/isocurve.py @@ -17,7 +17,7 @@ app = QtGui.QApplication([]) frames = 200 data = np.random.normal(size=(frames,30,30), loc=0, scale=100) data = np.concatenate([data, data], axis=0) -data = pg.gaussianFilter(data, (10, 10, 10))[frames/2:frames + frames/2] +data = pg.gaussianFilter(data, (10, 10, 10))[frames//2:frames + frames//2] data[:, 15:16, 15:17] += 1 win = pg.GraphicsLayoutWidget(show=True)