Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PRF: only try IPython if it is already imported#5038

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
efiring merged 1 commit intomatplotlib:masterfromtacaswell:prf_fix_import_time
Sep 9, 2015
Merged
Changes fromall 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
46 changes: 25 additions & 21 deletionslib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,6 +112,7 @@ def _backend_selection():
_IP_REGISTERED = None
_INSTALL_FIG_OBSERVER = False


def install_repl_displayhook():
"""
Install a repl display hook so that any stale figure are automatically
Expand All@@ -128,27 +129,30 @@ class _NotIPython(Exception):
# see if we have IPython hooks around, if use them

try:
from IPython import get_ipython
ip = get_ipython()
if ip is None:
raise _NotIPython()

if _IP_REGISTERED:
return

def post_execute():
if matplotlib.is_interactive():
draw_all()

# IPython >= 2
try:
ip.events.register('post_execute', post_execute)
except AttributeError:
# IPython 1.x
ip.register_post_execute(post_execute)

_IP_REGISTERED = post_execute
_INSTALL_FIG_OBSERVER = False
if 'IPython' in sys.modules:
from IPython import get_ipython
ip = get_ipython()
if ip is None:
raise _NotIPython()

if _IP_REGISTERED:
return

def post_execute():
if matplotlib.is_interactive():
draw_all()

# IPython >= 2
try:
ip.events.register('post_execute', post_execute)
except AttributeError:
# IPython 1.x
ip.register_post_execute(post_execute)

_IP_REGISTERED = post_execute
_INSTALL_FIG_OBSERVER = False
else:
_INSTALL_FIG_OBSERVER = True

# import failed or ipython is not running
except (ImportError, _NotIPython):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp