Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make code match comment in sankey. #11974

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
Nov 1, 2018
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 29, 2018

This makes Sankey.add no longer reject a labels that's a single
string, consistently with what the docstring states and what the comment
just after implies.

Previously, it would only accept a single string if its length is equal
to the number of flows, in which case it would use one character
of the string for each flow.

Alternatively, we could also change the docstring and delete the comment,
but I think this behavior is more intuitive? (Not that I ever use
Sankey, though it looks neat...)

Noted in #11959, dates all the way back since this class was added.

PR Summary

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

This makes Sankey.add no longer reject a labels that's a *single*
string, consistently with what the docstring states and what the comment
just after implies.

Previously, it would only accept a single string if its length is equal
to the number of flows, in which case it would use one character
of the string for each flow.

Alternatively, we could also change the docstring and delete the comment,
but I think this behavior is more intuitive?  (Not that I ever use
Sankey, though it looks neat...)
@tacaswell tacaswell added this to the v3.1 milestone Aug 29, 2018
@dstansby
Copy link
Member

👍 but could do with a test?

@anntzer
Copy link
Contributor Author

anntzer commented Sep 14, 2018

Well, sankey tests are... sparse (https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/tests/test_sankey.py) and I'm not volunteering to fix that :)

@dstansby dstansby merged commit ec6a45a into matplotlib:master Nov 1, 2018
@anntzer anntzer deleted the sankey branch November 1, 2018 09:47
@QuLogic
Copy link
Member

QuLogic commented Jan 18, 2019

This has broken the first two plots in the Sankey class example and the Rankine power cycle example.

I think you've misdiagnosed the problem here. It appears that it's a Python 2 vs. 3 bug. Python 2 str didn't have __iter__, so that was a reasonable way to check for a list or tuple. Python 3 str does have __iter__, so the condition is wrong now.

What it was originally supposed to check is that if you passed a list (or tuple), that it was the right length. Passing a single string was to be repeated for all entries.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 18, 2019

Yes, I just realized this while testing the other sankey PRs... working on it.
Wouldn't have guess it's a Py2-Py3 issue, my Py2-fu is very weak :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants