8000 Formatting · matplotlib/matplotlib@14b089f · GitHub
[go: up one dir, main page]

Skip to content

Commit 14b089f

Browse files
committed
Formatting
1 parent a8178eb commit 14b089f

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,13 @@ def alphaState(self, alpha):
12221222
return name
12231223

12241224
def _soft_mask_state(self, smask):
1225-
"""Return the name of an ExtGState that sets the soft mask to the given shading.
1225+
"""Return an ExtGState that sets the soft mask to the given shading.
12261226
12271227
Parameters
12281228
----------
12291229
smask : Reference
1230-
reference to a shading in DeviceGray color space, whose luminosity is
1231-
to be used as the alpha channel
1230+
Reference to a shading in DeviceGray color space, whose luminosity
1231+
is to be used as the alpha channel.
12321232
12331233
Returns
12341234
-------
@@ -1286,7 +1286,7 @@ def _write_soft_mask_groups(self):
12861286
self.beginStream(ob.id, None, attributes)
12871287
self.output(*content)
12881288
self.endStream()
1289-
1289+
12901290
def hatchPattern(self, hatch_style):
12911291
# The colors may come in as numpy arrays, which aren't hashable
12921292
if hatch_style is not None:
@@ -1348,13 +1348,13 @@ def addGouraudTriangles(self, points, colors):
13481348
13491349
Parameters
13501350
----------
1351-
13521351
points : np.ndarray
1353-
triangle vertices, shape (n, 3, 2)
1354-
where n = number of triangles, 3 = vertices, 2 = x, y
1352+
Triangle vertices, shape (n, 3, 2)
1353+
where n = number of triangles, 3 = vertices, 2 = x, y.
13551354
colors : np.ndarray
1356-
vertex colors, shape (n, 3, 1) or (n, 3, 4)
1357-
as with points, but last dimension is either (gray,) or (r, g, b, alpha)
1355+
Vertex colors, shape (n, 3, 1) or (n, 3, 4)
1356+
as with points, but last dimension is either (gray,)
1357+
or (r, g, b, alpha).
13581358
13591359
Returns
13601360
-------
@@ -1387,9 +1387,12 @@ def writeGouraudTriangles(self):
13871387
'BitsPerCoordinate': 32,
13881388
'BitsPerComponent': 8,
13891389
'BitsPerFlag': 8,
1390-
'ColorSpace': Name('DeviceRGB' if colordim == 3 else 'DeviceGray'),
1390+
'ColorSpace': Name(
1391+
'DeviceRGB' if colordim == 3 else 'DeviceGray'
1392+
),
13911393
'AntiAlias': False,
1392-
'Decode': ([points_min[0], points_max[0], points_min[1], points_max[1]]
1394+
'Decode': ([points_min[0], points_max[0],
1395+
points_min[1], points_max[1]]
13931396
+ [0, 1] * colordim),
13941397
})
13951398

@@ -1904,21 +1907,21 @@ def draw_gouraud_triangles(self, gc, points, colors, trans):
19041907
assert colors.ndim == 3
19051908
assert colors.shape[1] == 3
19061909
assert colors.shape[2] in (1, 4)
1907-
1910+
19081911
shape = points.shape
19091912
points = points.reshape((shape[0] * shape[1], 2))
19101913
tpoints = trans.transform(points)
19111914
tpoints = tpoints.reshape(shape)
19121915
name, _ = self.file.addGouraudTriangles(tpoints, colors)
19131916
output = self.file.output
1914-
1917+
19151918
if colors.shape[2] == 1:
19161919
# grayscale
19171920
gc.set_alpha(1.0)
19181921
self.check_gc(gc)
19191922
output(name, Op.shading)
19201923
return
1921-
1924+
19221925
alpha = colors[0, 0, 3]
19231926
if np.allclose(alpha, colors[:, :, 3]):
19241927
# single alpha value

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,8 @@ def test_pcolormesh():
11121112
ax3.pcolormesh(Qx, Qz, Z, shading="gouraud")
11131113

11141114

1115-
@image_comparison(['pcolormesh_alpha'], extensions=["png", "pdf"], remove_text=True)
1115+
@image_comparison(['pcolormesh_alpha'], extensions=["png", "pdf"],
1116+
remove_text=True)
11161117
def test_pcolormesh_alpha():
11171118
n = 12
11181119
X, Y = np.meshgrid(
@@ -1132,7 +1133,7 @@ def test_pcolormesh_alpha():
11321133
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
11331134
for ax in ax1, ax2, ax3, ax4:
11341135
ax.add_patch(mpatches.Rectangle(
1135-
(0,-1.5), 1.5, 3, facecolor=[.7, .1, .1, .5], zorder=0
1136+
(0, -1.5), 1.5, 3, facecolor=[.7, .1, .1, .5], zorder=0
11361137
))
11371138
# ax1, ax2: constant alpha
11381139
ax1.pcolormesh(Qx, Qy, Z, cmap=vir, alpha=0.4, shading='flat', zorder=1)
< 316C /div>

0 commit comments

Comments
 (0)
0