Show More
@@ -354,6 +354,7 b' def configure_inline_support(shell, backend):' | |||
|
354 | 354 | shell._saved_rcParams[k] = pyplot.rcParams[k] |
|
355 | 355 | # load inline_rc |
|
356 | 356 | pyplot.rcParams.update(cfg.rc) |
|
357 | new_backend_name = "inline" | |
|
357 | 358 | else: |
|
358 | 359 | from ipykernel.pylab.backend_inline import flush_figures |
|
359 | 360 | try: |
@@ -363,7 +364,13 b' def configure_inline_support(shell, backend):' | |||
|
363 | 364 | if hasattr(shell, '_saved_rcParams'): |
|
364 | 365 | pyplot.rcParams.update(shell._saved_rcParams) |
|
365 | 366 | del shell._saved_rcParams |
|
367 | new_backend_name = "other" | |
|
366 | 368 | |
|
369 | # only enable the formats once -> don't change the enabled formats (which the user may | |
|
370 | # has changed) when getting another "%matplotlib inline" call. | |
|
371 | # See https://github.com/ipython/ipykernel/issues/29 | |
|
372 | cur_backend = getattr(configure_inline_support, "current_backend", "unset") | |
|
373 | if new_backend_name != cur_backend: | |
|
367 | 374 | # Setup the default figure format |
|
368 | 375 | select_figure_formats(shell, cfg.figure_formats, **cfg.print_figure_kwargs) |
|
369 | ||
|
376 | configure_inline_support.current_backend = new_backend_name |
@@ -229,6 +229,26 b' class TestPylabSwitch(object):' | |||
|
229 | 229 | nt.assert_equal(gui, 'qt') |
|
230 | 230 | nt.assert_equal(s.pylab_gui_select, 'qt') |
|
231 | 231 | |
|
232 | def test_inline_twice(self): | |
|
233 | "Using '%matplotlib inline' twice should not reset formatters" | |
|
234 | ||
|
235 | ip = get_ipython() | |
|
236 | gui, backend = ip.enable_matplotlib('inline') | |
|
237 | nt.assert_equal(gui, 'inline') | |
|
238 | ||
|
239 | fmts = {'png'} | |
|
240 | active_mimes = {_fmt_mime_map[fmt] for fmt in fmts} | |
|
241 | pt.select_figure_formats(ip, fmts) | |
|
242 | ||
|
243 | gui, backend = ip.enable_matplotlib('inline') | |
|
244 | nt.assert_equal(gui, 'inline') | |
|
245 | ||
|
246 | for mime, f in ip.display_formatter.formatters.items(): | |
|
247 | if mime in active_mimes: | |
|
248 | nt.assert_in(Figure, f) | |
|
249 | else: | |
|
250 | nt.assert_not_in(Figure, f) | |
|
251 | ||
|
232 | 252 | def test_qt_gtk(self): |
|
233 | 253 | s = self.Shell() |
|
234 | 254 | gui, backend = s.enable_matplotlib('qt') |
General Comments 0
You need to be logged in to leave comments.
Login now