10000 Merge pull request #22892 from anntzer/unipython · matplotlib/matplotlib@aeb0692 · GitHub
[go: up one dir, main page]

Skip to content

Commit aeb0692

Browse files
authored
Merge pull request #22892 from anntzer/unipython
Remove support for IPython<4.
2 parents 1809c2d + 586ee10 commit aeb0692

File tree

2 files changed

+13
-36
lines changed

2 files changed

+13
-36
lines changed

lib/matplotlib/backends/backend_nbagg.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99
import pathlib
1010
import uuid
1111

12+
from ipykernel.comm import Comm
1213
from IPython.display import display, Javascript, HTML
13-
try:
14-
# Jupyter/IPython 4.x or later
15-
from ipykernel.comm import Comm
16-
except ImportError:
17-
# Jupyter/IPython 3.x or earlier
18-
from IPython.kernel.comm import Comm
1914

2015
from matplotlib import is_interactive
2116
from matplotlib._pylab_helpers import Gcf
@@ -44,18 +39,13 @@ def connection_info():
4439
return '\n'.join(result)
4540

4641

47-
# Note: Version 3.2 and 4.x icons
48-
# https://fontawesome.com/v3.2/icons/
49-
# https://fontawesome.com/v4.7/icons/
50-
# the `fa fa-xxx` part targets font-awesome 4, (IPython 3.x)
51-
# the icon-xxx targets font awesome 3.21 (IPython 2.x)
52-
_FONT_AWESOME_CLASSES = {
53-
'home': 'fa fa-home icon-home',
54-
'back': 'fa fa-arrow-left icon-arrow-left',
55-
'forward': 'fa fa-arrow-right icon-arrow-right',
56-
'zoom_to_rect': 'fa fa-square-o icon-check-empty',
57-
'move': 'fa fa-arrows icon-move',
58-
'download': 'fa fa-floppy-o icon-save',
42+
_FONT_AWESOME_CLASSES = { # font-awesome 4 names
43+
'home': 'fa fa-home',
44+
'back': 'fa fa-arrow-left',
45+
'forward': 'fa fa-arrow-right',
46+
'zoom_to_rect': 'fa fa-square-o',
47+
'move': 'fa fa-arrows',
48+
'download': 'fa fa-floppy-o',
5949
None: None
6050
}
6151

lib/matplotlib/pyplot.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ def post_execute():
140140
if matplotlib.is_interactive():
141141
draw_all()
142142

143-
try: # IPython >= 2
144-
ip.events.register("post_execute", post_execute)
145-
except AttributeError: # IPython 1.x
146-
ip.register_post_execute(post_execute)
143+
ip.events.register("post_execute", post_execute)
147144
_IP_REGISTERED = post_execute
148145
_INSTALL_FIG_OBSERVER = False
149146

@@ -160,26 +157,16 @@ def uninstall_repl_displayhook():
160157
161158
.. warning::
162159
163-
Need IPython >= 2 for this to work. For IPython < 2 will raise a
164-
``NotImplementedError``
165-
166-
.. warning::
167-
168-
If you are using vanilla python and have installed another
169-
display hook, this will reset ``sys.displayhook`` to what ever
170-
function was there when Matplotlib installed its displayhook,
171-
possibly discarding your changes.
160+
If you are using vanilla python and have installed another display hook,
161+
this will reset `sys.displayhook` to what ever function was there when
162+
Matplotlib installed its displayhook, possibly discarding your changes.
172163
"""
173164
global _IP_REGISTERED
174165
global _INSTALL_FIG_OBSERVER
175166
if _IP_REGISTERED:
176167
from IPython import get_ipython
177168
ip = get_ipython()
178-
try:
179-
ip.events.unregister('post_execute', _IP_REGISTERED)
180-
except AttributeError as err:
181-
raise NotImplementedError("Can not unregister events "
182-
"in IPython < 2.0") from err
169+
ip.events.unregister('post_execute', _IP_REGISTERED)
183170
_IP_REGISTERED = None
184171

185172
if _INSTALL_FIG_OBSERVER:

0 commit comments

Comments
 (0)
0