diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index df1fe07bf29..21de1b47cea 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -3517,7 +3517,6 @@ def enable_matplotlib(self, gui=None): gui, backend = pt.find_gui_and_backend(self.pylab_gui_select) pt.activate_matplotlib(backend) - pt.configure_inline_support(self, backend) # Now we must activate the gui pylab wants to use, and fix %run to take # plot updates into account diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py index 3af899e46da..1a937067795 100644 --- a/IPython/core/pylabtools.py +++ b/IPython/core/pylabtools.py @@ -358,62 +358,3 @@ def import_pylab(user_ns, import_all=True): # Add display and getfigs to the user's namespace user_ns['display'] = display user_ns['getfigs'] = getfigs - - -def configure_inline_support(shell, backend): - """Configure an IPython shell object for matplotlib use. - - Parameters - ---------- - shell : InteractiveShell instance - - backend : matplotlib backend - """ - # If using our svg payload backend, register the post-execution - # function that will pick up the results for display. This can only be - # done with access to the real shell object. - - # Note: if we can't load the inline backend, then there's no point - # continuing (such as in terminal-only shells in environments without - # zeromq available). - try: - from ipykernel.pylab.backend_inline import InlineBackend - except ImportError: - return - import matplotlib - - cfg = InlineBackend.instance(parent=shell) - cfg.shell = shell - if cfg not in shell.configurables: - shell.configurables.append(cfg) - - if backend == backends['inline']: - from ipykernel.pylab.backend_inline import flush_figures - shell.events.register('post_execute', flush_figures) - - # Save rcParams that will be overwrittern - shell._saved_rcParams = {} - for k in cfg.rc: - shell._saved_rcParams[k] = matplotlib.rcParams[k] - # load inline_rc - matplotlib.rcParams.update(cfg.rc) - new_backend_name = "inline" - else: - from ipykernel.pylab.backend_inline import flush_figures - try: - shell.events.unregister('post_execute', flush_figures) - except ValueError: - pass - if hasattr(shell, '_saved_rcParams'): - matplotlib.rcParams.update(shell._saved_rcParams) - del shell._saved_rcParams - new_backend_name = "other" - - # only enable the formats once -> don't change the enabled formats (which the user may - # has changed) when getting another "%matplotlib inline" call. - # See https://github.com/ipython/ipykernel/issues/29 - cur_backend = getattr(configure_inline_support, "current_backend", "unset") - if new_backend_name != cur_backend: - # Setup the default figure format - select_figure_formats(shell, cfg.figure_formats, **cfg.print_figure_kwargs) - configure_inline_support.current_backend = new_backend_name diff --git a/IPython/core/tests/test_pylabtools.py b/IPython/core/tests/test_pylabtools.py index 75b103f27a6..3e62fbec7ac 100644 --- a/IPython/core/tests/test_pylabtools.py +++ b/IPython/core/tests/test_pylabtools.py @@ -167,13 +167,10 @@ def act_mpl(backend): pt.activate_matplotlib = act_mpl self._save_ip = pt.import_pylab pt.import_pylab = lambda *a,**kw:None - self._save_cis = pt.configure_inline_support - pt.configure_inline_support = lambda *a,**kw:None def teardown(self): pt.activate_matplotlib = self._save_am pt.import_pylab = self._save_ip - pt.configure_inline_support = self._save_cis import matplotlib matplotlib.rcParams = self._saved_rcParams matplotlib.rcParamsOrig = self._saved_rcParamsOrig