flake8 compliance (except for PyQt5Gui)
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user