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

Skip to content

Fix offsetbox expand mode #10787

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
Mar 15, 2018

Conversation

afvincent
Copy link
Contributor

@afvincent afvincent commented Mar 14, 2018

PR Summary

Fixes #10784.

Small fix of a the “hacky” fix (b177c85) about issues when calling tight_layout with a legend in "expand" mode.

My understanding of the “new” issue is that when passing ncol=2 # or more to Axes.legend, it calls "_get_packed_offsets" (from the module offsetbox) with an argument wd_list that is longer than 1, which triggers a code path where total is used in arithmetic operations before that the processing of the case total is None introduced by b177c85 is actually performed. The core idea of this PR is simply to move that special-case processing before the arithmetic operation causing the issue.

Being there I simplified a bit the original test. I also added a test of the private function that triggered all those errors, with sets of parameters that should cover at least the edge-cases that have been recently found (mode = "expand"), and hopefully check that other corner cases do not raise exceptions. For the record, this multi-test (240 subtests) adds about 1.1 s to the testing time on my machine.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant

Edit: The PEP 8 checking was successful :). And added more details on the PR.

@afvincent afvincent added this to the v2.2.1 milestone Mar 14, 2018
@afvincent afvincent requested a review from tacaswell March 14, 2018 19:22
@dopplershift dopplershift merged commit c1eeb4c into matplotlib:master Mar 15, 2018
lumberbot-app bot pushed a commit that referenced this pull request Mar 15, 2018
timhoffm added a commit that referenced this pull request Mar 15, 2018
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.

axes.legend TypeError in v2.2.0
3 participants