##// END OF EJS Templates
Fix name pollution of interactive namespace in pylab mode....
Fernando Perez -
Show More
@@ -381,7 +381,7 b' class IPCompleter(Completer):'
381 """Extension of the completer class with IPython-specific features"""
381 """Extension of the completer class with IPython-specific features"""
382
382
383 def __init__(self, shell, namespace=None, global_namespace=None,
383 def __init__(self, shell, namespace=None, global_namespace=None,
384 omit__names=0, alias_table=None, use_readline=True):
384 omit__names=True, alias_table=None, use_readline=True):
385 """IPCompleter() -> completer
385 """IPCompleter() -> completer
386
386
387 Return a completer object suitable for use by the readline library
387 Return a completer object suitable for use by the readline library
@@ -96,15 +96,17 b' def import_pylab(user_ns, backend, import_all=True, shell=None):'
96
96
97 # Import numpy as np/pyplot as plt are conventions we're trying to
97 # Import numpy as np/pyplot as plt are conventions we're trying to
98 # somewhat standardize on. Making them available to users by default
98 # somewhat standardize on. Making them available to users by default
99 # will greatly help this.
99 # will greatly help this.
100 exec ("import numpy\n"
100 s = ("import numpy\n"
101 "import matplotlib\n"
101 "import matplotlib\n"
102 "from matplotlib import pylab, mlab, pyplot\n"
102 "from matplotlib import pylab, mlab, pyplot\n"
103 "np = numpy\n"
103 "np = numpy\n"
104 "plt = pyplot\n"
104 "plt = pyplot\n"
105 ) in user_ns
105 )
106 exec s in user_ns
106
107
107 if shell is not None:
108 if shell is not None:
109 exec s in shell.user_ns_hidden
108 # If using our svg payload backend, register the post-execution
110 # If using our svg payload backend, register the post-execution
109 # function that will pick up the results for display. This can only be
111 # function that will pick up the results for display. This can only be
110 # done with access to the real shell object.
112 # done with access to the real shell object.
@@ -117,6 +119,7 b' def import_pylab(user_ns, backend, import_all=True, shell=None):'
117 figsize(6.0, 4.0)
119 figsize(6.0, 4.0)
118 # Add 'figsize' to pyplot and to the user's namespace
120 # Add 'figsize' to pyplot and to the user's namespace
119 user_ns['figsize'] = pyplot.figsize = figsize
121 user_ns['figsize'] = pyplot.figsize = figsize
122 shell.user_ns_hidden['figsize'] = figsize
120 else:
123 else:
121 from IPython.zmq.pylab.backend_inline import pastefig
124 from IPython.zmq.pylab.backend_inline import pastefig
122 from matplotlib import pyplot
125 from matplotlib import pyplot
@@ -124,8 +127,11 b' def import_pylab(user_ns, backend, import_all=True, shell=None):'
124 user_ns['pastefig'] = pyplot.pastefig = pastefig
127 user_ns['pastefig'] = pyplot.pastefig = pastefig
125
128
126 if import_all:
129 if import_all:
127 exec("from matplotlib.pylab import *\n"
130 s = ("from matplotlib.pylab import *\n"
128 "from numpy import *\n") in user_ns
131 "from numpy import *\n")
132 exec s in user_ns
133 if shell is not None:
134 exec s in shell.user_ns_hidden
129
135
130
136
131 def pylab_activate(user_ns, gui=None, import_all=True):
137 def pylab_activate(user_ns, gui=None, import_all=True):
General Comments 0
You need to be logged in to leave comments. Login now