-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
_check_color_like function for list inputs #25025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+30
−0
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f490d5e
Update colors.py
i-deal 18972c1
Update colors.py
i-deal 5950e50
Update colors.py
i-deal 9badee8
Update lib/matplotlib/colors.py
i-deal 477da9f
fixes syntax
i-deal 456798a
Update test_colors.py
i-deal 263d51d
Update test_colors.py
i-deal 5da70b8
Merge branch 'main' of https://github.com/i-deal/matplotlib
i-deal 60c0ffa
Update test_colors.py
i-deal 5ee5b26
Update test_colors.py
i-deal 49d86c6
Update test_colors.py
i-deal b986c7c
Update test_colors.py
i-deal 7f38555
Update test_colors.py
i-deal 3b49746
Update test_colors.py
i-deal 6abb7a0
Update test_colors.py
i-deal 3176b64
Update colors.py
i-deal b79f09f
Update test_colors.py
i-deal 7beccba
Update colors.py
i-deal 42e13ba
Update test_colors.py
i-deal 114a2fd
:(
i-deal 5c68d13
Update lib/matplotlib/colors.py
i-deal 14e7ea9
Update test_colors.py
i-deal 04cb731
update syntax
i-deal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import copy | ||
import itertools | ||
import unittest.mock | ||
from re import escape | ||
|
||
from io import BytesIO | ||
import numpy as np | ||
|
@@ -1592,3 +1593,20 @@ def test_cm_set_cmap_error(): | |
bad_cmap = 'AardvarksAreAwkward' | ||
with pytest.raises(ValueError, match=bad_cmap): | ||
sm.set_cmap(bad_cmap) | ||
|
||
|
||
def test_check_color_like(): | ||
err_msg = "['abcd'] is not a valid value for c" | ||
assert mcolors._check_color_like(colors1='yellow', colors2='red') is None | ||
with pytest.raises(ValueError, match=err_msg): | ||
mcolors._check_color_like(c='abcd') | ||
|
||
|
||
def test_check_color_like_list(): | ||
err_msg = escape("['abcd'] are not valid values for c") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to use r" instead of escape but if using escape then please write re.escape and import re rather than from re import escape |
||
assert mcolors._check_color_like_list(colors=['yellow', 'orange']) is None | ||
assert mcolors._check_color_like_list(c1=['red'], c2=['blue']) is None | ||
with pytest.raises(ValueError, match=err_msg): | ||
mcolors._check_color_like_list(c=['abcd', 'red']) | ||
with pytest.raises(ValueError, match=err_msg): | ||
mcolors._check_color_like_list(c1=['red', 'blue'], c=['abcd']) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this error message isn't a list because the input to this function isn't a list