Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
FIX: Checks for (value, color) tuples in LinearSegmentedColormap.from_list#29052
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join uson gitter for real-time discussion.
For details on testing, writing docs, and our review process, please seethe developer guide
We strive to be a welcoming and open project. Please follow ourCode of Conduct.
I must say, the code got a whole lot more complicated. If you think it became too unreadable, I'd be happy to discuss how we can improve it. But I felt like these checks were important to catch user errors and give meaningful feedback. The problem is that the inputs are ambiguous, and it is not possible to tell what the userintends to do. For now this is solved by just looking at the first entry. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Concerning the pull request: Do you prefer if all commits are squashed into one, or will you take care of this when merging? |
Not sure how the failed checks are related to my changes. Are those just flaky checks? |
Uh oh!
There was an error while loading.Please reload this page.
Sorry for the late reply.
You are welcome to squash. If not, we'll do it on merge.
The CI runs have been deleted meanwhile. I assume the failures were unrelated. We had a couple of failing tests recently. Please try to rebase, that should likely fix it. |
15a693c
to0fae9bd
CompareThanks for your feedback! I added your remarks, squashed the commits and rebased on |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Thanks! Had to use |
Assume that the 'colors' argument is always a list of colors.If 'to_rgba_array' fails, attempt to unpack the values as a list of'(color, value)' tuples.Fixesmatplotlib#29042. Passing '(color, alpha)' tuples are nor correctly parsedas a list of colors.Check for range and monotony of values when unpacking (value, color)pairs.Implemented tests for different combinations of inputs.
The last commit had some old unused parameter in one test case, causing pytest to complain about a missing fixture. Sorry for the confusion. I amended that commit already but forgot to push 😅 |
"power cycled" to get CI to re-run against current main (which should fix the mypy failures). |
46ea8f0
intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@3j14 and congratulations on your first contribution to Matplotlib! 🎉 |
Uh oh!
There was an error while loading.Please reload this page.
PR summary
Fixes#29042.
By default, a list of colors is assumed. Only if the conversion to rgba values fails, check for (value, color) pairs.
The check of the first entry in colors in preserved to raise more meaningful error messages.
For the first item to be interpreted as a valid (value, color) tuple, it has to be
Sized
(implements__len__
),str
,matplotlib.colors.is_color_like
testEither way, errors are returned if not all entries are (value, color) pairs or if any invalid colors are encountered.
Implemented tests for different combinations of inputs.