##// END OF EJS Templates
Jorgen's %clean array
vivainio -
Show More
@@ -2,6 +2,7 b''
2 """ IPython extension: add %clear magic """
2 """ IPython extension: add %clear magic """
3
3
4 import IPython.ipapi
4 import IPython.ipapi
5 import gc
5 ip = IPython.ipapi.get()
6 ip = IPython.ipapi.get()
6
7
7
8
@@ -27,6 +28,16 b' def clear_f(self,arg):'
27 try:
28 try:
28 del self.user_ns[key]
29 del self.user_ns[key]
29 except: pass
30 except: pass
31 elif target == 'array':
32 try:
33 pylab=ip.IP.pylab
34 for x in self.user_ns.keys():
35 if isinstance(self.user_ns[x],pylab.arraytype):
36 del self.user_ns[x]
37 except AttributeError:
38 print "Clear array only available in -pylab mode"
39 gc.collect()
40
30
41
31 ip.expose_magic("clear",clear_f)
42 ip.expose_magic("clear",clear_f)
32
43
@@ -2,7 +2,7 b''
2 """
2 """
3 Classes for handling input/output prompts.
3 Classes for handling input/output prompts.
4
4
5 $Id: Prompts.py 1261 2006-04-11 14:37:02Z vivainio $"""
5 $Id: Prompts.py 1264 2006-04-11 19:24:29Z vivainio $"""
6
6
7 #*****************************************************************************
7 #*****************************************************************************
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -442,7 +442,6 b' class CachedOutput:'
442 # Store the last prompt string each time, we need it for aligning
442 # Store the last prompt string each time, we need it for aligning
443 # continuation and auto-rewrite prompts
443 # continuation and auto-rewrite prompts
444 self.last_prompt = ''
444 self.last_prompt = ''
445 self.entries = [None] # output counter starts at 1 for the user
446 self.Pprint = Pprint
445 self.Pprint = Pprint
447 self.output_sep = output_sep
446 self.output_sep = output_sep
448 self.output_sep2 = output_sep2
447 self.output_sep2 = output_sep2
@@ -563,9 +562,8 b' class CachedOutput:'
563 # hackish access to top-level namespace to create _1,_2... dynamically
562 # hackish access to top-level namespace to create _1,_2... dynamically
564 to_main = {}
563 to_main = {}
565 if self.do_full_cache:
564 if self.do_full_cache:
566 self.entries.append(arg)
567 new_result = '_'+`self.prompt_count`
565 new_result = '_'+`self.prompt_count`
568 to_main[new_result] = self.entries[-1]
566 to_main[new_result] = arg
569 self.user_ns.update(to_main)
567 self.user_ns.update(to_main)
570 self.user_ns['_oh'][self.prompt_count] = arg
568 self.user_ns['_oh'][self.prompt_count] = arg
571
569
General Comments 0
You need to be logged in to leave comments. Login now