MCPcopy Index your code
hub / github.com/ipython/ipython / enable_pylab

Method enable_pylab

IPython/core/interactiveshell.py:3862–3902  ·  view source on GitHub ↗

Activate pylab support at runtime. This turns on support for matplotlib, preloads into the interactive namespace all of numpy and pylab, and configures IPython to correctly interact with the GUI event loop. The GUI backend to be used can be optionally selected with

(self, gui=None, import_all=True)

Source from the content-addressed store, hash-verified

3860 return gui, backend
3861
3862 def enable_pylab(self, gui=None, import_all=True):
3863 """Activate pylab support at runtime.
3864
3865 This turns on support for matplotlib, preloads into the interactive
3866 namespace all of numpy and pylab, and configures IPython to correctly
3867 interact with the GUI event loop. The GUI backend to be used can be
3868 optionally selected with the optional ``gui`` argument.
3869
3870 This method only adds preloading the namespace to InteractiveShell.enable_matplotlib.
3871
3872 Parameters
3873 ----------
3874 gui : optional, string
3875 If given, dictates the choice of matplotlib GUI backend to use
3876 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3877 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3878 matplotlib (as dictated by the matplotlib build-time options plus the
3879 user's matplotlibrc configuration file). Note that not all backends
3880 make sense in all contexts, for example a terminal ipython can't
3881 display figures inline.
3882 import_all : optional, bool, default: True
3883 Whether to do `from numpy import *` and `from pylab import *`
3884 in addition to module imports.
3885 """
3886 from IPython.core.pylabtools import import_pylab
3887
3888 gui, backend = self.enable_matplotlib(gui)
3889
3890 # We want to prevent the loading of pylab to pollute the user's
3891 # namespace as shown by the %who* magics, so we execute the activation
3892 # code in an empty namespace, and we update *both* user_ns and
3893 # user_ns_hidden with this information.
3894 ns = {}
3895 import_pylab(ns, import_all)
3896 # warn about clobbered names
3897 ignored = {"__builtins__"}
3898 both = set(ns).intersection(self.user_ns).difference(ignored)
3899 clobbered = [ name for name in both if self.user_ns[name] is not ns[name] ]
3900 self.user_ns.update(ns)
3901 self.user_ns_hidden.update(ns)
3902 return gui, backend, clobbered
3903
3904 #-------------------------------------------------------------------------
3905 # Utilities

Callers 2

init_gui_pylabMethod · 0.80
pylabMethod · 0.80

Calls 3

enable_matplotlibMethod · 0.95
import_pylabFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected