<s> """<STR_LIT>""" <EOL> import sys <EOL> import matplotlib <EOL> from matplotlib . backends . backend_agg import new_figure_manager <EOL> from matplotlib . _pylab_helpers import Gcf <EOL> from IPython . config . configurable import SingletonConfigurable <EOL> from IPython . core . displaypub import publish_display_data <EOL> from IPython . lib . pylabtools import print_figure , select_figure_format <EOL> from IPython . utils . traitlets import Dict , Instance , CaselessStrEnum <EOL> class InlineBackendConfig ( SingletonConfigurable ) : <EOL> """<STR_LIT>""" <EOL> rc = Dict ( { '<STR_LIT>' : ( <NUM_LIT> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } , config = True , <EOL> help = """<STR_LIT>""" <EOL> ) <EOL> figure_format = CaselessStrEnum ( [ '<STR_LIT>' , '<STR_LIT>' ] , default_value = '<STR_LIT>' , config = True , <EOL> help = "<STR_LIT>" ) <EOL> def _figure_format_changed ( self , name , old , new ) : <EOL> if self . shell is None : <EOL> return <EOL> else : <EOL> select_figure_format ( self . shell , new ) <EOL> shell = Instance ( '<STR_LIT>' ) <EOL> def show ( close = True ) : <EOL> """<STR_LIT>""" <EOL> for figure_manager in Gcf . get_all_fig_managers ( ) : <EOL> send_figure ( figure_manager . canvas . figure ) <EOL> if close : <EOL> matplotlib . pyplot . close ( '<STR_LIT:all>' ) <EOL> show . _draw_called = False <EOL> def draw_if_interactive ( ) : <EOL> """<STR_LIT>""" <EOL> show . _draw_called = True <EOL> def flush_figures ( ) : <EOL> """<STR_LIT>""" <EOL> if show . _draw_called : <EOL> show ( ) <EOL> show . _draw_called = False <EOL> def send_figure ( fig ) : <EOL> """<STR_LIT>""" <EOL> if not fig . axes : <EOL> return <EOL> fmt = InlineBackendConfig . instance ( ) . figure_format <EOL> data = print_figure ( fig , fmt ) <EOL> mimetypes = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> mime = mimetypes [ fmt ] <EOL> sys . stdout . flush ( ) ; sys . stderr . flush ( ) <EOL> publish_display_data ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> { mime : data } <EOL> ) </s>
