11"""A matplotlib backend for publishing figures via display_data"""
2- #-----------------------------------------------------------------------------
3- # Copyright (C) 2011 The IPython Development Team
4- #
5- # Distributed under the terms of the BSD License. The full license is in
6- # the file COPYING, distributed as part of this software.
7- #-----------------------------------------------------------------------------
8-
9- #-----------------------------------------------------------------------------
10- # Imports
11- #-----------------------------------------------------------------------------
2+
3+ # Copyright (c) IPython Development Team.
4+ # Distributed under the terms of the Modified BSD License.
5+
126from __future__ import print_function
137
14- # Third-party imports
158import matplotlib
169from matplotlib .backends .backend_agg import new_figure_manager , FigureCanvasAgg # analysis: ignore
1710from matplotlib ._pylab_helpers import Gcf
1811
19- # Local imports
2012from IPython .core .getipython import get_ipython
2113from IPython .core .display import display
2214
2315from .config import InlineBackend
2416
25- #-----------------------------------------------------------------------------
26- # Functions
27- #-----------------------------------------------------------------------------
2817
2918def show (close = None ):
3019 """Show all figures as SVG/PNG payloads sent to the IPython clients.
@@ -43,7 +32,9 @@ def show(close=None):
4332 display (figure_manager .canvas .figure )
4433 finally :
4534 show ._to_draw = []
46- if close :
35+ # only call close('all') if any to close
36+ # close triggers gc.collect, which can be slow
37+ if close and Gcf .get_all_fig_managers ():
4738 matplotlib .pyplot .close ('all' )
4839
4940
0 commit comments