Skip to content

Commit ba09058

Browse files
committed
Appease the PEP8 gods. Somewhat of a sacraficial lamb if you ask me.
1 parent 2c0b413 commit ba09058

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/matplotlib/image.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,7 @@ def thumbnail(infile, thumbfile, scale=0.1, interpolation='bilinear',
15031503
fig.savefig(thumbfile, dpi=dpi)
15041504
return fig
15051505

1506+
15061507
def flatten_rgba(src, bg=None):
15071508
"""
15081509
Flatten an RGBA image *src* with a background color *bg*.
@@ -1517,7 +1518,7 @@ def flatten_rgba(src, bg=None):
15171518
15181519
bg : Tuple(int,int,int), optional
15191520
Background color to merge *src* with. If no bg color is provided
1520-
the color from the rcParam 'savefig.facecolor' will be use.
1521+
the color from the rcParam 'savefig.facecolor' will be used.
15211522
15221523
Returns
15231524
-------
@@ -1529,18 +1530,18 @@ def flatten_rgba(src, bg=None):
15291530
rcParams.get('savefig.facecolor', 'white'))
15301531
bg = tuple([int(x * 255.0) for x in bg])
15311532

1532-
# Numpy images have dtype=uint8 which will overflow
1533+
# Numpy images have dtype=uint8 which will overflow for these calculations
15331534
src = src.astype(np.uint16)
15341535

1535-
alpha = src[:,:,3]
1536-
src_rgb = src[:,:,:3]
1536+
alpha = src[:, :, 3]
1537+
src_rgb = src[:, :, :3]
15371538
w, h, _ = src.shape
15381539

15391540
dest = np.empty((w, h, 4))
1540-
dest[:,:,0] = (255 - alpha)*bg[0] + alpha*src_rgb[:,:,0]
1541-
dest[:,:,1] = (255 - alpha)*bg[1] + alpha*src_rgb[:,:,1]
1542-
dest[:,:,2] = (255 - alpha)*bg[2] + alpha*src_rgb[:,:,2]
1541+
dest[:, :, 0] = (255 - alpha)*bg[0] + alpha*src_rgb[:, :, 0]
1542+
dest[:, :, 1] = (255 - alpha)*bg[1] + alpha*src_rgb[:, :, 1]
1543+
dest[:, :, 2] = (255 - alpha)*bg[2] + alpha*src_rgb[:, :, 2]
15431544
dest = (dest/255).astype(np.uint8)
1544-
dest[:,:,3] = 255
1545+
dest[:, :, 3] = 255
15451546

15461547
return dest

0 commit comments

Comments
 (0)