-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
py3k fix #2962
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
py3k fix #2962
Conversation
@@ -263,6 +263,7 @@ def _get_legend_handles(self, legend_handler_map=None): | |||
all_handles = Axes_get_legend_handles(self, legend_handler_map) | |||
|
|||
for ax in self.parasites: | |||
all_handles = list(all_handles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should go outside of the loop, you only need to convert this to a list once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell
But the issue is the .extend method (line right below, but still inside the loop) being applied to a generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right and
all_handles = list(all_handles)
runs through the generator until it is exhausted and make all_handles
a list. The loop should then work correctly.
This looks about right to me. Chasing thing down it actually isn't a py3k issue, if you look at https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_axes.py#L212 |
Could you also add a note to CHANGELOG about fixing this? |
@tacaswell |
I like the code, I do not like the text of the changelog. I do not think this is a py3k issue, rather just a bug. |
You are right! I still had my mind at py3k bug. Just changed that. |
No worries, py3k has enough issues it is tempting to blame everything on at ;) My first assumption was that this was a dictionary One last request, could you squash your commits into one? |
I'm not sure how to do that, and based on what I read I cannot do that when I already pushed to github. Is it OK if we close this and I make a new PR with one commit? |
Once you have done the squashing do a Doing it this way does little harm, keeps the discussion all in one place, and keeps from running up our issue count. |
@tacaswell |
Looks good. Typically we add tests to make sure this does not regress, however the code coverage in mpl_toolkits is very thin/non existent so we will not worry about it in this PR. Thanks for fixing this issue! Hopefully this is the first of many. |
Turn generator into list in parasite_axes
Hi,
This is probably not the right way to fix this issue, but I would like to draw attention to this bug when using parasite_axes.py on python3.3.
The legend handler was returning an
Thanks for matplotlib!
-Filipe