Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Jun 5, 2024
1 parent 3afa5d9 commit bd226cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions pycolorbar/settings/colorbar_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def validate_colors(cls, v):
isinstance(color_component, (int, float)) and 0 <= color_component <= 1 for color_component in v
):
raise ValueError("Invalid RGB/RGBA format. Expected tuple with values between 0 and 1.")
v = tuple(v)
else:
raise ValueError("Invalid color format. Expected a named color, hex string, or RGB/RGBA tuple.")
return v
Expand Down
6 changes: 3 additions & 3 deletions pycolorbar/tests/test_colorbar_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_invalid_n(self, n):
[
"#ff0000", # valid hex
(1, 0, 0), # valid RGB tuple
[1, 0, 0], # valid RGB tuple
[1, 0, 0], # valid RGB list
(1, 0, 0, 1), # valid RGBA tuple (if bad/over/under alpha provided ... RGB alpha will be overwritten !)
"red", # valid named color
"none",
Expand All @@ -187,8 +187,8 @@ def test_valid_colors(self, color):
"""Test valid colors for 'bad_color', 'over_color', 'under_color'."""
cmap_settings = {"name": "viridis", "bad_color": color, "over_color": color, "under_color": color}
validated = ColormapSettings(**cmap_settings)
if isinstance(color, tuple):
color = list(color)
if isinstance(color, list):
color = tuple(color)
assert validated.bad_color == color
assert validated.over_color == color
assert validated.under_color == color
Expand Down

0 comments on commit bd226cb

Please sign in to comment.