Show More
@@ -4,7 +4,7 b'' | |||
|
4 | 4 | All the matplotlib support code was co-developed with John Hunter, |
|
5 | 5 | matplotlib's author. |
|
6 | 6 | |
|
7 |
$Id: Shell.py 215 |
|
|
7 | $Id: Shell.py 2156 2007-03-19 02:32:19Z fperez $""" | |
|
8 | 8 | |
|
9 | 9 | #***************************************************************************** |
|
10 | 10 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
@@ -446,8 +446,7 b' class MatplotlibShellBase:' | |||
|
446 | 446 | user_ns = IPython.ipapi.make_user_ns(user_ns) |
|
447 | 447 | |
|
448 | 448 | exec ("import matplotlib\n" |
|
449 | "import matplotlib.pylab as pylab\n" | |
|
450 | "from matplotlib.pylab import *") in user_ns | |
|
449 | "import matplotlib.pylab as pylab\n") in user_ns | |
|
451 | 450 | |
|
452 | 451 | # Build matplotlib info banner |
|
453 | 452 | b=""" |
@@ -931,6 +930,17 b' class IPShellQt4(threading.Thread):' | |||
|
931 | 930 | |
|
932 | 931 | # A set of matplotlib public IPython shell classes, for single-threaded |
|
933 | 932 | # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. |
|
933 | def _load_pylab(user_ns): | |
|
934 | """Allow users to disable pulling all of pylab into the top-level | |
|
935 | namespace. | |
|
936 | ||
|
937 | This little utility must be called AFTER the actual ipython instance is | |
|
938 | running, since only then will the options file have been fully parsed.""" | |
|
939 | ||
|
940 | ip = IPython.ipapi.get() | |
|
941 | if ip.options.pylab_import_all: | |
|
942 | exec "from matplotlib.pylab import *" in user_ns | |
|
943 | ||
|
934 | 944 | class IPShellMatplotlib(IPShell): |
|
935 | 945 | """Subclass IPShell with MatplotlibShell as the internal shell. |
|
936 | 946 | |
@@ -941,6 +951,7 b' class IPShellMatplotlib(IPShell):' | |||
|
941 | 951 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
942 | 952 | IPShell.__init__(self,argv,user_ns,user_global_ns,debug, |
|
943 | 953 | shell_class=MatplotlibShell) |
|
954 | _load_pylab(user_ns) | |
|
944 | 955 | |
|
945 | 956 | class IPShellMatplotlibGTK(IPShellGTK): |
|
946 | 957 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. |
@@ -950,6 +961,7 b' class IPShellMatplotlibGTK(IPShellGTK):' | |||
|
950 | 961 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
951 | 962 | IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug, |
|
952 | 963 | shell_class=MatplotlibMTShell) |
|
964 | _load_pylab(user_ns) | |
|
953 | 965 | |
|
954 | 966 | class IPShellMatplotlibWX(IPShellWX): |
|
955 | 967 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. |
@@ -959,6 +971,7 b' class IPShellMatplotlibWX(IPShellWX):' | |||
|
959 | 971 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
960 | 972 | IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug, |
|
961 | 973 | shell_class=MatplotlibMTShell) |
|
974 | _load_pylab(user_ns) | |
|
962 | 975 | |
|
963 | 976 | class IPShellMatplotlibQt(IPShellQt): |
|
964 | 977 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. |
@@ -968,6 +981,7 b' class IPShellMatplotlibQt(IPShellQt):' | |||
|
968 | 981 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
969 | 982 | IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, |
|
970 | 983 | shell_class=MatplotlibMTShell) |
|
984 | _load_pylab(user_ns) | |
|
971 | 985 | |
|
972 | 986 | class IPShellMatplotlibQt4(IPShellQt4): |
|
973 | 987 | """Subclass IPShellQt4 with MatplotlibMTShell as the internal shell. |
@@ -977,6 +991,7 b' class IPShellMatplotlibQt4(IPShellQt4):' | |||
|
977 | 991 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
978 | 992 | IPShellQt4.__init__(self,argv,user_ns,user_global_ns,debug, |
|
979 | 993 | shell_class=MatplotlibMTShell) |
|
994 | _load_pylab(user_ns) | |
|
980 | 995 | |
|
981 | 996 | #----------------------------------------------------------------------------- |
|
982 | 997 | # Factory functions to actually start the proper thread-aware shell |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | # -*- Mode: Shell-Script -*- Not really, but shows comments correctly |
|
2 | # $Id: ipythonrc 1979 2006-12-12 18:50:20Z vivainio $ | |
|
2 | # $Id: ipythonrc 2156 2007-03-19 02:32:19Z fperez $ | |
|
3 | 3 | |
|
4 | 4 | #*************************************************************************** |
|
5 | 5 | # |
@@ -258,6 +258,15 b" prompt_out 'Out[\\#]: '" | |||
|
258 | 258 | # the output prompts will be unpadded (flush left). |
|
259 | 259 | prompts_pad_left 1 |
|
260 | 260 | |
|
261 | # Pylab support: when ipython is started with the -pylab switch, by default it | |
|
262 | # executes 'from matplotlib.pylab import *'. Set this variable to false if you | |
|
263 | # want to disable this behavior. | |
|
264 | ||
|
265 | # For details on pylab, see the matplotlib website: | |
|
266 | # http://matplotlib.sf.net | |
|
267 | pylab_import_all 1 | |
|
268 | ||
|
269 | ||
|
261 | 270 | # quick 1 -> same as ipython -quick |
|
262 | 271 | quick 0 |
|
263 | 272 |
@@ -6,7 +6,7 b' Requires Python 2.1 or better.' | |||
|
6 | 6 | |
|
7 | 7 | This file contains the main make_IPython() starter function. |
|
8 | 8 | |
|
9 |
$Id: ipmaker.py 2 |
|
|
9 | $Id: ipmaker.py 2156 2007-03-19 02:32:19Z fperez $""" | |
|
10 | 10 | |
|
11 | 11 | #***************************************************************************** |
|
12 | 12 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> |
@@ -159,6 +159,7 b" object? -> Details about 'object'. ?object also works, ?? prints more." | |||
|
159 | 159 | 'debug! deep_reload! editor=s log|l messages! nosep ' |
|
160 | 160 | 'object_info_string_level=i pdb! ' |
|
161 | 161 | 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s ' |
|
162 | 'pylab_import_all! ' | |
|
162 | 163 | 'quick screen_length|sl=i prompts_pad_left=i ' |
|
163 | 164 | 'logfile|lf=s logplay|lp=s profile|p=s ' |
|
164 | 165 | 'readline! readline_merge_completions! ' |
@@ -213,6 +214,7 b" object? -> Details about 'object'. ?object also works, ?? prints more." | |||
|
213 | 214 | prompt_in2 = ' .\\D.: ', |
|
214 | 215 | prompt_out = 'Out[\\#]: ', |
|
215 | 216 | prompts_pad_left = 1, |
|
217 | pylab_import_all = 1, | |
|
216 | 218 | quiet = 0, |
|
217 | 219 | quick = 0, |
|
218 | 220 | readline = 1, |
@@ -60,7 +60,7 b' You can implement other color schemes easily, the syntax is fairly' | |||
|
60 | 60 | self-explanatory. Please send back new schemes you develop to the author for |
|
61 | 61 | possible inclusion in future releases. |
|
62 | 62 | |
|
63 |
$Id: ultraTB.py 215 |
|
|
63 | $Id: ultraTB.py 2156 2007-03-19 02:32:19Z fperez $""" | |
|
64 | 64 | |
|
65 | 65 | #***************************************************************************** |
|
66 | 66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> |
@@ -103,7 +103,7 b' INDENT_SIZE = 8' | |||
|
103 | 103 | # formatter. When running in an actual IPython instance, the user's rc.colors |
|
104 | 104 | # value is used, but havinga module global makes this functionality available |
|
105 | 105 | # to users of ultraTB who are NOT running inside ipython. |
|
106 |
DEFAULT_SCHEME = 'NoColor |
|
|
106 | DEFAULT_SCHEME = 'NoColor' | |
|
107 | 107 | |
|
108 | 108 | #--------------------------------------------------------------------------- |
|
109 | 109 | # Code begins |
@@ -160,16 +160,17 b' def _fixed_getinnerframes(etb, context=1,tb_offset=0):' | |||
|
160 | 160 | |
|
161 | 161 | _parser = PyColorize.Parser() |
|
162 | 162 | |
|
163 | def _formatTracebackLines(lnum, index, lines, Colors, lvals=None): | |
|
163 | def _formatTracebackLines(lnum, index, lines, Colors, lvals=None,scheme=None): | |
|
164 | 164 | numbers_width = INDENT_SIZE - 1 |
|
165 | 165 | res = [] |
|
166 | 166 | i = lnum - index |
|
167 | 167 | |
|
168 | 168 | # This lets us get fully syntax-highlighted tracebacks. |
|
169 | try: | |
|
170 | scheme = __IPYTHON__.rc.colors | |
|
171 | except: | |
|
172 | scheme = DEFAULT_SCHEME | |
|
169 | if scheme is None: | |
|
170 | try: | |
|
171 | scheme = __IPYTHON__.rc.colors | |
|
172 | except: | |
|
173 | scheme = DEFAULT_SCHEME | |
|
173 | 174 | _line_format = _parser.format2 |
|
174 | 175 | |
|
175 | 176 | for line in lines: |
@@ -420,6 +421,7 b' class VerboseTB(TBTools):' | |||
|
420 | 421 | # some locals |
|
421 | 422 | Colors = self.Colors # just a shorthand + quicker name lookup |
|
422 | 423 | ColorsNormal = Colors.Normal # used a lot |
|
424 | col_scheme = self.color_scheme_table.active_scheme_name | |
|
423 | 425 | indent = ' '*INDENT_SIZE |
|
424 | 426 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) |
|
425 | 427 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) |
@@ -658,7 +660,8 b' class VerboseTB(TBTools):' | |||
|
658 | 660 | frames.append(level) |
|
659 | 661 | else: |
|
660 | 662 | frames.append('%s%s' % (level,''.join( |
|
661 |
_formatTracebackLines(lnum,index,lines, |
|
|
663 | _formatTracebackLines(lnum,index,lines,Colors,lvals, | |
|
664 | col_scheme)))) | |
|
662 | 665 | |
|
663 | 666 | # Get (safely) a string form of the exception info |
|
664 | 667 | try: |
@@ -1,5 +1,10 b'' | |||
|
1 | 1 | 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2 | 2 | |
|
3 | * IPython/Shell.py (_load_pylab): Make the execution of 'from | |
|
4 | pylab import *' when -pylab is given be optional. A new flag, | |
|
5 | pylab_import_all controls this behavior, the default is True for | |
|
6 | backwards compatibility. | |
|
7 | ||
|
3 | 8 | * IPython/ultraTB.py (_formatTracebackLines): Added (slightly |
|
4 | 9 | modified) R. Bernstein's patch for fully syntax highlighted |
|
5 | 10 | tracebacks. The functionality is also available under ultraTB for |
General Comments 0
You need to be logged in to leave comments.
Login now