Skip to content

Commit 1639a25

Browse files
timhoffmQuLogic
andauthored
Apply suggestions from code review
Co-authored-by: Elliott Sales de Andrade <[email protected]>
1 parent 226b2f2 commit 1639a25

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/matplotlib/colors.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,7 @@ def with_alpha(self, alpha):
953953
The alpha blending value, between 0 (transparent) and 1 (opaque).
954954
"""
955955
if not isinstance(alpha, Real):
956-
raise TypeError(
957-
f"'alpha' must be numeric or None, not {type(alpha)}")
956+
raise TypeError(f"'alpha' must be numeric or None, not {type(alpha)}")
958957
if not 0 <= alpha <= 1:
959958
ValueError("'alpha' must be between 0 and 1, inclusive")
960959
new_cm = self.copy()

lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def test_colormap_with_alpha():
253253
cmap2 = cmap.with_alpha(0.5)
254254
# color is the same:
255255
vals = [0, 0.5, 1] # numeric positions that map to the listed colors
256-
assert_array_equal(cmap(vals)[:, :2], cmap2(vals)[:, :2])
256+
assert_array_equal(cmap(vals)[:, :3], cmap2(vals)[:, :3])
257257
# alpha of cmap2 is changed:
258258
assert_array_equal(cmap(vals)[:, 3], [1, 1, 0.8])
259259
assert_array_equal(cmap2(vals)[:, 3], [0.5, 0.5, 0.5])

0 commit comments

Comments
 (0)