parameters: (safe_execfile)
return_statement: return mpl_execfile
docstring: Factory to return a matplotlib-enabled runner for %run.
  
      Parameters
      ----------
      safe_execfile : function
        This must be a function with the same interface as the
        :meth:`safe_execfile` method of IPython.
  
      Returns
      -------
      A function suitable for use as the ``runner`` argument of the %run magic
      function.
docstring_summary: Factory to return a matplotlib-enabled runner for %run.
docstring_tokens: Factory to return a matplotlib - enabled runner for %run .
function: def mpl_runner(safe_execfile):
      """Factory to return a matplotlib-enabled runner for %run.
  
      Parameters
      ----------
      safe_execfile : function
        This must be a function with the same interface as the
        :meth:`safe_execfile` method of IPython.
  
      Returns
      -------
      A function suitable for use as the ``runner`` argument of the %run magic
      function.
      """
  
      def mpl_execfile(fname,*where,**kw):
          """matplotlib-aware wrapper around safe_execfile.
  
          Its interface is identical to that of the :func:`execfile` builtin.
  
          This is ultimately a call to execfile(), but wrapped in safeties to
          properly handle interactive rendering."""
  
          import matplotlib
          import matplotlib.pyplot as plt
  
          #print '*** Matplotlib runner ***' # dbg
          # turn off rendering until end of script
          is_interactive = matplotlib.rcParams['interactive']
          matplotlib.interactive(False)
          safe_execfile(fname,*where,**kw)
          matplotlib.interactive(is_interactive)
          # make rendering call now, if the user tried to do it
          if plt.draw_if_interactive.called:
              plt.draw()
              plt.draw_if_interactive.called = False
  
          # re-draw everything that is stale
          try:
              da = plt.draw_all
          except AttributeError:
              pass
          else:
              da()
  
      return mpl_execfile
function_tokens: def mpl_runner ( safe_execfile ) : def mpl_execfile ( fname , * where , * * kw ) : """matplotlib-aware wrapper around safe_execfile.
  
          Its interface is identical to that of the :func:`execfile` builtin.
  
          This is ultimately a call to execfile(), but wrapped in safeties to
          properly handle interactive rendering.""" import matplotlib import matplotlib . pyplot as plt #print '*** Matplotlib runner ***' # dbg # turn off rendering until end of script is_interactive = matplotlib . rcParams [ 'interactive' ] matplotlib . interactive ( False ) safe_execfile ( fname , * where , * * kw ) matplotlib . interactive ( is_interactive ) # make rendering call now, if the user tried to do it if plt . draw_if_interactive . called : plt . draw ( ) plt . draw_if_interactive . called = False # re-draw everything that is stale try : da = plt . draw_all except AttributeError : pass else : da ( ) return mpl_execfile