From 2ba9f296afb3c2a831e5d1b6bb1293bed293b357 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 5 Aug 2020 15:09:44 -0400 Subject: [PATCH 1/2] Go back to checking figures for their manager in destroy. This is a partial revert of a small part of #13581. Fixes #18163. --- lib/matplotlib/_pylab_helpers.py | 7 ++++--- lib/matplotlib/tests/test_backend_bases.py | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/_pylab_helpers.py b/lib/matplotlib/_pylab_helpers.py index 907e69957ca2..26ba7a171244 100644 --- a/lib/matplotlib/_pylab_helpers.py +++ b/lib/matplotlib/_pylab_helpers.py @@ -71,9 +71,10 @@ def destroy(cls, num): @classmethod def destroy_fig(cls, fig): """Destroy figure *fig*.""" - canvas = getattr(fig, "canvas", None) - manager = getattr(canvas, "manager", None) - cls.destroy(manager) + num = next((manager.num for manager in cls.figs.values() + if manager.canvas.figure == fig), None) + if num is not None: + cls.destroy(num) @classmethod def destroy_all(cls): diff --git a/lib/matplotlib/tests/test_backend_bases.py b/lib/matplotlib/tests/test_backend_bases.py index d8d7f252af1c..7da6ed026b13 100644 --- a/lib/matplotlib/tests/test_backend_bases.py +++ b/lib/matplotlib/tests/test_backend_bases.py @@ -60,6 +60,15 @@ def test_get_default_filename(tmpdir): assert filename == 'image.png' +def test_canvas_change(): + fig = plt.figure() + # Replaces fig.canvas + canvas = FigureCanvasBase(fig) + # Should still work. + plt.close(fig) + assert not plt.fignum_exists(fig.number) + + @pytest.mark.backend('pdf') def test_non_gui_warning(monkeypatch): plt.subplots() From db6fb4dff060f63b8b10f06cf7bd9e46bc41fc94 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 10 Aug 2020 16:36:34 -0400 Subject: [PATCH 2/2] Skip test_interactive_backend on macOS Travis. We will follow up on this later, #18213. --- lib/matplotlib/tests/test_backends_interactive.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index 5bd06baa8b26..592169e03da5 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -154,8 +154,13 @@ def check_alt_backend(alt_backend): @pytest.mark.parametrize("toolbar", ["toolbar2", "toolmanager"]) @pytest.mark.flaky(reruns=3) def test_interactive_backend(backend, toolbar): - if backend == "macosx" and toolbar == "toolmanager": - pytest.skip("toolmanager is not implemented for macosx.") + if backend == "macosx": + if toolbar == "toolmanager": + pytest.skip("toolmanager is not implemented for macosx.") + if toolbar == "toolbar2" and os.environ.get('TRAVIS'): + # See https://github.com/matplotlib/matplotlib/issues/18213 + pytest.skip("toolbar2 for macosx is buggy on Travis.") + proc = subprocess.run( [sys.executable, "-c", _test_script, json.dumps({"toolbar": toolbar})], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy