| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Benchmarkshttps://github.com/matplotlib/mpl-bench % asv dev --bench constrained master:asv dev --bench constrained
· Discovering benchmarks
· Running 2 total benchmarks (1 commits * 1 environments * 2 benchmarks)
[ 0.00%] ·· Benchmarking existing-py_Users_jklymak_anaconda3_envs_matplotlibdev_bin_python
[ 25.00%] ··· constrained_layout.time_subplots ok
[ 25.00%] ··· === ==========
n
--- ----------
1 55.3±0ms
2 184±0ms
5 833±0ms
=== ==========
[ 50.00%] ··· constrained_layout.time_subplots_colorbar ok
[ 50.00%] ··· === =========
n
--- ---------
1 134±0ms
2 448±0ms
4 1.34±0s
=== =========
This PR:[ 25.00%] ··· constrained_layout.time_subplots ok
[ 25.00%] ··· === ==========
n
--- ----------
1 85.5±0ms
2 208±0ms
5 836±0ms
=== ==========
[ 50.00%] ··· constrained_layout.time_subplots_colorbar ok
[ 50.00%] ··· === =========
n
--- ---------
1 120±0ms
2 452±0ms
4 1.35±0s
=== =========
|
Sorry, something went wrong.
|
This is inspired by #19892 where we will probably move towards making layout managers more modular.... |
Sorry, something went wrong.
|
One note - for constrained_layout, at least, the figure does need to know that it is being used before any colorbars are added so that it can use the non-gridspec colorbars. So, in general, its not possible to strip all layout manager state to draw time. However, this PR is still useful because it allows more layout manager state to be determined at draw time. |
Sorry, something went wrong.
|
I'd like to get this in so #20426 can get in for 3.5. Note this is a relatively straightforward change, despite its apparent length. The logic for creating the layout boxes that comprise constrained_layout are created at draw-time instead of when the figure and gridspecs are created. |
Sorry, something went wrong.
|
|
||
|
|
||
| def _make_layout_margins(fig, renderer, *, w_pad=0, h_pad=0, | ||
| def _make_layout_margins(_layoutgrids, fig, renderer, *, w_pad=0, h_pad=0, |
There was a problem hiding this comment.
Changes from here and below are just adding the _layoutgrids structure to all the methods....
Sorry, something went wrong.
| return _layoutgrids | ||
|
|
||
|
|
||
| def _make_layoutgrids(fig, _layoutgrids): |
There was a problem hiding this comment.
this logic was all in figure.py.
Sorry, something went wrong.
| return _layoutgrids | ||
|
|
||
|
|
||
| def _make_layoutgrids_gs(_layoutgrids, gs): |
There was a problem hiding this comment.
This logic was all in gridspecs.py
Sorry, something went wrong.
| """ | ||
| return self._parent.get_constrained_layout_pads(relative=relative) | ||
|
|
||
| def init_layoutgrid(self): |
There was a problem hiding this comment.
This was moved to _constrained_layout Not how there are no _layoutgrids attached to the figure any longer...
Sorry, something went wrong.
There was a problem hiding this comment.
Do you want to add a changelog note?
Sorry, something went wrong.
There was a problem hiding this comment.
Do we need one for private attributes?
Sorry, something went wrong.
There was a problem hiding this comment.
Nope.
Sorry, something went wrong.
| width_ratios=width_ratios, | ||
| height_ratios=height_ratios) | ||
|
|
||
| # set up layoutgrid for constrained_layout: |
There was a problem hiding this comment.
All moved to _constrained_layout.py and happens at draw time...
Sorry, something went wrong.
| _layoutgrids[fig] = layoutgrid.LayoutGrid( | ||
| parent=parentlb, | ||
| name=(parentlb.name + '.' + 'panellb' + | ||
| layoutgrid.seq_id()), |
There was a problem hiding this comment.
Perhaps you can have a seq_id(<prefix>) function to avoid all these string manipulations everywhere.
(possibly in a separate PR)
Sorry, something went wrong.
There was a problem hiding this comment.
Sure, I just moved it into LayoutGrid. The names were just for debug purposes to keep track of what each grid was supposed to be containing.
Sorry, something went wrong.
Benchmark with 30 draws per benchmark:master:$ asv dev --bench constrained
· Discovering benchmarks
· Running 2 total benchmarks (1 commits * 1 environments * 2 benchmarks)
[ 0.00%] ·· Benchmarking existing-py_Users_jklymak_anaconda3_envs_matplotlibdev_bin_python
[ 25.00%] ··· constrained_layout.time_subplots ok
[ 25.00%] ··· === =========
n
--- ---------
1 868±0ms
2 3.27±0s
5 17.4±0s
=== =========
[ 50.00%] ··· constrained_layout.time_subplots_colorbar ok
[ 50.00%] ··· === =========
n
--- ---------
1 2.22±0s
2 8.48±0s
4 28.9±0s
=== =========
This PR:$ asv dev --bench constrained
· Discovering benchmarks
· Running 2 total benchmarks (1 commits * 1 environments * 2 benchmarks)
[ 0.00%] ·· Benchmarking existing-py_Users_jklymak_anaconda3_envs_matplotlibdev_bin_python
[ 25.00%] ··· constrained_layout.time_subplots ok
[ 25.00%] ··· === =========
n
--- ---------
1 928±0ms
2 3.31±0s
5 16.5±0s
=== =========
[ 50.00%] ··· constrained_layout.time_subplots_colorbar ok
[ 50.00%] ··· === =========
n
--- ---------
1 2.27±0s
2 8.98±0s
4 28.1±0s
=== =========
Same benchmark, but constrained_layout=Falseasv dev --bench constrained
· Discovering benchmarks
· Running 2 total benchmarks (1 commits * 1 environments * 2 benchmarks)
[ 0.00%] ·· Benchmarking existing-py_Users_jklymak_anaconda3_envs_matplotlibdev_bin_python
[ 25.00%] ··· constrained_layout.time_subplots ok
[ 25.00%] ··· === =========
n
--- ---------
1 404±0ms
2 1.57±0s
5 6.59±0s
=== =========
[ 50.00%] ··· constrained_layout.time_subplots_colorbar ok
[ 50.00%] ··· === =========
n
--- ---------
1 925±0ms
2 2.95±0s
4 9.16±0s
=== =========
|
Sorry, something went wrong.
|
I'll pop this to "merge with single review". There are no API changes, and its operating on something we still nominally consider experimental. |
Sorry, something went wrong.
| return layoutgrids | ||
|
|
||
|
|
||
| def make_layoutgrids(fig, layoutgrids): |
There was a problem hiding this comment.
All the others take layoutgrids first; should this not do the same also?
Sorry, something went wrong.
There was a problem hiding this comment.
This is (usually) called first, so the layoutgrids is only if we are doing the call recursively....
Sorry, something went wrong.
|
I think you missed a couple of the alignment comments, but otherwise LGTM. |
Sorry, something went wrong.
fixed now, thanks... |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
This PR moves all of the state for constrained_layout out of figure and gridspec except for the kwargs in figure. There are a few clear advantages.
This may have a minor speed hit because all the layout boxes are made each draw, but I doubt its very significant
PR Checklist