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