Don't register the same callabck multiple times...
Don't register the same callabck multiple times
Using the %matplotlib magics would not always work without this fix:
For `%matplotlib qt5` to work, `flush_figures` should not be in `get_ipython().events.callbacks['post_execute']`. Yet without this fix:
```python
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 7.18.1 -- An enhanced Interactive Python.
In [1]: %matplotlib inline
In [2]: %matplotlib inline
In [3]: %matplotlib inline
In [4]: %matplotlib inline
In [5]: get_ipython().events.callbacks['post_execute']
Out[5]:
[<bound method AutoreloadMagics.post_execute_hook of <autoreload.AutoreloadMagics object at 0x00000199BFE73888>>,
<function ipykernel.pylab.backend_inline.flush_figures()>,
<function matplotlib.pyplot.install_repl_displayhook.<locals>.post_execute()>,
<function ipykernel.pylab.backend_inline.flush_figures()>,
<function ipykernel.pylab.backend_inline.flush_figures()>,
<function ipykernel.pylab.backend_inline.flush_figures()>,
<function ipykernel.pylab.backend_inline.flush_figures()>]
In [6]: %matplotlib qt5
In [7]: get_ipython().events.callbacks['post_execute']
Out[7]:
[<bound method AutoreloadMagics.post_execute_hook of <autoreload.AutoreloadMagics object at 0x00000199BFE73888>>,
<function matplotlib.pyplot.install_repl_displayhook.<locals>.post_execute()>,
<function ipykernel.pylab.backend_inline.flush_figures()>,
<function ipykernel.pylab.backend_inline.flush_figures()>,
<function ipykernel.pylab.backend_inline.flush_figures()>,
<function ipykernel.pylab.backend_inline.flush_figures()>]
In [8]:
```