Skip to content

Commit ea6894f

Browse files
committed
Removed try-except that are not needed
1 parent 699cc95 commit ea6894f

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

lib/matplotlib/cm.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,11 @@ def to_rgba(self, x, alpha=None, bytes=False, norm=True):
276276
if norm:
277277
x = self.norm(x)
278278

279-
try:
280-
np_alpha = ma.asarray(alpha)
281-
if np_alpha.ndim == 1 and np_alpha.shape == x.shape:
282-
rgba = self.cmap(x, bytes=bytes)
283-
rgba[0:, 3] = np_alpha
284-
return rgba
285-
except AttributeError:
286-
# e.g., alpha is not an array;
287-
pass
279+
np_alpha = ma.asarray(alpha)
280+
if np_alpha.ndim == 1 and np_alpha.shape == x.shape:
281+
rgba = self.cmap(x, bytes=bytes)
282+
rgba[0:, 3] = np_alpha
283+
return rgba
288284

289285
rgba = self.cmap(x, alpha=alpha, bytes=bytes)
290286
return rgba

lib/matplotlib/collections.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -678,14 +678,11 @@ def set_alpha(self, alpha):
678678
ACCEPTS: float or None
679679
"""
680680
if alpha is not None:
681-
try:
682-
# Check if alpha is an array of matching size
683-
np_alpha = ma.asarray(alpha)
684-
if np_alpha.ndim == 1:
685-
artist.Artist.set_alpha(self, np_alpha)
686-
return
687-
except AttributeError:
688-
pass
681+
# Check if alpha is an array of matching size
682+
np_alpha = ma.asarray(alpha)
683+
if np_alpha.ndim == 1:
684+
artist.Artist.set_alpha(self, np_alpha)
685+
return
689686
try:
690687
float(alpha)
691688
except TypeError:

0 commit comments

Comments
 (0)