Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
toAxes.legend
, it calls "_get_packed_offsets" (from the moduleoffsetbox
) with an argumentwd_list
that is longer than 1, which triggers a code path wheretotal
is used in arithmetic operations before that the processing of the casetotal 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
Edit: The PEP 8 checking was successful :). And added more details on the PR.