flake8 compliance (except for PyQt5Gui)
This commit is contained in:
@@ -40,7 +40,8 @@ class X:
|
|||||||
|
|
||||||
def eval(self, x, y):
|
def eval(self, x, y):
|
||||||
|
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
class Y:
|
class Y:
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ class SinPi:
|
|||||||
|
|
||||||
def eval(self, x, y):
|
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:
|
class CosPi:
|
||||||
@@ -68,7 +69,7 @@ class CosPi:
|
|||||||
|
|
||||||
def eval(self, x, y):
|
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:
|
class Times:
|
||||||
@@ -80,16 +81,18 @@ class Times:
|
|||||||
|
|
||||||
def eval(self, x, y):
|
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:
|
if random.random() < prob:
|
||||||
return random.choice([SinPi, CosPi, Times])(prob)
|
return random.choice([SinPi, CosPi, Times])(prob)
|
||||||
else:
|
else:
|
||||||
return random.choice([X, Y])()
|
return random.choice([X, Y])()
|
||||||
|
|
||||||
def plotIntensity(exp, pixelsPerUnit = 150):
|
|
||||||
|
def plotIntensity(exp, pixelsPerUnit=150):
|
||||||
|
|
||||||
canvasWidth = 2 * pixelsPerUnit + 1
|
canvasWidth = 2 * pixelsPerUnit + 1
|
||||||
canvas = Image.new("L", (canvasWidth, canvasWidth))
|
canvas = Image.new("L", (canvasWidth, canvasWidth))
|
||||||
@@ -99,17 +102,18 @@ def plotIntensity(exp, pixelsPerUnit = 150):
|
|||||||
# Convert pixel location to [-1,1] coordinates
|
# Convert pixel location to [-1,1] coordinates
|
||||||
x = float(px - pixelsPerUnit) / pixelsPerUnit
|
x = float(px - pixelsPerUnit) / pixelsPerUnit
|
||||||
y = -float(py - pixelsPerUnit) / pixelsPerUnit
|
y = -float(py - pixelsPerUnit) / pixelsPerUnit
|
||||||
z = exp.eval(x,y)
|
z = exp.eval(x, y)
|
||||||
|
|
||||||
# Scale [-1,1] result to [0,255].
|
# Scale [-1,1] result to [0,255].
|
||||||
intensity = int(z * 127.5 + 127.5)
|
intensity = int(z * 127.5 + 127.5)
|
||||||
canvas.putpixel((px,py), intensity)
|
canvas.putpixel((px, py), intensity)
|
||||||
|
|
||||||
return canvas
|
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)
|
greenPlane = plotIntensity(greenExp, pixelsPerUnit)
|
||||||
bluePlane = plotIntensity(blueExp, pixelsPerUnit)
|
bluePlane = plotIntensity(blueExp, pixelsPerUnit)
|
||||||
return Image.merge("RGB", (redPlane, greenPlane, bluePlane))
|
return Image.merge("RGB", (redPlane, greenPlane, bluePlane))
|
||||||
|
|||||||
Reference in New Issue
Block a user