##// END OF EJS Templates
Fix inline backend logic and avoid tests if mpl not available.
Fernando Perez -
Show More
@@ -253,7 +253,7 b' def import_pylab(user_ns, import_all=True):'
253 253 exec s in user_ns
254 254
255 255
256 def configure_inline_backend(shell, user_ns=None):
256 def configure_inline_support(shell, backend, user_ns=None):
257 257 """Configure an IPython shell object for matplotlib use.
258 258
259 259 Parameters
@@ -261,6 +261,8 b' def configure_inline_backend(shell, user_ns=None):'
261 261 shell : InteractiveShell instance
262 262 If None, this function returns immediately.
263 263
264 backend : matplotlib backend
265
264 266 user_ns : dict
265 267 A namespace where all configured variables will be placed. If not given,
266 268 the `user_ns` attribute of the shell object is used.
@@ -268,18 +270,26 b' def configure_inline_backend(shell, user_ns=None):'
268 270 if shell is None:
269 271 return
270 272
271 user_ns = shell.user_ns if user_ns is None else user_ns
272
273 273 # If using our svg payload backend, register the post-execution
274 274 # function that will pick up the results for display. This can only be
275 275 # done with access to the real shell object.
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:
276 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
277 286
278 287 cfg = InlineBackend.instance(config=shell.config)
279 288 cfg.shell = shell
280 289 if cfg not in shell.configurables:
281 290 shell.configurables.append(cfg)
282 291
292 if backend == backends['inline']:
283 293 from IPython.zmq.pylab.backend_inline import flush_figures
284 294 from matplotlib import pyplot
285 295 shell.register_post_execute(flush_figures)
@@ -323,10 +333,7 b' def pylab_activate(user_ns, gui=None, import_all=True, shell=None):'
323 333 gui, backend = find_gui_and_backend(gui)
324 334 activate_matplotlib(backend)
325 335 import_pylab(user_ns, import_all)
326
327 # The inline backend is only used by GUI shells
328 if backend == backends['inline']:
329 configure_inline_backend(shell, backend, user_ns)
336 configure_inline_support(shell, backend, user_ns)
330 337
331 338 print """
332 339 Welcome to pylab, a matplotlib-based Python environment [backend: %s].
@@ -238,8 +238,8 b' def make_exclude():'
238 238 exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb'))
239 239
240 240 if not have['matplotlib']:
241 exclusions.extend([ipjoin('lib', 'pylabtools'),
242 ipjoin('lib', 'tests', 'test_pylabtools')])
241 exclusions.extend([ipjoin('core', 'pylabtools'),
242 ipjoin('core', 'tests', 'test_pylabtools')])
243 243
244 244 if not have['tornado']:
245 245 exclusions.append(ipjoin('frontend', 'html'))
General Comments 0
You need to be logged in to leave comments. Login now