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

Commitd5f1d55

Browse files
authored
Merge pull request#18214 from meeseeksmachine/auto-backport-of-pr-18184-on-v3.3.x
Backport PR#18184 on branch v3.3.x (Go back to checking figures for their manager in destroy.)
2 parents9908136 +0745b37 commitd5f1d55

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

‎lib/matplotlib/_pylab_helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ def destroy(cls, num):
7171
@classmethod
7272
defdestroy_fig(cls,fig):
7373
"""Destroy figure *fig*."""
74-
canvas=getattr(fig,"canvas",None)
75-
manager=getattr(canvas,"manager",None)
76-
cls.destroy(manager)
74+
num=next((manager.numformanagerincls.figs.values()
75+
ifmanager.canvas.figure==fig),None)
76+
ifnumisnotNone:
77+
cls.destroy(num)
7778

7879
@classmethod
7980
defdestroy_all(cls):

‎lib/matplotlib/tests/test_backend_bases.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ def test_get_default_filename(tmpdir):
6060
assertfilename=='image.png'
6161

6262

63+
deftest_canvas_change():
64+
fig=plt.figure()
65+
# Replaces fig.canvas
66+
canvas=FigureCanvasBase(fig)
67+
# Should still work.
68+
plt.close(fig)
69+
assertnotplt.fignum_exists(fig.number)
70+
71+
6372
@pytest.mark.backend('pdf')
6473
deftest_non_gui_warning(monkeypatch):
6574
plt.subplots()

‎lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,13 @@ def check_alt_backend(alt_backend):
146146
@pytest.mark.parametrize("toolbar", ["toolbar2","toolmanager"])
147147
@pytest.mark.flaky(reruns=3)
148148
deftest_interactive_backend(backend,toolbar):
149-
ifbackend=="macosx"andtoolbar=="toolmanager":
150-
pytest.skip("toolmanager is not implemented for macosx.")
149+
ifbackend=="macosx":
150+
iftoolbar=="toolmanager":
151+
pytest.skip("toolmanager is not implemented for macosx.")
152+
iftoolbar=="toolbar2"andos.environ.get('TRAVIS'):
153+
# See https://github.com/matplotlib/matplotlib/issues/18213
154+
pytest.skip("toolbar2 for macosx is buggy on Travis.")
155+
151156
proc=subprocess.run(
152157
[sys.executable,"-c",_test_script,
153158
json.dumps({"toolbar":toolbar})],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp