Skip to content

Improve error handling in _parse_scatter_color_args #17245

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

Merged
merged 1 commit into from
Apr 29, 2020

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Apr 25, 2020

PR Summary

Fixes #17243

The problem was that mcolors.to_rgba_array(c) can raise two categories of ValueErrors. One are generic array conversion-related errors, the other is our own ValueError('RGBA values should be within 0-1 range'). Only the former should be catched and rewritten. Our own ValueError should directly surface.

I chose the simple approach of just checking the error message. One could alternatively introduce an own Exception subtype. But we're not really doing that in other places and ValueError seems exactly right for out-of-bounds numbers.

@timhoffm timhoffm force-pushed the scatter-color-error-message branch from 33ee858 to a397322 Compare April 26, 2020 09:25
@timhoffm timhoffm force-pushed the scatter-color-error-message branch from a397322 to 0c44be6 Compare April 26, 2020 22:52
@QuLogic
Copy link
Member

QuLogic commented Apr 28, 2020

Is that the right issue number?

@timhoffm
Copy link
Member Author

Ups, fixed the number.

@jklymak jklymak merged commit be3e477 into matplotlib:master Apr 29, 2020
@timhoffm timhoffm deleted the scatter-color-error-message branch April 29, 2020 17:56
@QuLogic QuLogic mentioned this pull request May 15, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading error message in _parse_scatter_color_args
3 participants