@@ -108,84 +108,6 @@ def _backend_selection():
108
108
from matplotlib .backends import pylab_setup
109
109
_backend_mod , new_figure_manager , draw_if_interactive , _show = pylab_setup ()
110
110
111
- _IP_REGISTERED = None
112
- _INSTALL_FIG_OBSERVER = False
113
-
114
- def install_repl_displayhook ():
115
- """
116
- Install a repl display hook so that any stale figure are automatically
117
- redrawn when control is returned to the repl.
118
-
119
- This works with both IPython terminals and vanilla python shells.
120
- """
121
- global _IP_REGISTERED
122
- global _INSTALL_FIG_OBSERVER
123
-
124
- class _NotIPython (Exception ):
125
- pass
126
-
127
- # see if we have IPython hooks around, if use them
128
-
129
- try :
130
- from IPython import get_ipython
131
- ip = get_ipython ()
132
- if ip is None :
133
- raise _NotIPython ()
134
-
135
- if _IP_REGISTERED :
136
- return
137
-
138
- def post_execute ():
139
- if matplotlib .is_interactive ():
140
- draw_all ()
141
-
142
- # IPython >= 2
143
- try :
144
- ip .events .register ('post_execute' , post_execute )
145
- except AttributeError :
146
- # IPython 1.x
147
- ip .register_post_execute (post_execute )
148
-
149
- _IP_REGISTERED = post_execute
150
- _INSTALL_FIG_OBSERVER = False
151
-
152
- # import failed or ipython is not running
153
- except (ImportError , _NotIPython ):
154
- _INSTALL_FIG_OBSERVER = True
155
-
156
-
157
- def uninstall_repl_displayhook ():
158
- """
159
- Uninstalls the matplotlib display hook.
160
-
161
- .. warning
162
-
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 it's displayhook,
171
- possibly discarding your changes.
172
- """
173
- global _IP_REGISTERED
174
- global _INSTALL_FIG_OBSERVER
175
- if _IP_REGISTERED :
176
- from IPython import get_ipython
177
- ip = get_ipython ()
178
- try :
179
- ip .events .unregister ('post_execute' , _IP_REGISTERED )
180
- except AttributeError :
181
- raise NotImplementedError ("Can not unregister events "
182
- "in IPython < 2.0" )
183
- _IP_REGISTERED = None
184
-
185
- if _INSTALL_FIG_OBSERVER :
186
- _INSTALL_FIG_OBSERVER = False
187
-
188
-
189
111
draw_all = _pylab_helpers .Gcf .draw_all
190
112
191
113
@@ -245,13 +167,11 @@ def isinteractive():
245
167
def ioff ():
246
168
'Turn interactive mode off.'
247
169
matplotlib .interactive (False )
248
- uninstall_repl_displayhook ()
249
170
250
171
251
172
def ion ():
252
173
'Turn interactive mode on.'
253
174
matplotlib .interactive (True )
254
- install_repl_displayhook ()
255
175
256
176
257
177
def pause (interval ):
@@ -532,9 +452,6 @@ def make_active(event):
532
452
fig = figManager .canvas .figure
533
453
fig .number = num
534
454
535
- if _INSTALL_FIG_OBSERVER :
536
- fig .stale_callback = _auto_draw_if_interactive
537
-
538
455
return fig
539
456
540
457
@@ -2483,13 +2400,6 @@ def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None,
2483
2400
sci (ret )
2484
2401
return ret
2485
2402
2486
- # just to be safe. Interactive mode can be turned on without
2487
- # calling `plt.ion()` so register it again here.
2488
- # This is safe because multiple calls to `install_repl_displayhook`
2489
- # are no-ops and the registered function respect `mpl.is_interactive()`
2490
- # to determine if they should trigger a draw.
2491
- install_repl_displayhook ()
2492
-
2493
2403
################# REMAINING CONTENT GENERATED BY boilerplate.py ##############
2494
2404
2495
2405
0 commit comments