Skip to content

FIX: errors in get_position changes #12363

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 2 commits into from
Oct 12, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Oct 1, 2018

PR Summary

Closes #12355

This corrects a few mistakes in positioning PRs that were preventing locatable axes from working correctly. It also makes a couple of kwargs explicit rather than positional when we call them.

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

@ImportanceOfBeingErnest
Copy link
Member

Maybe this is a good place to add a test for the failing usecase?

@jklymak
Copy link
Member Author

jklymak commented Oct 2, 2018

New test fails master, passes this PR and was the root of the problem....

@jklymak jklymak added this to the v3.0.x milestone Oct 2, 2018
@jklymak jklymak force-pushed the fix-correct-get-position-errors branch from 59a994b to a5e6667 Compare October 2, 2018 15:44
@jklymak jklymak added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. status: needs review labels Oct 2, 2018
@timhoffm
Copy link
Member

timhoffm commented Oct 3, 2018

Please rebase. #12366 is in and should fix the failing CI.

@jklymak
Copy link
Member Author

jklymak commented Oct 3, 2018

...rebased

@timhoffm
Copy link
Member

timhoffm commented Oct 3, 2018

flake8 says

./lib/mpl_toolkits/tests/test_axes_grid1.py:399:57: W291 trailing whitespace

@jklymak jklymak force-pushed the fix-correct-get-position-errors branch from 0ce489c to 1da1c35 Compare October 3, 2018 17:49
@jklymak
Copy link
Member Author

jklymak commented Oct 3, 2018

Fixed flake8. I'd actually be in favour of adding an Exception for the trailing whitespace error.

Copy link
Member

@WeatherGod WeatherGod left a comment

Choose a reason for hiding this comment

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

everything else looks good, just have a comment about a code alignment.

@@ -2298,7 +2298,8 @@ def get_tightbbox(self, renderer, bbox_extra_artists=None):

for ax in self.axes:
if ax.get_visible():
bb.append(ax.get_tightbbox(renderer, bbox_extra_artists))
bb.append(ax.get_tightbbox(renderer,
bbox_extra_artists=bbox_extra_artists))
Copy link
Member

Choose a reason for hiding this comment

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

The alignment of this keyword argument makes me think it is for the append, not the get_tightbbox(), but even that looks wonky. Which PEP8 alignment rule is this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just did two-tab (8-space) indentation - I don't think it'll fit on one line, though I can check

Copy link
Member

Choose a reason for hiding this comment

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

It will not, nor will it work with aligning to the correct opening parenthesis, but you can do this:

                bb.append(                                                      
                    ax.get_tightbbox(renderer,                                  
                                     bbox_extra_artists=bbox_extra_artists))    

Copy link
Member Author

Choose a reason for hiding this comment

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

Ummm, OK, but really the 8-space indent is allowed by PEP8, and in this case I think looks best:

https://www.python.org/dev/peps/pep-0008/?#indentation

Copy link
Member

Choose a reason for hiding this comment

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

I'm meant "will not fit", not anything about whether it's in PEP8.

Copy link
Member

Choose a reason for hiding this comment

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

That PEP8 link uses 4-space indent for continuation lines; it's only if there's ambiguity that double indent is used (but keep in mind there are no nested function calls in those examples.)

Copy link
Member

Choose a reason for hiding this comment

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

I think a list comprehension would be more readable anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, list comprehension is bearable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Uh, I think (hope?) @timhoffm meant something like

        bbox.extend(
            ax.get_tightbbox(renderer, bbox_extra_artists=bbox_extra_artists)
            for ax in self.axes if ax.get_visible())

Copy link
Member Author

Choose a reason for hiding this comment

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

Fine

for ax in self.parasites]
bbs.append(super().get_tightbbox(renderer, call_axes_locator))
bbs.append(super().get_tightbbox(renderer,
call_axes_locator=call_axes_locator))
Copy link
Member

Choose a reason for hiding this comment

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

similar issue here, the alignment of the keyword argument is wonky.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@jklymak jklymak force-pushed the fix-correct-get-position-errors branch 2 times, most recently from a518ddf to d4c7069 Compare October 4, 2018 14:58
@jklymak jklymak force-pushed the fix-correct-get-position-errors branch from d4c7069 to 78db75f Compare October 4, 2018 15:15
@@ -327,9 +327,10 @@ def _remove_method(h):
return ax2

def get_tightbbox(self, renderer, call_axes_locator=True):
bbs = [ax.get_tightbbox(renderer, call_axes_locator)
bbs = [ax.get_tightbbox(renderer, call_axes_locator=call_axes_locator)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how this change is needed? (doesn't hurt, but still?)

@jklymak jklymak mentioned this pull request Oct 12, 2018
@tacaswell tacaswell merged commit ff53308 into matplotlib:master Oct 12, 2018
@lumberbot-app
Copy link

lumberbot-app bot commented Oct 12, 2018

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.0.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 ff533081242308803ecdad75cd2539c999278e66
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #12363: FIX: errors in get_position changes'
  1. Push to a named branch :
git push YOURFORK v3.0.x:auto-backport-of-pr-12363-on-v3.0.x
  1. Create a PR against branch v3.0.x, I would have named this PR:

"Backport PR #12363 on branch v3.0.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

jklymak pushed a commit to jklymak/matplotlib that referenced this pull request Oct 12, 2018
…tion-errors

FIX: errors in get_position changes
QuLogic added a commit that referenced this pull request Oct 13, 2018
@jklymak jklymak deleted the fix-correct-get-position-errors branch October 22, 2018 17:41
@jklymak jklymak added the topic: geometry manager LayoutEngine, Constrained layout, Tight layout label Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error for bbox_inches='tight' in savefig with make_axes_locatable
7 participants