Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: add ability to remove layout engine#22452

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 2 commits intomatplotlib:mainfromtacaswell:enh_null_layout_engine
Aug 9, 2022

Conversation

tacaswell
Copy link
Member

PR Summary

This may be too simplistic as it just sets it to None which gives you ability
to "go through zero" and change to an incompatible layout engine.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@tacaswelltacaswell added this to thev3.6.0 milestoneFeb 11, 2022
Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

Ping@jklymak are there any traps when removing layouts?

@jklymak
Copy link
Member

I can't think of any. It just doesn't get run.

timhoffm reacted with thumbs up emoji

@tacaswelltacaswellforce-pushed theenh_null_layout_engine branch 3 times, most recently fromaa2a746 todd7c2e0CompareMarch 25, 2022 03:30
@tacaswell
Copy link
MemberAuthor

I added aNullLayoutEngine despite@anntzer 's concerns because I was worried about

fig.set_layout_engine('tight')fig.set_layout_engine('none')fig.set_layout_engine('constrained')

as away of "going through 0" and doing something that we put a bunch of effort into preventing!

self._colorbar_gridspec = colorbar_gridspec
super().__init__(**kwargs)

def execute(self, fig):
Copy link
Member

Choose a reason for hiding this comment

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

I guess I'm not sure about adding a Null engine here. It makesset_layout_engine('none') go through a (slightly) different codepath than never setting the layout engine at all. If we do this, we should probably initialize the figure with this NullLayoutEngine? But I'm not sure why we want to have this at all.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We can not stick a formatter on at init time without making the bools tri-states ({unset, True, False}). This acts as a no-op place holder that remember the colorbar related settings without inventing another side-band way to store that.

Unfortunately I think that "never been set" vs "was set and then removed" are in fact different.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see - we don't want to switch colorbar behaviour after it has started to be used... So we are turning off the algorithm, but keeping its side effect.

At some point we need to figure out how to ditch the two ways of placing colorbars without breaking everybody.

tacaswell reacted with thumbs up emoji
@jklymak
Copy link
Member

Doc build error:

WARNING: error while formatting signature for matplotlib.layout_engine.NullLayoutEnigne: Handler <function mangle_signature at 0x7f20ea43a4c0> for event 'autodoc-process-signature' threw an exception (exception: Unknown section Parameter in the docstring of NullLayoutEnigne in /home/circleci/project/lib/matplotlib/layout_engine.py.)

@jklymakjklymak added topic: geometry managerLayoutEngine, Constrained layout, Tight layout status: needs review labelsMay 24, 2022
@jklymak
Copy link
Member

I'll move to draft until the doc error is fixed...

@jklymakjklymak marked this pull request as draftJune 2, 2022 14:31
@tacaswelltacaswell marked this pull request as ready for reviewJune 2, 2022 17:02
@@ -101,6 +101,28 @@ def execute(self, fig):
raise NotImplementedError


class NullLayoutEngine(LayoutEngine):
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to have this public?

Can we think of a better name? Something that catches "mirror the behavior of whatever layout engine it is replacing"? Maybe FrozenLayoutEngine or LayoutEngineSnapshot? Also this behavior is the key reason for the existence of the class. It should be prominently in the docstring, not only in the parameter description.

Copy link
Member

Choose a reason for hiding this comment

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

This turns the layout engine off, so I don't think it really freeze the layout manager?

Copy link
Member

Choose a reason for hiding this comment

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

There is a difference betweenNone andNullLayoutEngine, and we have to capture that at least in the docstring but if possible already in the class name.NullLayoutEngine sounds as if it does nothing at all and intuitively I'd have expected that that's equvalent with the initial stateNone.

Copy link
Member

Choose a reason for hiding this comment

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

NullLayoutEngineLockedColorbarImplimentation is a bit long!

Copy link
Member

Choose a reason for hiding this comment

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

BTW, I think this needs to be public because the user can get it as a result fromget_layout_engine. Maybe what is needed is a sentence of explanation for the user in the docs....

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

On the other hand,NullLayoutEngineLockedColorbarImplimentation is not something we expect a user to ever directly create and it very clear about what is it and communicates to the user something funny is going on.

If we document this publicly then it will also be a very unique search term to land users at the right place in the docs.

"""
A no-op LayoutEngine.

This is primarily to act as a place holder if we remove a layout engine.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Thisisprimarilytoactasaplaceholderifweremovealayoutengine.
Thisisactsasaplaceholderifweremovealayoutengine.However,differentlayoutengines
requiredifferentcolorbarimplementationsandsomearenotcompatiblewith``subplots_adjust``,
sothisNullengineretainstherequirementsofthelast-usedlayoutengine.

Copy link
Member

Choose a reason for hiding this comment

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

This is an improvement 👍 . Can you make it even more explicit: "different layout engines require different ..." / "some are not compatible". To my knowledge we have exactly two layout engines we are talking about.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

True, but the goal of this hook was to make it easy to add more / let external libraries provide their own so I think that leaving this general is the optimistic position.

@jklymak
Copy link
Member

... moved to draft pending rebase and rename (which I mean, fine, I don't care what the name is)

@tacaswelltacaswellforce-pushed theenh_null_layout_engine branch fromdcc9693 to1ff8d49CompareJune 26, 2022 03:28
This also adds a "place holder" layout engine to ensure that users can not "gothrough zero" and change to an incompatible layout engine.Co-authored-by: Jody Klymak <jklymak@gmail.com>
@tacaswelltacaswellforce-pushed theenh_null_layout_engine branch from1ff8d49 tof7f3bb6CompareJune 26, 2022 03:30
@jklymak
Copy link
Member

Is this still draft@tacaswell ?

@tacaswelltacaswell marked this pull request as ready for reviewAugust 2, 2022 16:33
@tacaswell
Copy link
MemberAuthor

@jklymak Are you happy with the documentation in this PR?

@jklymak
Copy link
Member

Still looks fine to me! Thanks,

- 'tight' uses `~.TightLayoutEngine`
- 'none' removes layout engine.

If `None`, the behavior is controlled by :rc:`figure.autolayout`
Copy link
Member

Choose a reason for hiding this comment

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

Were we doing*None*?

Copy link
MemberAuthor

@tacaswelltacaswellAug 4, 2022
edited
Loading

Choose a reason for hiding this comment

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

We seem to have about the same number of both

$ ack  '\*None\*' -l | wc     56      56    1865$ ack  '`None`' -l | wc     61      61    2223

[edit updated to exclude docs build product]

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@QuLogicQuLogic merged commit357bac5 intomatplotlib:mainAug 9, 2022
@tacaswelltacaswell deleted the enh_null_layout_engine branchAugust 9, 2022 13:27
@QuLogicQuLogic mentioned this pull requestSep 9, 2022
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer left review comments

@timhoffmtimhoffmtimhoffm left review comments

@oscargusoscargusoscargus left review comments

@QuLogicQuLogicQuLogic approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Labels
topic: geometry managerLayoutEngine, Constrained layout, Tight layout
Projects
None yet
Milestone
v3.6.0
Development

Successfully merging this pull request may close these issues.

6 participants
@tacaswell@jklymak@QuLogic@anntzer@timhoffm@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp