From 0ee8e81282da3aee3f510e15b536630ed7bfa01e Mon Sep 17 00:00:00 2001 From: Emmanuel Ferdman Date: Mon, 9 Jun 2025 03:59:59 -0700 Subject: [PATCH] Throw exception when alpha is out of bounds Signed-off-by: Emmanuel Ferdman --- lib/matplotlib/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index dd5d22130904..254e2c1a203b 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -949,7 +949,7 @@ def with_alpha(self, alpha): if not isinstance(alpha, Real): raise TypeError(f"'alpha' must be numeric or None, not {type(alpha)}") if not 0 <= alpha <= 1: - ValueError("'alpha' must be between 0 and 1, inclusive") + raise ValueError("'alpha' must be between 0 and 1, inclusive") new_cm = self.copy() if not new_cm._isinit: new_cm._init()