FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix passing singleton sequence-type styles to hist by rcomer · Pull Request #29719 · matplotlib/matplotlib · GitHub

Fix passing singleton sequence-type styles to hist - #29719

Merged
story645 merged 1 commit into
matplotlib:mainfrom
rcomer:hist-styles
Mar 12, 2025
Merged

Fix passing singleton sequence-type styles to hist#29719
story645 merged 1 commit into
matplotlib:mainfrom
rcomer:hist-styles

Conversation

rcomer commented Mar 8, 2025
edited
Loading

Copy link
Copy Markdown
Member

PR summary

Fixes #29717. Use of np.atleast_1d here is not appropriate for style properties expressed as tuples or array-likes. For colours we can just use to_rgba_array. For linestyles I factored out the logic used to set one or more linestyles in Collection.

We are already using to_rgba_array if colors is passed:

else:
colors = mcolors.to_rgba_array(color)

PR checklist

rcomer added the PR: bugfix Pull requests that fix identified bugs label Mar 8, 2025

rcomer commented Mar 8, 2025

Copy link
Copy Markdown
Member Author

OK so we can't just use to_rgba_array if the colour is "none", which doesn't happen in the tests but does in the docs...

rcomer closed this Mar 8, 2025
rcomer deleted the hist-styles branch March 8, 2025 18:45
rcomer restored the hist-styles branch March 8, 2025 18:46
rcomer reopened this Mar 8, 2025

story645 commented Mar 9, 2025

Copy link
Copy Markdown
Member

OK so we can't just use to_rgba_array if the colour is "none",

Is this related to #28475?

rcomer commented Mar 9, 2025

Copy link
Copy Markdown
Member Author

OK so we can't just use to_rgba_array if the colour is "none",

Is this related to #28475?

Yes exactly. The array has zero size, so you get a StopIteration error when you try to call next.

timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I have been pondering for a time whether we should have an internal helper to loop over possibly list-type properties. This should take care of all the technical details like single value vs. list of values, properly handling sequence-like single values, optionally length checks (we currently don't have a clear policy whether we request the same size, or whether we are permissive and continuously cycle as long as needed, which may be handy in some cases but could hide a bug in others).

rcomer added this to the v3.10.2 milestone Mar 11, 2025
story645 merged commit 4b68626 into matplotlib:main Mar 12, 2025
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 12, 2025
story645 added a commit that referenced this pull request Mar 12, 2025
…719-on-v3.10.x

Backport PR #29719 on branch v3.10.x (Fix passing singleton sequence-type styles to hist)
rcomer deleted the hist-styles branch March 12, 2025 10:27
ksunden mentioned this pull request May 9, 2025
5 tasks
ksunden mentioned this pull request Aug 7, 2025
5 tasks
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: bugfix Pull requests that fix identified bugs topic: collections and mappables

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Using a linestyle tuple with a histogram crashes with matplotlib 3.10

3 participants


Back | FazBrowse Home | New Git URL