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

Skip to content

Commit 0f77ba9

Browse files
committed
MNT: make layout deprecations pending
TST: fix the tests
1 parent 075067c commit 0f77ba9

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lib/matplotlib/figure.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,7 +2484,8 @@ def get_tight_layout(self):
24842484
"""Return whether `.tight_layout` is called when drawing."""
24852485
return isinstance(self.get_layout_engine(), TightLayoutEngine)
24862486

2487-
@_api.deprecated("3.6", alternative="set_layout_engine")
2487+
@_api.deprecated("3.6", alternative="set_layout_engine",
2488+
pending=True)
24882489
def set_tight_layout(self, tight):
24892490
"""
24902491
Set whether and how `.tight_layout` is called when drawing.
@@ -2512,7 +2513,8 @@ def get_constrained_layout(self):
25122513
"""
25132514
return isinstance(self.get_layout_engine(), ConstrainedLayoutEngine)
25142515

2515-
@_api.deprecated("3.6", alternative="set_layout_engine('constrained')")
2516+
@_api.deprecated("3.6", alternative="set_layout_engine('constrained')",
2517+
pending=True)
25162518
def set_constrained_layout(self, constrained):
25172519
"""
25182520
Set whether ``constrained_layout`` is used upon drawing. If None,
@@ -2538,7 +2540,8 @@ def set_constrained_layout(self, constrained):
25382540
self.stale = True
25392541

25402542
@_api.deprecated(
2541-
"3.6", alternative="figure.get_layout_engine().set()")
2543+
"3.6", alternative="figure.get_layout_engine().set()",
2544+
pending=True)
25422545
def set_constrained_layout_pads(self, **kwargs):
25432546
"""
25442547
Set padding for ``constrained_layout``.
@@ -2570,7 +2573,8 @@ def set_constrained_layout_pads(self, **kwargs):
25702573
if isinstance(self.get_layout_engine(), ConstrainedLayoutEngine):
25712574
self.get_layout_engine().set(**kwargs)
25722575

2573-
@_api.deprecated("3.6", alternative="fig.get_layout_engine().get_info()")
2576+
@_api.deprecated("3.6", alternative="fig.get_layout_engine().get_info()",
2577+
pending=True)
25742578
def get_constrained_layout_pads(self, relative=False):
25752579
"""
25762580
Get padding for ``constrained_layout``.

lib/matplotlib/tests/test_constrainedlayout.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from matplotlib._api.deprecation import MatplotlibDeprecationWarning
21
import numpy as np
32
import pytest
43

@@ -594,14 +593,14 @@ def test_discouraged_api():
594593
fig, ax = plt.subplots(constrained_layout=True)
595594
fig.draw_without_rendering()
596595

597-
with pytest.warns(MatplotlibDeprecationWarning,
598-
match="was deprecated in Matplotlib 3.6"):
596+
with pytest.warns(PendingDeprecationWarning,
597+
match="will be deprecated"):
599598
fig, ax = plt.subplots()
600599
fig.set_constrained_layout(True)
601600
fig.draw_without_rendering()
602601

603-
with pytest.warns(MatplotlibDeprecationWarning,
604-
match="was deprecated in Matplotlib 3.6"):
602+
with pytest.warns(PendingDeprecationWarning,
603+
match="will be deprecated"):
605604
fig, ax = plt.subplots()
606605
fig.set_constrained_layout({'w_pad': 0.02, 'h_pad': 0.02})
607606
fig.draw_without_rendering()

lib/matplotlib/tests/test_tightlayout.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import warnings
2-
from matplotlib._api.deprecation import MatplotlibDeprecationWarning
32

43
import numpy as np
54
from numpy.testing import assert_array_equal
@@ -372,8 +371,8 @@ def test_clipped_to_axes():
372371

373372
def test_tight_pads():
374373
fig, ax = plt.subplots()
375-
with pytest.warns(MatplotlibDeprecationWarning,
376-
match='was deprecated in Matplotlib 3.6'):
374+
with pytest.warns(PendingDeprecationWarning,
375+
match='will be deprecated'):
377376
fig.set_tight_layout({'pad': 0.15})
378377
fig.draw_without_rendering()
379378

0 commit comments

Comments
 (0)