Skip to content

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

Merged
ksunden merged 1 commit into
matplotlib:mainfrom
FelipeCybis:linearsegmentedcolormap-typehint
Apr 25, 2024
Merged

ksunden merged 1 commit into
matplotlib:mainfrom
FelipeCybis:linearsegmentedcolormap-typehint

Conversation

@FelipeCybis

Copy link
Copy Markdown
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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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
Copy Markdown
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
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