##// END OF EJS Templates
add `%pylab --no-import`...
MinRK -
Show More
@@ -14,6 +14,7 b''
14
14
15 # Our own packages
15 # Our own packages
16 from IPython.config.application import Application
16 from IPython.config.application import Application
17 from IPython.core import magic_arguments
17 from IPython.core.magic import Magics, magics_class, line_magic
18 from IPython.core.magic import Magics, magics_class, line_magic
18 from IPython.testing.skipdoctest import skip_doctest
19 from IPython.testing.skipdoctest import skip_doctest
19
20
@@ -27,7 +28,21 b' class PylabMagics(Magics):'
27
28
28 @skip_doctest
29 @skip_doctest
29 @line_magic
30 @line_magic
30 def pylab(self, parameter_s=''):
31 @magic_arguments.magic_arguments()
32 @magic_arguments.argument(
33 '--no-import', action='store_true', default=None,
34 help="""Prevent IPython from populating the namespace"""
35 )
36 @magic_arguments.argument(
37 'gui', nargs='?',
38 help="""Name of the matplotlib backend to use
39 ('qt', 'wx', 'gtk', 'osx', 'tk', 'inline', 'auto').
40 If given, the corresponding matplotlib backend is used,
41 otherwise it will be matplotlib's default
42 (which you can set in your matplotlib config file).
43 """
44 )
45 def pylab(self, line=''):
31 """Load numpy and matplotlib to work interactively.
46 """Load numpy and matplotlib to work interactively.
32
47
33 %pylab [GUINAME]
48 %pylab [GUINAME]
@@ -75,14 +90,20 b' class PylabMagics(Magics):'
75 Backend in use: Qt4Agg
90 Backend in use: Qt4Agg
76 For more information, type 'help(pylab)'.
91 For more information, type 'help(pylab)'.
77 """
92 """
78
93 args = magic_arguments.parse_argstring(self.pylab, line)
79 if Application.initialized():
94 if args.no_import is None:
80 app = Application.instance()
95 # get default from Application
81 try:
96 if Application.initialized():
82 import_all_status = app.pylab_import_all
97 app = Application.instance()
83 except AttributeError:
98 try:
84 import_all_status = True
99 import_all = app.pylab_import_all
100 except AttributeError:
101 import_all = True
102 else:
103 # nothing specified, no app - default True
104 import_all = True
85 else:
105 else:
86 import_all_status = True
106 # invert no-import flag
107 import_all = not args.no_import
87
108
88 self.shell.enable_pylab(parameter_s, import_all=import_all_status, welcome_message=True)
109 self.shell.enable_pylab(args.gui, import_all=import_all, welcome_message=True)
General Comments 0
You need to be logged in to leave comments. Login now