Show More
@@ -253,7 +253,7 b' def import_pylab(user_ns, import_all=True):' | |||||
253 | exec s in user_ns |
|
253 | exec s in user_ns | |
254 |
|
254 | |||
255 |
|
255 | |||
256 |
def configure_inline_ |
|
256 | def configure_inline_support(shell, backend, user_ns=None): | |
257 | """Configure an IPython shell object for matplotlib use. |
|
257 | """Configure an IPython shell object for matplotlib use. | |
258 |
|
258 | |||
259 | Parameters |
|
259 | Parameters | |
@@ -261,6 +261,8 b' def configure_inline_backend(shell, user_ns=None):' | |||||
261 | shell : InteractiveShell instance |
|
261 | shell : InteractiveShell instance | |
262 | If None, this function returns immediately. |
|
262 | If None, this function returns immediately. | |
263 |
|
263 | |||
|
264 | backend : matplotlib backend | |||
|
265 | ||||
264 | user_ns : dict |
|
266 | user_ns : dict | |
265 | A namespace where all configured variables will be placed. If not given, |
|
267 | A namespace where all configured variables will be placed. If not given, | |
266 | the `user_ns` attribute of the shell object is used. |
|
268 | the `user_ns` attribute of the shell object is used. | |
@@ -268,25 +270,33 b' def configure_inline_backend(shell, user_ns=None):' | |||||
268 | if shell is None: |
|
270 | if shell is None: | |
269 | return |
|
271 | return | |
270 |
|
272 | |||
271 | user_ns = shell.user_ns if user_ns is None else user_ns |
|
|||
272 |
|
||||
273 | # If using our svg payload backend, register the post-execution |
|
273 | # If using our svg payload backend, register the post-execution | |
274 | # function that will pick up the results for display. This can only be |
|
274 | # function that will pick up the results for display. This can only be | |
275 | # done with access to the real shell object. |
|
275 | # done with access to the real shell object. | |
276 | from IPython.zmq.pylab.backend_inline import InlineBackend |
|
|||
277 |
|
276 | |||
|
277 | # Note: if we can't load the inline backend, then there's no point | |||
|
278 | # continuing (such as in terminal-only shells in environments without | |||
|
279 | # zeromq available). | |||
|
280 | try: | |||
|
281 | from IPython.zmq.pylab.backend_inline import InlineBackend | |||
|
282 | except ImportError: | |||
|
283 | return | |||
|
284 | ||||
|
285 | user_ns = shell.user_ns if user_ns is None else user_ns | |||
|
286 | ||||
278 | cfg = InlineBackend.instance(config=shell.config) |
|
287 | cfg = InlineBackend.instance(config=shell.config) | |
279 | cfg.shell = shell |
|
288 | cfg.shell = shell | |
280 | if cfg not in shell.configurables: |
|
289 | if cfg not in shell.configurables: | |
281 | shell.configurables.append(cfg) |
|
290 | shell.configurables.append(cfg) | |
282 |
|
291 | |||
283 | from IPython.zmq.pylab.backend_inline import flush_figures |
|
292 | if backend == backends['inline']: | |
284 | from matplotlib import pyplot |
|
293 | from IPython.zmq.pylab.backend_inline import flush_figures | |
285 | shell.register_post_execute(flush_figures) |
|
294 | from matplotlib import pyplot | |
286 | # load inline_rc |
|
295 | shell.register_post_execute(flush_figures) | |
287 | pyplot.rcParams.update(cfg.rc) |
|
296 | # load inline_rc | |
288 | # Add 'figsize' to pyplot and to the user's namespace |
|
297 | pyplot.rcParams.update(cfg.rc) | |
289 | user_ns['figsize'] = pyplot.figsize = figsize |
|
298 | # Add 'figsize' to pyplot and to the user's namespace | |
|
299 | user_ns['figsize'] = pyplot.figsize = figsize | |||
290 |
|
300 | |||
291 | # Setup the default figure format |
|
301 | # Setup the default figure format | |
292 | fmt = cfg.figure_format |
|
302 | fmt = cfg.figure_format | |
@@ -323,10 +333,7 b' def pylab_activate(user_ns, gui=None, import_all=True, shell=None):' | |||||
323 | gui, backend = find_gui_and_backend(gui) |
|
333 | gui, backend = find_gui_and_backend(gui) | |
324 | activate_matplotlib(backend) |
|
334 | activate_matplotlib(backend) | |
325 | import_pylab(user_ns, import_all) |
|
335 | import_pylab(user_ns, import_all) | |
326 |
|
336 | configure_inline_support(shell, backend, user_ns) | ||
327 | # The inline backend is only used by GUI shells |
|
|||
328 | if backend == backends['inline']: |
|
|||
329 | configure_inline_backend(shell, backend, user_ns) |
|
|||
330 |
|
337 | |||
331 | print """ |
|
338 | print """ | |
332 | Welcome to pylab, a matplotlib-based Python environment [backend: %s]. |
|
339 | Welcome to pylab, a matplotlib-based Python environment [backend: %s]. |
@@ -238,8 +238,8 b' def make_exclude():' | |||||
238 | exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb')) |
|
238 | exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb')) | |
239 |
|
239 | |||
240 | if not have['matplotlib']: |
|
240 | if not have['matplotlib']: | |
241 |
exclusions.extend([ipjoin(' |
|
241 | exclusions.extend([ipjoin('core', 'pylabtools'), | |
242 |
ipjoin(' |
|
242 | ipjoin('core', 'tests', 'test_pylabtools')]) | |
243 |
|
243 | |||
244 | if not have['tornado']: |
|
244 | if not have['tornado']: | |
245 | exclusions.append(ipjoin('frontend', 'html')) |
|
245 | exclusions.append(ipjoin('frontend', 'html')) |
General Comments 0
You need to be logged in to leave comments.
Login now