Show More
@@ -2,6 +2,7 b'' | |||
|
2 | 2 | """ IPython extension: add %clear magic """ |
|
3 | 3 | |
|
4 | 4 | import IPython.ipapi |
|
5 | import gc | |
|
5 | 6 | ip = IPython.ipapi.get() |
|
6 | 7 | |
|
7 | 8 | |
@@ -27,6 +28,16 b' def clear_f(self,arg):' | |||
|
27 | 28 | try: |
|
28 | 29 | del self.user_ns[key] |
|
29 | 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 | 42 | ip.expose_magic("clear",clear_f) |
|
32 | 43 |
@@ -2,7 +2,7 b'' | |||
|
2 | 2 | """ |
|
3 | 3 | Classes for handling input/output prompts. |
|
4 | 4 | |
|
5 |
$Id: Prompts.py 126 |
|
|
5 | $Id: Prompts.py 1264 2006-04-11 19:24:29Z vivainio $""" | |
|
6 | 6 | |
|
7 | 7 | #***************************************************************************** |
|
8 | 8 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
@@ -442,7 +442,6 b' class CachedOutput:' | |||
|
442 | 442 | # Store the last prompt string each time, we need it for aligning |
|
443 | 443 | # continuation and auto-rewrite prompts |
|
444 | 444 | self.last_prompt = '' |
|
445 | self.entries = [None] # output counter starts at 1 for the user | |
|
446 | 445 | self.Pprint = Pprint |
|
447 | 446 | self.output_sep = output_sep |
|
448 | 447 | self.output_sep2 = output_sep2 |
@@ -563,9 +562,8 b' class CachedOutput:' | |||
|
563 | 562 | # hackish access to top-level namespace to create _1,_2... dynamically |
|
564 | 563 | to_main = {} |
|
565 | 564 | if self.do_full_cache: |
|
566 | self.entries.append(arg) | |
|
567 | 565 | new_result = '_'+`self.prompt_count` |
|
568 |
to_main[new_result] = |
|
|
566 | to_main[new_result] = arg | |
|
569 | 567 | self.user_ns.update(to_main) |
|
570 | 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