Skip to content

Commit 279c634

Browse files
committed
Fix to_rgba to recognise an empty string
1 parent f79e89a commit 279c634

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mizani/_colors/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def to_rgba(
103103
RGBA color(s)
104104
"""
105105
if isinstance(colors, str):
106-
if colors == "none" or colors == "None":
106+
if colors in ("none", "None", ""):
107107
return "none"
108108

109109
if isinstance(alpha, (float, int, np.floating, np.integer)):

tests/colors/test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def test_to_rgba():
3131
assert to_rgba("red", np.int64(1)) == "#FF0000FF" # pyright: ignore[reportCallIssue,reportArgumentType]
3232

3333
assert to_rgba(None, 1) == "none"
34+
assert to_rgba("", 1) == "none"
35+
assert to_rgba("none", 0.2) == "none"
3436
assert to_rgba([None, None], 1) == ["none", "none"] # pyright: ignore[reportCallIssue,reportArgumentType]
3537

3638
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)