From 6441c2e4c50f0f1b63a83d3e5f26f94e40b96730 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Fri, 25 May 2018 19:46:07 +0200 Subject: [PATCH] flake8 compliance (except for PyQt5Gui) --- photobooth/camera/CameraDummy.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/photobooth/camera/CameraDummy.py b/photobooth/camera/CameraDummy.py index ca012e9..2e6c9ec 100644 --- a/photobooth/camera/CameraDummy.py +++ b/photobooth/camera/CameraDummy.py @@ -40,7 +40,8 @@ class X: def eval(self, x, y): - return x + return x + class Y: @@ -57,7 +58,7 @@ class SinPi: def eval(self, x, y): - return math.sin(math.pi * self.arg.eval(x,y)) + return math.sin(math.pi * self.arg.eval(x, y)) class CosPi: @@ -68,7 +69,7 @@ class CosPi: def eval(self, x, y): - return math.cos(math.pi * self.arg.eval(x,y)) + return math.cos(math.pi * self.arg.eval(x, y)) class Times: @@ -80,16 +81,18 @@ class Times: def eval(self, x, y): - return self.lhs.eval(x,y) * self.rhs.eval(x,y) + return self.lhs.eval(x, y) * self.rhs.eval(x, y) -def buildExpr(prob = 0.99): + +def buildExpr(prob=0.99): if random.random() < prob: return random.choice([SinPi, CosPi, Times])(prob) else: return random.choice([X, Y])() -def plotIntensity(exp, pixelsPerUnit = 150): + +def plotIntensity(exp, pixelsPerUnit=150): canvasWidth = 2 * pixelsPerUnit + 1 canvas = Image.new("L", (canvasWidth, canvasWidth)) @@ -97,19 +100,20 @@ def plotIntensity(exp, pixelsPerUnit = 150): for py in range(canvasWidth): for px in range(canvasWidth): # Convert pixel location to [-1,1] coordinates - x = float(px - pixelsPerUnit) / pixelsPerUnit + x = float(px - pixelsPerUnit) / pixelsPerUnit y = -float(py - pixelsPerUnit) / pixelsPerUnit - z = exp.eval(x,y) + z = exp.eval(x, y) # Scale [-1,1] result to [0,255]. intensity = int(z * 127.5 + 127.5) - canvas.putpixel((px,py), intensity) + canvas.putpixel((px, py), intensity) return canvas -def plotColor(redExp, greenExp, blueExp, pixelsPerUnit = 150): - redPlane = plotIntensity(redExp, pixelsPerUnit) +def plotColor(redExp, greenExp, blueExp, pixelsPerUnit=150): + + redPlane = plotIntensity(redExp, pixelsPerUnit) greenPlane = plotIntensity(greenExp, pixelsPerUnit) - bluePlane = plotIntensity(blueExp, pixelsPerUnit) + bluePlane = plotIntensity(blueExp, pixelsPerUnit) return Image.merge("RGB", (redPlane, greenPlane, bluePlane))