Skip to content
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

[TYP] Add possible type hint to colors argument in LinearSegmentedColormap.from_list #28068

Merged

Conversation

FelipeCybis
Copy link
Contributor

PR summary

Add possible type of colors when creating LinearSegmentedColormap.from_list(). Today only ArrayLike is used but it can also be a list or a tuple of 2-element tuples containing (value, color-like), as stated in the docs "If only colors are given, they are equidistantly mapped from the range [0, 1]; i.e. 0 maps to colors[0] and 1 maps to colors[-1]. If (value, color) pairs are given, the mapping is from value to color. This can be used to divide the range unevenly."

This can be typed as Sequence[tuple[float, ColorType]]

PR checklist

Copy link

@github-actions github-actions bot left a 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 us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@timhoffm
Copy link
Member

Do we backport to 3.9?

@ksunden ksunden added this to the v3.9.0 milestone Apr 25, 2024
@ksunden ksunden merged commit ec0653d into matplotlib:main Apr 25, 2024
42 of 43 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 25, 2024
…` argument in `LinearSegmentedColormap.from_list`
QuLogic added a commit that referenced this pull request Apr 26, 2024
…068-on-v3.9.x

Backport PR #28068 on branch v3.9.x ([TYP] Add possible type hint to `colors` argument in `LinearSegmentedColormap.from_list`)
@FelipeCybis FelipeCybis deleted the linearsegmentedcolormap-typehint branch May 24, 2024 18:18
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.

[Bug]: LinearSegmentedColormap.from_list does not have all type hints for argument colors
3 participants