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

FIX: let pandas IndexInt64 work for boxplot by jklymak · Pull Request #13398 · matplotlib/matplotlib · GitHub

Repository navigation

FIX: let pandas IndexInt64 work for boxplot - #13398

Merged
NelleV merged 3 commits into
matplotlib:masterfrom
jklymak:fix-boxplot-pandas
Feb 19, 2019
Merged

NelleV merged 3 commits into
matplotlib:masterfrom
jklymak:fix-boxplot-pandas

Conversation

jklymak commented Feb 10, 2019

Copy link
Copy Markdown
Member

PR Summary

Closes #10022 by casting the list of positions to an array as suggested by @tacaswell

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

jklymak commented Feb 10, 2019

Copy link
Copy Markdown
Member Author

I think this fix is "OK" as a stopgap, but I think what really should happen is position be put through unit conversion (which I don't think it is). But I'll leave that for someone who actually uses boxplot to make sure it is done properly... Still think this should go in to make array-like things w/o units work OK. Happy to be told that someone's favourite units used to work, but break w/ this change.

positions = list(range(1, N + 1))
elif len(positions) != N:
raise ValueError(datashape_message.format("positions"))
positions = np.array(positions)

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

This is a good fix for the case described in the ticket, but I think the code will continue raising obscure error when positions are not numbers. Can you add a check after this line about the dtype of the array being a number? Maybe something like:

if not isinstance(positions.dtype, numbers.Number):
     raise TypeError("positions should be a iterable of dtype number, but found dtype %s" % blah blah blah.)

When we end up supporting something else than numbers, this can be updated.

Copy link
Copy Markdown
Member Author

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 couldn't quite get that check to work; I had to check the first element. But if there is a better way, let me know.

NelleV merged commit 2884058 into matplotlib:master Feb 19, 2019

NelleV commented Feb 19, 2019

Copy link
Copy Markdown
Member

Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

boxplot: positions used to take Int64Index

4 participants


Back | FazBrowse Home | New Git URL