##// END OF EJS Templates
%clear magic now fully restored...
Paul Ivanov -
Show More
@@ -205,14 +205,14 b' def test_clear():'
205 nt.assert_true('dead' in [_ip.user_ns[x] for x in '_','__','___'])
205 nt.assert_true('dead' in [_ip.user_ns[x] for x in '_','__','___'])
206 _ip.magic('clear out')
206 _ip.magic('clear out')
207 nt.assert_false('dead' in [_ip.user_ns[x] for x in '_','__','___'])
207 nt.assert_false('dead' in [_ip.user_ns[x] for x in '_','__','___'])
208 nt.assert_true(len(_ip.user_ns['Out']) ==0)
208 nt.assert_true(len(_ip.user_ns['Out']) == 0)
209
209
210 # test '%clear in'
210 # test '%clear in'
211 _ip.run_cell("parrot", store_history=True)
211 _ip.run_cell("parrot", store_history=True)
212 nt.assert_true('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
212 nt.assert_true('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
213 _ip.magic('%clear in')
213 _ip.magic('%clear in')
214 nt.assert_false('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
214 nt.assert_false('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
215 nt.assert_true(len(_ip.user_ns['In'] ==0))
215 nt.assert_true(len(_ip.user_ns['In']) == 0)
216
216
217 # test '%clear dhist'
217 # test '%clear dhist'
218 _ip.run_cell("tmp = [d for d in _dh]") # copy before clearing
218 _ip.run_cell("tmp = [d for d in _dh]") # copy before clearing
@@ -44,14 +44,11 b' def clear_f(self,arg):'
44 print "Flushing input history"
44 print "Flushing input history"
45 pc = self.displayhook.prompt_count + 1
45 pc = self.displayhook.prompt_count + 1
46 for n in range(1, pc):
46 for n in range(1, pc):
47 key = '_i'+`n`
47 key = '_i'+repr(n)
48 user_ns.pop(key,None)
48 user_ns.pop(key,None)
49 try:
49 user_ns.update(dict(_i=u'',_ii=u'',_iii=u''))
50 del user_ns[key]
50 del self.history_manager.input_hist_parsed[:]
51 except: pass
51 del self.history_manager.input_hist_raw[:]
52 # must be done in-place
53 self.history_manager.input_hist_parsed[:] = ['\n'] * pc
54 self.history_manager.input_hist_raw[:] = ['\n'] * pc
55
52
56 elif target == 'array':
53 elif target == 'array':
57 # Support cleaning up numpy arrays
54 # Support cleaning up numpy arrays
@@ -62,7 +59,7 b' def clear_f(self,arg):'
62 for x,val in user_ns.items():
59 for x,val in user_ns.items():
63 if isinstance(val,ndarray):
60 if isinstance(val,ndarray):
64 del user_ns[x]
61 del user_ns[x]
65 except AttributeError:
62 except ImportError:
66 print "Clear array only works if Numpy is available."
63 print "Clear array only works if Numpy is available."
67
64
68 elif target == 'shadow_compress':
65 elif target == 'shadow_compress':
@@ -83,4 +80,4 b' def clear_f(self,arg):'
83 # Activate the extension
80 # Activate the extension
84 ip.define_magic("clear",clear_f)
81 ip.define_magic("clear",clear_f)
85 from IPython.core.completerlib import quick_completer
82 from IPython.core.completerlib import quick_completer
86 quick_completer( '%clear','in out shadow_nuke shadow_compress dhist')
83 quick_completer('%clear','in out array shadow_nuke shadow_compress dhist')
General Comments 0
You need to be logged in to leave comments. Login now