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

Skip to content

FIX: Don't let constrained_layout counter overflow #11330

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

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented May 29, 2018

PR Summary

constrained_layout adds a unique number to each layout element. However, if many figures are open
this number was overflowing 1000. For some reason kiwisolver doesn't like the longer integers in the variable names (which is a bit of a mystery in itself, but kind of moot - if someone had 1000 elements in their constrained_layout I think they'd be pretty sad about how long it took to render).

This simply resets the iterator every time a new figure is made....

No test, as it requires making > 1000 elements, and it'd take quite a while (~60 s or so on my machine, though I'm doing a write as well). Also not sure how to check that the last CL is correct.

Test code:

import numpy as np
import matplotlib.pyplot as plt

plt.ioff()
fig = None
for a in range(40):
    fig, ax = plt.subplots(4, 4, constrained_layout=True)
    ax = ax.flatten()
    ax[0].plot(range(10))
    ax[1].plot(range(20))
    fig.savefig('booos/boo%03d.png'%a)

PR Checklist

  • Code is PEP 8 compliant

@jklymak jklymak added the topic: geometry manager LayoutEngine, Constrained layout, Tight layout label May 29, 2018
@jklymak jklymak force-pushed the fix-constrained-layout-too-many-constraints branch from 4949b3c to 5ebc6b0 Compare May 29, 2018 00:28
@tacaswell tacaswell added this to the v3.0 milestone May 29, 2018
@tacaswell
Copy link
Member

Will this cause collisions if I create a figure, work on it for a bit, create a second figure, and then go back to working in the first figure?

@jklymak jklymak force-pushed the fix-constrained-layout-too-many-constraints branch 2 times, most recently from c0d2ed1 to 476b101 Compare May 29, 2018 04:14
@jklymak
Copy link
Member Author

jklymak commented May 29, 2018

Will this cause collisions if I create a figure, work on it for a bit, create a second figure, and then go back to working in the first figure?

No, the name doesn't matter. But, if the name didn't matter, why was the name mattering? Turned out I'd hard coded the 3 digits into a few places, which was a mistake and the actual bug.

@jklymak jklymak force-pushed the fix-constrained-layout-too-many-constraints branch 4 times, most recently from 4466bc4 to e8f2a4d Compare May 29, 2018 13:34
@jklymak jklymak force-pushed the fix-constrained-layout-too-many-constraints branch from 7c2427f to 96c4e28 Compare May 29, 2018 14:17
@jklymak jklymak force-pushed the fix-constrained-layout-too-many-constraints branch from 96c4e28 to b4ef275 Compare May 29, 2018 16:24
@jklymak jklymak changed the title FIX: Reset constrained_layout counter for each new figure FIX: Don't let constrained_layout counter overflow May 30, 2018
@phobson phobson merged commit 1f0121a into matplotlib:master Jun 5, 2018
@jklymak jklymak deleted the fix-constrained-layout-too-many-constraints branch August 4, 2018 16:07
@jklymak jklymak modified the milestones: v3.0, v2.2.3 Aug 4, 2018
@jklymak
Copy link
Member Author

jklymak commented Aug 4, 2018

@meeseeksdev backport to v2.2.x

@lumberbot-app
Copy link

lumberbot-app bot commented Aug 4, 2018

There seem to be a conflict, please backport manually

tacaswell added a commit that referenced this pull request Aug 4, 2018
Backport: Pull Request #11330: FIX: Don't let constrained_layout counter overflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants