FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix and test deprecated layout method toggling by richardsheridan · Pull Request #22849 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions lib/matplotlib/figure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,8 @@ def set_tight_layout(self, tight):
_tight_parameters = tight if isinstance(tight, dict) else {}
if bool(tight):
self.set_layout_engine(TightLayoutEngine(**_tight_parameters))
else:
self.set_layout_engine(None)
self.stale = True

def get_constrained_layout(self):
Expand Down Expand Up @@ -2569,6 +2571,8 @@ def set_constrained_layout(self, constrained):
_parameters = constrained if isinstance(constrained, dict) else {}
if _constrained:
self.set_layout_engine(ConstrainedLayoutEngine(**_parameters))
else:
self.set_layout_engine(None)
self.stale = True

@_api.deprecated(
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_constrainedlayout.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,12 @@ def test_discouraged_api():
def test_kwargs():
fig, ax = plt.subplots(constrained_layout={'h_pad': 0.02})
fig.draw_without_rendering()


def test_constrained_toggle():
fig, ax = plt.subplots()
with pytest.warns(PendingDeprecationWarning):
fig.set_constrained_layout(True)
assert fig.get_constrained_layout()
fig.set_constrained_layout(False)
assert not fig.get_constrained_layout()
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_tightlayout.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,12 @@ def test_tight_pads():
def test_tight_kwargs():
fig, ax = plt.subplots(tight_layout={'pad': 0.15})
fig.draw_without_rendering()


def test_tight_toggle():
fig, ax = plt.subplots()
with pytest.warns(PendingDeprecationWarning):
fig.set_tight_layout(True)
assert fig.get_tight_layout()
fig.set_tight_layout(False)
assert not fig.get_tight_layout()

Back | FazBrowse Home | New Git URL