8000 Mnt remove unneeded pylab imports by tacaswell · Pull Request #9998 · ipython/ipython · GitHub
[go: up one dir, main page]

Skip to content

Mnt remove unneeded pylab imports #9998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions IPython/core/pylabtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def mpl_execfile(fname,*where,**kw):
properly handle interactive rendering."""

import matplotlib
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt

#print '*** Matplotlib runner ***' # dbg
# turn off rendering until end of script
Expand All @@ -168,9 +168,17 @@ def mpl_execfile(fname,*where,**kw):
safe_execfile(fname,*where,**kw)
matplotlib.interactive(is_interactive)
# make rendering call now, if the user tried to do it
if pylab.draw_if_interactive.called:
pylab.draw()
pylab.draw_if_interactive.called = False
if plt.draw_if_interactive.called:
plt.draw()
plt.draw_if_interactive.called = False

# re-draw everything that is stale
try:
da = plt.draw_all
except AttributeError:
pass
else:
da()

return mpl_execfile

Expand Down Expand Up @@ -297,12 +305,12 @@ def activate_matplotlib(backend):

# This must be imported last in the matplotlib series, after
# backend/interactivity choices have been made
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt

pylab.show._needmain = False
plt.show._needmain = False
# We need to detect at runtime whether show() is called by the user.
# For this, we wrap it into a decorator which adds a 'called' flag.
pylab.draw_if_interactive = flag_calls(pylab.draw_if_interactive)
plt.draw_if_interactive = flag_calls(plt.draw_if_interactive)


def import_pylab(user_ns, import_all=True):
Expand Down
0