##// END OF EJS Templates
cleanup profile fixup rst
Matthias BUSSONNIER -
Show More
@@ -1,11 +1,10 b''
1 c = get_config()
1 c = get_config()
2
2
3
3
4 c.ConverterTemplate.extract_figures=False
5 c.ConverterTemplate.template_file='basichtml'
4 c.ConverterTemplate.template_file='basichtml'
6 c.ConverterTemplate.tex_environement=False
5 c.ConverterTemplate.tex_environement=False
7
6
8 c.NbconvertApp.fileext='html'
7 c.NbconvertApp.fileext='html'
9
8
10 c.ExtractFigureTransformer.enabled = False
9 c.ExtractFigureTransformer.enabled=False
11 c.CSSHtmlHeaderTransformer.enabled=True
10 c.CSSHtmlHeaderTransformer.enabled=True
@@ -1,5 +1,6 b''
1 c = get_config()
1 c = get_config()
2
2 load_subconfig('base_html.nbcv')
3 load_subconfig('base_html.nbcv')
3
4
4 c.ConverterTemplate.template_file='fullhtml'
5 c.ConverterTemplate.template_file='fullhtml'
5
6
@@ -1,11 +1,15 b''
1 c = get_config()
1 c = get_config()
2
2
3 c.ConverterTemplate.extract_figures=True
4 c.ConverterTemplate.template_file='latex_base'
3 c.ConverterTemplate.template_file='latex_base'
5 c.ConverterTemplate.tex_environement=True
4 c.ConverterTemplate.tex_environement=True
6 c.ConverterTemplate.display_data_priority=['latex', 'svg', 'png', 'jpg', 'jpeg' , 'text']
5
7 c.ExtractFigureTransformer.display_data_priority=['latex', 'svg', 'png', 'jpg', 'jpeg']
6
8 c.NbconvertApp.fileext='tex'
7 c.NbconvertApp.fileext='tex'
9
8
9 c.GlobalConfigurable.display_data_priority =['latex', 'svg', 'png', 'jpg', 'jpeg' , 'text']
10 # do not extract text
11 c.ExtractFigureTransformer.display_data_priority=['latex', 'svg', 'png', 'jpg', 'jpeg']
12
13
10 c.ExtractFigureTransformer.extra_ext_map={'svg':'pdf'}
14 c.ExtractFigureTransformer.extra_ext_map={'svg':'pdf'}
11 c.ExtractFigureTransformer.enabled=True
15 c.ExtractFigureTransformer.enabled=True
@@ -1,7 +1,6 b''
1 c = get_config()
1 c = get_config()
2
2
3 c.ConverterTemplate.extract_figures=False
4 c.ConverterTemplate.template_file='python'
3 c.ConverterTemplate.template_file='python'
5 c.ConverterTemplate.tex_environement=False
4 c.ConverterTemplate.tex_environement=False
6
5
7 c.NbconvertApp.fileext='py'
6 c.NbconvertApp.fileext='py'
@@ -1,13 +1,13 b''
1 c = get_config()
1 c = get_config()
2
2
3 c.ConverterTemplate.extract_figures=True
4 c.ConverterTemplate.template_file='rst'
3 c.ConverterTemplate.template_file='rst'
5 c.ConverterTemplate.tex_environement=False
4 c.ConverterTemplate.tex_environement=False
6
5
7 c.NbconvertApp.fileext='rst'
6 c.NbconvertApp.fileext='rst'
8 c.ExtractFigureTransformer.enabled=True
7 c.ExtractFigureTransformer.enabled=True
9
8
9 c.GlobalConfigurable.display_data_priority =['svg', 'png', 'latex', 'jpg', 'jpeg','text']
10 c.ExtractFigureTransformer.display_data_priority=['svg', 'png', 'latex', 'jpg', 'jpeg','text']
10 c.ExtractFigureTransformer.display_data_priority=['svg', 'png', 'latex', 'jpg', 'jpeg','text']
11 c.ConverterTemplate.display_data_priority= ['svg', 'png', 'latex', 'jpg', 'jpeg','text']
11 c.ConverterTemplate.display_data_priority= ['svg', 'png', 'latex', 'jpg', 'jpeg','text']
12
12
13
13
1 NO CONTENT: file renamed from tests/ipynbref/00_notebook_tour.orig.rst to tests/ipynbref/00_notebook_tour_orig.rst
NO CONTENT: file renamed from tests/ipynbref/00_notebook_tour.orig.rst to tests/ipynbref/00_notebook_tour_orig.rst
@@ -1,633 +1,660 b''
1 A brief tour of the IPython notebook
1 A brief tour of the IPython notebook
2 ====================================
2 ====================================
3
3
4 This document will give you a brief tour of the capabilities of the
4 This document will give you a brief tour of the capabilities of the
5 IPython notebook.
5 IPython notebook.
6 You can view its contents by scrolling around, or execute each cell by
6 You can view its contents by scrolling around, or execute each cell by
7 typing ``Shift-Enter``. After you conclude this brief high-level tour,
7 typing ``Shift-Enter``. After you conclude this brief high-level tour,
8 you should read the accompanying notebook titled
8 you should read the accompanying notebook titled
9 ``01_notebook_introduction``, which takes a more step-by-step approach
9 ``01_notebook_introduction``, which takes a more step-by-step approach
10 to the features of the system.
10 to the features of the system.
11
11
12 The rest of the notebooks in this directory illustrate various other
12 The rest of the notebooks in this directory illustrate various other
13 aspects and capabilities of the IPython notebook; some of them may
13 aspects and capabilities of the IPython notebook; some of them may
14 require additional libraries to be executed.
14 require additional libraries to be executed.
15
15
16 **NOTE:** This notebook *must* be run from its own directory, so you
16 **NOTE:** This notebook *must* be run from its own directory, so you
17 must ``cd`` to this directory and then start the notebook, but do *not*
17 must ``cd`` to this directory and then start the notebook, but do *not*
18 use the ``--notebook-dir`` option to run it from another location.
18 use the ``--notebook-dir`` option to run it from another location.
19
19
20 The first thing you need to know is that you are still controlling the
20 The first thing you need to know is that you are still controlling the
21 same old IPython you're used to, so things like shell aliases and magic
21 same old IPython you're used to, so things like shell aliases and magic
22 commands still work:
22 commands still work:
23
23
24 In[1]:
24 In[1]:
25
25
26 .. code:: python
26 .. code:: python
27
27
28 pwd
28 pwd
29
29
30 Out[1]:
30 Out[1]:
31 .. parsed-literal::
31 .. parsed-literal::
32
32
33 u'/Users/minrk/dev/ip/mine/docs/examples/notebooks'
33 u'/Users/minrk/dev/ip/mine/docs/examples/notebooks'
34
34
35
35
36 In[2]:
36 In[2]:
37
37
38 .. code:: python
38 .. code:: python
39
39
40 ls
40 ls
41
41
42
42
43 .. parsed-literal::
43 .. parsed-literal::
44
44
45 00_notebook_tour.ipynb callbacks.ipynb python-logo.svg
45 00_notebook_tour.ipynb callbacks.ipynb python-logo.svg
46 01_notebook_introduction.ipynb cython_extension.ipynb rmagic_extension.ipynb
46 01_notebook_introduction.ipynb cython_extension.ipynb rmagic_extension.ipynb
47 Animations_and_Progress.ipynb display_protocol.ipynb sympy.ipynb
47 Animations_and_Progress.ipynb display_protocol.ipynb sympy.ipynb
48 Capturing Output.ipynb formatting.ipynb sympy_quantum_computing.ipynb
48 Capturing Output.ipynb formatting.ipynb sympy_quantum_computing.ipynb
49 Script Magics.ipynb octavemagic_extension.ipynb trapezoid_rule.ipynb
49 Script Magics.ipynb octavemagic_extension.ipynb trapezoid_rule.ipynb
50 animation.m4v progbar.ipynb
50 animation.m4v progbar.ipynb
51
51
52 In[3]:
52 In[3]:
53
53
54 .. code:: python
54 .. code:: python
55
55
56 message = 'The IPython notebook is great!'
56 message = 'The IPython notebook is great!'
57 # note: the echo command does not run on Windows, it's a unix command.
57 # note: the echo command does not run on Windows, it's a unix command.
58 !echo $message
58 !echo $message
59
59
60
60
61 .. parsed-literal::
61 .. parsed-literal::
62
62
63 The IPython notebook is great!
63 The IPython notebook is great!
64
64
65 Plots with matplotlib
65 Plots with matplotlib
66 ---------------------
66 ---------------------
67
67
68
69 IPython adds an 'inline' matplotlib backend, which embeds any matplotlib
68 IPython adds an 'inline' matplotlib backend, which embeds any matplotlib
70 figures into the notebook.
69 figures into the notebook.
71
70
72 In[4]:
71 In[4]:
73
72
74 .. code:: python
73 .. code:: python
75
74
76 %pylab inline
75 %pylab inline
77
76
78
77
79 .. parsed-literal::
78 .. parsed-literal::
80
79
81
80
82 Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
81 Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
83 For more information, type 'help(pylab)'.
82 For more information, type 'help(pylab)'.
84
83
85 In[5]:
84 In[5]:
86
85
87 .. code:: python
86 .. code:: python
88
87
89 x = linspace(0, 3*pi, 500)
88 x = linspace(0, 3*pi, 500)
90 plot(x, sin(x**2))
89 plot(x, sin(x**2))
91 title('A simple chirp');
90 title('A simple chirp');
92
91
93 .. image:: _fig_07.png
92 .. image:: _fig_07.png
94
93
95 You can paste blocks of input with prompt markers, such as those from
94 You can paste blocks of input with prompt markers, such as those from
96 `the official Python
95 `the official Python
97 tutorial <http://docs.python.org/tutorial/interpreter.html#interactive-mode>`_
96 tutorial <http://docs.python.org/tutorial/interpreter.html#interactive-mode>`_
98
97
99 In[6]:
98 In[6]:
100
99
101 .. code:: python
100 .. code:: python
102
101
103 >>> the_world_is_flat = 1
102 >>> the_world_is_flat = 1
104 >>> if the_world_is_flat:
103 >>> if the_world_is_flat:
105 ... print "Be careful not to fall off!"
104 ... print "Be careful not to fall off!"
106
105
107
106
108 .. parsed-literal::
107 .. parsed-literal::
109
108
110 Be careful not to fall off!
109 Be careful not to fall off!
111
110
112 Errors are shown in informative ways:
111 Errors are shown in informative ways:
113
112
114 In[7]:
113 In[7]:
115
114
116 .. code:: python
115 .. code:: python
117
116
118 %run non_existent_file
117 %run non_existent_file
119
118
120
119
121 .. parsed-literal::
120 .. parsed-literal::
122
121
123 ERROR: File `u'non_existent_file.py'` not found.
122 ERROR: File `u'non_existent_file.py'` not found.
124 In[8]:
123 In[8]:
125
124
126 .. code:: python
125 .. code:: python
127
126
128 x = 1
127 x = 1
129 y = 4
128 y = 4
130 z = y/(1-x)
129 z = y/(1-x)
131
130
132 ::
131 ::
133
132
134 ---------------------------------------------------------------------------
133 ---------------------------------------------------------------------------
135 ZeroDivisionError Traceback (most recent call last)
134 ZeroDivisionError Traceback (most recent call last)
136 <ipython-input-8-dc39888fd1d2> in <module>()
135 <ipython-input-8-dc39888fd1d2> in <module>()
137 1 x = 1
136 1 x = 1
138 2 y = 4
137 2 y = 4
139 ----> 3 z = y/(1-x)
138 ----> 3 z = y/(1-x)
140
139
141 ZeroDivisionError: integer division or modulo by zero
140 ZeroDivisionError: integer division or modulo by zero
142 When IPython needs to display additional information (such as providing
141 When IPython needs to display additional information (such as providing
143 details on an object via ``x?`` it will automatically invoke a pager at
142 details on an object via ``x?`` it will automatically invoke a pager at
144 the bottom of the screen:
143 the bottom of the screen:
145
144
146 In[18]:
145 In[18]:
147
146
148 .. code:: python
147 .. code:: python
149
148
150 magic
149 magic
151
150
152 Non-blocking output of kernel
151 Non-blocking output of kernel
153 -----------------------------
152 -----------------------------
154
153
155 If you execute the next cell, you will see the output arriving as it is
154 If you execute the next cell, you will see the output arriving as it is
156 generated, not all at the end.
155 generated, not all at the end.
157
156
158 In[19]:
157 In[19]:
159
158
160 .. code:: python
159 .. code:: python
161
160
162 import time, sys
161 import time, sys
163 for i in range(8):
162 for i in range(8):
164 print i,
163 print i,
165 time.sleep(0.5)
164 time.sleep(0.5)
166
165
167
166
168 .. parsed-literal::
167 .. parsed-literal::
169
168
170 0 1 2 3 4 5 6 7
169 0 1 2 3 4 5 6 7
170
171 Clean crash and restart
171 Clean crash and restart
172 -----------------------
172 -----------------------
173
173
174 We call the low-level system libc.time routine with the wrong argument
174 We call the low-level system libc.time routine with the wrong argument
175 via ctypes to segfault the Python interpreter:
175 via ctypes to segfault the Python interpreter:
176
176
177 In[*]:
177 In[*]:
178
178
179 .. code:: python
179 .. code:: python
180
180
181 import sys
181 import sys
182 from ctypes import CDLL
182 from ctypes import CDLL
183 # This will crash a Linux or Mac system; equivalent calls can be made on Windows
183 # This will crash a Linux or Mac system; equivalent calls can be made on Windows
184 dll = 'dylib' if sys.platform == 'darwin' else '.so.6'
184 dll = 'dylib' if sys.platform == 'darwin' else '.so.6'
185 libc = CDLL("libc.%s" % dll)
185 libc = CDLL("libc.%s" % dll)
186 libc.time(-1) # BOOM!!
186 libc.time(-1) # BOOM!!
187
187
188 Markdown cells can contain formatted text and code
188 Markdown cells can contain formatted text and code
189 --------------------------------------------------
189 --------------------------------------------------
190
190
191 You can *italicize*, **boldface**
191 You can *italicize*, **boldface**
192
192
193 - build
193 - build
194 - lists
194 - lists
195
195
196 and embed code meant for illustration instead of execution in Python:
196 and embed code meant for illustration instead of execution in Python:
197
197
198 ::
198 ::
199
199
200 def f(x):
200 def f(x):
201 """a docstring"""
201 """a docstring"""
202 return x**2
202 return x**2
203
203
204 or other languages:
204 or other languages:
205
205
206 ::
206 ::
207
207
208 if (i=0; i<n; i++) {
208 if (i=0; i<n; i++) {
209 printf("hello %d\n", i);
209 printf("hello %d\n", i);
210 x += 4;
210 x += 4;
211 }
211 }
212
212
213
213
214 Courtesy of MathJax, you can include mathematical expressions both
214 Courtesy of MathJax, you can include mathematical expressions both
215 inline: :math:`e^{i\pi} + 1 = 0` and displayed:
215 inline: :math:`e^{i\pi} + 1 = 0` and displayed:
216
216
217 .. math:: e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i
217 .. math:: e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i
218
218
219
219
220
220
221 Rich displays: include anyting a browser can show
221 Rich displays: include anyting a browser can show
222 -------------------------------------------------
222 -------------------------------------------------
223
223
224 Note that we have an actual protocol for this, see the
224 Note that we have an actual protocol for this, see the
225 ``display_protocol`` notebook for further details.
225 ``display_protocol`` notebook for further details.
226
226
227 Images
227 Images
228 ~~~~~~
228 ~~~~~~
229
229
230
230
231 In[1]:
231 In[1]:
232
232
233 .. code:: python
233 .. code:: python
234
234
235 from IPython.display import Image
235 from IPython.display import Image
236 Image(filename='../../source/_static/logo.png')
236 Image(filename='../../source/_static/logo.png')
237
237
238 Out[1]:
238 Out[1]:
239 .. image:: _fig_22.png
239 .. image:: _fig_22.png
240
240
241
241
242 An image can also be displayed from raw data or a url
242 An image can also be displayed from raw data or a url
243
243
244 In[2]:
244 In[2]:
245
245
246 .. code:: python
246 .. code:: python
247
247
248 Image(url='http://python.org/images/python-logo.gif')
248 Image(url='http://python.org/images/python-logo.gif')
249
249
250 Out[2]:
250 Out[2]:
251 .. parsed-literal::
252
253 <IPython.core.display.Image at 0x1060e7410>
254
251
255
252 SVG images are also supported out of the box (since modern browsers do a
256 SVG images are also supported out of the box (since modern browsers do a
253 good job of rendering them):
257 good job of rendering them):
254
258
255 In[3]:
259 In[3]:
256
260
257 .. code:: python
261 .. code:: python
258
262
259 from IPython.display import SVG
263 from IPython.display import SVG
260 SVG(filename='python-logo.svg')
264 SVG(filename='python-logo.svg')
261
265
262 Out[3]:
266 Out[3]:
263 .. image:: _fig_26.svg
267 .. image:: _fig_26.svg
264
268
265
269
266 Embedded vs Non-embedded Images
270 Embedded vs Non-embedded Images
267 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
271 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
268
272
269
273
270 As of IPython 0.13, images are embedded by default for compatibility
274 As of IPython 0.13, images are embedded by default for compatibility
271 with QtConsole, and the ability to still be displayed offline.
275 with QtConsole, and the ability to still be displayed offline.
272
276
273 Let's look at the differences:
277 Let's look at the differences:
274
278
275 In[4]:
279 In[4]:
276
280
277 .. code:: python
281 .. code:: python
278
282
279 # by default Image data are embedded
283 # by default Image data are embedded
280 Embed = Image( 'http://scienceview.berkeley.edu/view/images/newview.jpg')
284 Embed = Image( 'http://scienceview.berkeley.edu/view/images/newview.jpg')
281
285
282 # if kwarg `url` is given, the embedding is assumed to be false
286 # if kwarg `url` is given, the embedding is assumed to be false
283 SoftLinked = Image(url='http://scienceview.berkeley.edu/view/images/newview.jpg')
287 SoftLinked = Image(url='http://scienceview.berkeley.edu/view/images/newview.jpg')
284
288
285 # In each case, embed can be specified explicitly with the `embed` kwarg
289 # In each case, embed can be specified explicitly with the `embed` kwarg
286 # ForceEmbed = Image(url='http://scienceview.berkeley.edu/view/images/newview.jpg', embed=True)
290 # ForceEmbed = Image(url='http://scienceview.berkeley.edu/view/images/newview.jpg', embed=True)
287
291
288 Today's image from a webcam at Berkeley, (at the time I created this
292 Today's image from a webcam at Berkeley, (at the time I created this
289 notebook). This should also work in the Qtconsole. Drawback is that the
293 notebook). This should also work in the Qtconsole. Drawback is that the
290 saved notebook will be larger, but the image will still be present
294 saved notebook will be larger, but the image will still be present
291 offline.
295 offline.
292
296
293 In[5]:
297 In[5]:
294
298
295 .. code:: python
299 .. code:: python
296
300
297 Embed
301 Embed
298
302
299 Out[5]:
303 Out[5]:
300 ..jpg image::
304 ..jpg image::
301
305
302
306
303 Today's image from same webcam at Berkeley, (refreshed every minutes, if
307 Today's image from same webcam at Berkeley, (refreshed every minutes, if
304 you reload the notebook), visible only with an active internet
308 you reload the notebook), visible only with an active internet
305 connexion, that should be different from the previous one. This will not
309 connexion, that should be different from the previous one. This will not
306 work on Qtconsole. Notebook saved with this kind of image will be
310 work on Qtconsole. Notebook saved with this kind of image will be
307 lighter and always reflect the current version of the source, but the
311 lighter and always reflect the current version of the source, but the
308 image won't display offline.
312 image won't display offline.
309
313
310 In[6]:
314 In[6]:
311
315
312 .. code:: python
316 .. code:: python
313
317
314 SoftLinked
318 SoftLinked
315
319
316 Out[6]:
320 Out[6]:
321 .. parsed-literal::
322
323 <IPython.core.display.Image at 0x10fb99b10>
324
317
325
318 Of course, if you re-run the all notebook, the two images will be the
326 Of course, if you re-run the all notebook, the two images will be the
319 same again.
327 same again.
320
328
321 Video
329 Video
322 ~~~~~
330 ~~~~~
323
331
324
332
325 And more exotic objects can also be displayed, as long as their
333 And more exotic objects can also be displayed, as long as their
326 representation supports the IPython display protocol.
334 representation supports the IPython display protocol.
327
335
328 For example, videos hosted externally on YouTube are easy to load (and
336 For example, videos hosted externally on YouTube are easy to load (and
329 writing a similar wrapper for other hosted content is trivial):
337 writing a similar wrapper for other hosted content is trivial):
330
338
331 In[7]:
339 In[7]:
332
340
333 .. code:: python
341 .. code:: python
334
342
335 from IPython.display import YouTubeVideo
343 from IPython.display import YouTubeVideo
336 # a talk about IPython at Sage Days at U. Washington, Seattle.
344 # a talk about IPython at Sage Days at U. Washington, Seattle.
337 # Video credit: William Stein.
345 # Video credit: William Stein.
338 YouTubeVideo('1j_HxD4iLn8')
346 YouTubeVideo('1j_HxD4iLn8')
339
347
340 Out[7]:
348 Out[7]:
349 .. parsed-literal::
350
351 <IPython.lib.display.YouTubeVideo at 0x10fba2190>
352
341
353
342 Using the nascent video capabilities of modern browsers, you may also be
354 Using the nascent video capabilities of modern browsers, you may also be
343 able to display local videos. At the moment this doesn't work very well
355 able to display local videos. At the moment this doesn't work very well
344 in all browsers, so it may or may not work for you; we will continue
356 in all browsers, so it may or may not work for you; we will continue
345 testing this and looking for ways to make it more robust.
357 testing this and looking for ways to make it more robust.
346
358
347 The following cell loads a local file called ``animation.m4v``, encodes
359 The following cell loads a local file called ``animation.m4v``, encodes
348 the raw video as base64 for http transport, and uses the HTML5 video tag
360 the raw video as base64 for http transport, and uses the HTML5 video tag
349 to load it. On Chrome 15 it works correctly, displaying a control bar at
361 to load it. On Chrome 15 it works correctly, displaying a control bar at
350 the bottom with a play/pause button and a location slider.
362 the bottom with a play/pause button and a location slider.
351
363
352 In[8]:
364 In[8]:
353
365
354 .. code:: python
366 .. code:: python
355
367
356 from IPython.display import HTML
368 from IPython.display import HTML
357 video = open("animation.m4v", "rb").read()
369 video = open("animation.m4v", "rb").read()
358 video_encoded = video.encode("base64")
370 video_encoded = video.encode("base64")
359 video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
371 video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
360 HTML(data=video_tag)
372 HTML(data=video_tag)
361
373
362 Out[8]:
374 Out[8]:
375 .. parsed-literal::
376
377 <IPython.core.display.HTML at 0x10fba28d0>
378
363
379
364 Local Files
380 Local Files
365 -----------
381 -----------
366
382
367 The above examples embed images and video from the notebook filesystem
383 The above examples embed images and video from the notebook filesystem
368 in the output areas of code cells. It is also possible to request these
384 in the output areas of code cells. It is also possible to request these
369 files directly in markdown cells if they reside in the notebook
385 files directly in markdown cells if they reside in the notebook
370 directory via relative urls prefixed with ``files/``:
386 directory via relative urls prefixed with ``files/``:
371
387
372 ::
388 ::
373
389
374 files/[subdirectory/]<filename>
390 files/[subdirectory/]<filename>
375
391
376 For example, in the example notebook folder, we have the Python logo,
392 For example, in the example notebook folder, we have the Python logo,
377 addressed as:
393 addressed as:
378
394
379 ::
395 ::
380
396
381 <img src="files/python-logo.svg" />
397 <img src="files/python-logo.svg" />
382
398
383 and a video with the HTML5 video tag:
399 and a video with the HTML5 video tag:
384
400
385 ::
401 ::
386
402
387 <video controls src="files/animation.m4v" />
403 <video controls src="files/animation.m4v" />
388
404
389 These do not embed the data into the notebook file, and require that the
405 These do not embed the data into the notebook file, and require that the
390 files exist when you are viewing the notebook.
406 files exist when you are viewing the notebook.
391
407
392 Security of local files
408 Security of local files
393 ~~~~~~~~~~~~~~~~~~~~~~~
409 ~~~~~~~~~~~~~~~~~~~~~~~
394
410
395 Note that this means that the IPython notebook server also acts as a
411 Note that this means that the IPython notebook server also acts as a
396 generic file server for files inside the same tree as your notebooks.
412 generic file server for files inside the same tree as your notebooks.
397 Access is not granted outside the notebook folder so you have strict
413 Access is not granted outside the notebook folder so you have strict
398 control over what files are visible, but for this reason it is highly
414 control over what files are visible, but for this reason it is highly
399 recommended that you do not run the notebook server with a notebook
415 recommended that you do not run the notebook server with a notebook
400 directory at a high level in your filesystem (e.g. your home directory).
416 directory at a high level in your filesystem (e.g. your home directory).
401
417
402 When you run the notebook in a password-protected manner, local file
418 When you run the notebook in a password-protected manner, local file
403 access is restricted to authenticated users unless read-only views are
419 access is restricted to authenticated users unless read-only views are
404 active.
420 active.
405
421
406 Linking to files and directories for viewing in the browser
422 Linking to files and directories for viewing in the browser
407 -----------------------------------------------------------
423 -----------------------------------------------------------
408
424
409 It is also possible to link directly to files or directories so they can
425 It is also possible to link directly to files or directories so they can
410 be opened in the browser. This is especially convenient if you're
426 be opened in the browser. This is especially convenient if you're
411 interacting with a tool within IPython that generates HTML pages, and
427 interacting with a tool within IPython that generates HTML pages, and
412 you'd like to easily be able to open those in a new browser window.
428 you'd like to easily be able to open those in a new browser window.
413 Alternatively, if your IPython notebook server is on a remote system,
429 Alternatively, if your IPython notebook server is on a remote system,
414 creating links provides an easy way to download any files that get
430 creating links provides an easy way to download any files that get
415 generated.
431 generated.
416
432
417 As we saw above, there are a bunch of ``.ipynb`` files in our current
433 As we saw above, there are a bunch of ``.ipynb`` files in our current
418 directory.
434 directory.
419
435
420 In[1]:
436 In[1]:
421
437
422 .. code:: python
438 .. code:: python
423
439
424 ls
440 ls
425
441
426
442
427 .. parsed-literal::
443 .. parsed-literal::
428
444
429 00_notebook_tour.ipynb formatting.ipynb
445 00_notebook_tour.ipynb formatting.ipynb
430 01_notebook_introduction.ipynb octavemagic_extension.ipynb
446 01_notebook_introduction.ipynb octavemagic_extension.ipynb
431 Animations_and_Progress.ipynb publish_data.ipynb
447 Animations_and_Progress.ipynb publish_data.ipynb
432 Capturing Output.ipynb python-logo.svg
448 Capturing Output.ipynb python-logo.svg
433 Script Magics.ipynb rmagic_extension.ipynb
449 Script Magics.ipynb rmagic_extension.ipynb
434 animation.m4v sympy.ipynb
450 animation.m4v sympy.ipynb
435 cython_extension.ipynb sympy_quantum_computing.ipynb
451 cython_extension.ipynb sympy_quantum_computing.ipynb
436 display_protocol.ipynb trapezoid_rule.ipynb
452 display_protocol.ipynb trapezoid_rule.ipynb
437
453
438 If we want to create a link to one of them, we can call use the
454 If we want to create a link to one of them, we can call use the
439 ``FileLink`` object.
455 ``FileLink`` object.
440
456
441 In[2]:
457 In[2]:
442
458
443 .. code:: python
459 .. code:: python
444
460
445 from IPython.display import FileLink
461 from IPython.display import FileLink
446 FileLink('00_notebook_tour.ipynb')
462 FileLink('00_notebook_tour.ipynb')
447
463
448 Out[2]:
464 Out[2]:
465 .. parsed-literal::
466
467 <IPython.lib.display.FileLink at 0x10f7ea3d0>
468
449
469
450 Alternatively, if we want to link to all of them, we can use the
470 Alternatively, if we want to link to all of them, we can use the
451 ``FileLinks`` object, passing ``'.'`` to indicate that we want links
471 ``FileLinks`` object, passing ``'.'`` to indicate that we want links
452 generated for the current working directory. Note that if there were
472 generated for the current working directory. Note that if there were
453 other directories under the current directory, ``FileLinks`` would work
473 other directories under the current directory, ``FileLinks`` would work
454 in a recursive manner creating links to files in all sub-directories as
474 in a recursive manner creating links to files in all sub-directories as
455 well.
475 well.
456
476
457 In[7]:
477 In[7]:
458
478
459 .. code:: python
479 .. code:: python
460
480
461 from IPython.display import FileLinks
481 from IPython.display import FileLinks
462 FileLinks('.')
482 FileLinks('.')
463
483
464 Out[7]:
484 Out[7]:
485 .. parsed-literal::
486
487 <IPython.lib.display.FileLinks at 0x10f7eaad0>
488
465
489
466 External sites
490 External sites
467 ~~~~~~~~~~~~~~
491 ~~~~~~~~~~~~~~
468
492
469 You can even embed an entire page from another site in an iframe; for
493 You can even embed an entire page from another site in an iframe; for
470 example this is today's Wikipedia page for mobile users:
494 example this is today's Wikipedia page for mobile users:
471
495
472 In[9]:
496 In[9]:
473
497
474 .. code:: python
498 .. code:: python
475
499
476 HTML('<iframe src=http://en.mobile.wikipedia.org/?useformat=mobile width=700 height=350></iframe>')
500 HTML('<iframe src=http://en.mobile.wikipedia.org/?useformat=mobile width=700 height=350></iframe>')
477
501
478 Out[9]:
502 Out[9]:
503 .. parsed-literal::
504
505 <IPython.core.display.HTML at 0x1094900d0>
506
479
507
480 Mathematics
508 Mathematics
481 ~~~~~~~~~~~
509 ~~~~~~~~~~~
482
510
483 And we also support the display of mathematical expressions typeset in
511 And we also support the display of mathematical expressions typeset in
484 LaTeX, which is rendered in the browser thanks to the `MathJax
512 LaTeX, which is rendered in the browser thanks to the `MathJax
485 library <http://mathjax.org>`_.
513 library <http://mathjax.org>`_.
486
514
487 Note that this is *different* from the above examples. Above we were
515 Note that this is *different* from the above examples. Above we were
488 typing mathematical expressions in Markdown cells (along with normal
516 typing mathematical expressions in Markdown cells (along with normal
489 text) and letting the browser render them; now we are displaying the
517 text) and letting the browser render them; now we are displaying the
490 output of a Python computation as a LaTeX expression wrapped by the
518 output of a Python computation as a LaTeX expression wrapped by the
491 ``Math()`` object so the browser renders it. The ``Math`` object will
519 ``Math()`` object so the browser renders it. The ``Math`` object will
492 add the needed LaTeX delimiters (``$$``) if they are not provided:
520 add the needed LaTeX delimiters (``$$``) if they are not provided:
493
521
494 In[10]:
522 In[10]:
495
523
496 .. code:: python
524 .. code:: python
497
525
498 from IPython.display import Math
526 from IPython.display import Math
499 Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')
527 Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')
500
528
501 Out[10]:
529 Out[10]:
502 .. math::
530 .. math::
503
531
504 $$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$$
532 $$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$$
505
533
506
534
507 With the ``Latex`` class, you have to include the delimiters yourself.
535 With the ``Latex`` class, you have to include the delimiters yourself.
508 This allows you to use other LaTeX modes such as ``eqnarray``:
536 This allows you to use other LaTeX modes such as ``eqnarray``:
509
537
510 In[11]:
538 In[11]:
511
539
512 .. code:: python
540 .. code:: python
513
541
514 from IPython.display import Latex
542 from IPython.display import Latex
515 Latex(r"""\begin{eqnarray}
543 Latex(r"""\begin{eqnarray}
516 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
544 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
517 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
545 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
518 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
546 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
519 \nabla \cdot \vec{\mathbf{B}} & = 0
547 \nabla \cdot \vec{\mathbf{B}} & = 0
520 \end{eqnarray}""")
548 \end{eqnarray}""")
521
549
522 Out[11]:
550 Out[11]:
523 .. math::
551 .. math::
524
552
525 \begin{eqnarray}
553 \begin{eqnarray}
526 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
554 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
527 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
555 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
528 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
556 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
529 \nabla \cdot \vec{\mathbf{B}} & = 0
557 \nabla \cdot \vec{\mathbf{B}} & = 0
530 \end{eqnarray}
558 \end{eqnarray}
531
559
532
560
533 Or you can enter latex directly with the ``%%latex`` cell magic:
561 Or you can enter latex directly with the ``%%latex`` cell magic:
534
562
535 In[12]:
563 In[12]:
536
564
537 .. code:: python
565 .. code:: python
538
566
539 %%latex
567 %%latex
540 \begin{aligned}
568 \begin{aligned}
541 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
569 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
542 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
570 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
543 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
571 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
544 \nabla \cdot \vec{\mathbf{B}} & = 0
572 \nabla \cdot \vec{\mathbf{B}} & = 0
545 \end{aligned}
573 \end{aligned}
546
574
547 .. math::
575 .. math::
548
576
549 \begin{aligned}
577 \begin{aligned}
550 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
578 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
551 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
579 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
552 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
580 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
553 \nabla \cdot \vec{\mathbf{B}} & = 0
581 \nabla \cdot \vec{\mathbf{B}} & = 0
554 \end{aligned}
582 \end{aligned}
555
583
556 There is also a ``%%javascript`` cell magic for running javascript
584 There is also a ``%%javascript`` cell magic for running javascript
557 directly, and ``%%svg`` for manually entering SVG content.
585 directly, and ``%%svg`` for manually entering SVG content.
558
586
559 Loading external codes
587 Loading external codes
560 ======================
588 ======================
561
589
562 - Drag and drop a ``.py`` in the dashboard
590 - Drag and drop a ``.py`` in the dashboard
563 - Use ``%load`` with any local or remote url: `the Matplotlib
591 - Use ``%load`` with any local or remote url: `the Matplotlib
564 Gallery! <http://matplotlib.sourceforge.net/gallery.html>`_
592 Gallery! <http://matplotlib.sourceforge.net/gallery.html>`_
565
593
566 In this notebook we've kept the output saved so you can see the result,
594 In this notebook we've kept the output saved so you can see the result,
567 but you should run the next cell yourself (with an active internet
595 but you should run the next cell yourself (with an active internet
568 connection).
596 connection).
569
597
570 Let's make sure we have pylab again, in case we have restarted the
598 Let's make sure we have pylab again, in case we have restarted the
571 kernel due to the crash demo above
599 kernel due to the crash demo above
572
600
573 In[12]:
601 In[12]:
574
602
575 .. code:: python
603 .. code:: python
576
604
577 %pylab inline
605 %pylab inline
578
606
579
607
580 .. parsed-literal::
608 .. parsed-literal::
581
609
582
610
583 Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
611 Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
584 For more information, type 'help(pylab)'.
612 For more information, type 'help(pylab)'.
585
613
586 In[15]:
614 In[15]:
587
615
588 .. code:: python
616 .. code:: python
589
617
590 %load http://matplotlib.sourceforge.net/mpl_examples/pylab_examples/integral_demo.py
618 %load http://matplotlib.sourceforge.net/mpl_examples/pylab_examples/integral_demo.py
591
619
592 In[16]:
620 In[16]:
593
621
594 .. code:: python
622 .. code:: python
595
623
596 #!/usr/bin/env python
624 #!/usr/bin/env python
597
625
598 # implement the example graphs/integral from pyx
626 # implement the example graphs/integral from pyx
599 from pylab import *
627 from pylab import *
600 from matplotlib.patches import Polygon
628 from matplotlib.patches import Polygon
601
629
602 def func(x):
630 def func(x):
603 return (x-3)*(x-5)*(x-7)+85
631 return (x-3)*(x-5)*(x-7)+85
604
632
605 ax = subplot(111)
633 ax = subplot(111)
606
634
607 a, b = 2, 9 # integral area
635 a, b = 2, 9 # integral area
608 x = arange(0, 10, 0.01)
636 x = arange(0, 10, 0.01)
609 y = func(x)
637 y = func(x)
610 plot(x, y, linewidth=1)
638 plot(x, y, linewidth=1)
611
639
612 # make the shaded region
640 # make the shaded region
613 ix = arange(a, b, 0.01)
641 ix = arange(a, b, 0.01)
614 iy = func(ix)
642 iy = func(ix)
615 verts = [(a,0)] + zip(ix,iy) + [(b,0)]
643 verts = [(a,0)] + zip(ix,iy) + [(b,0)]
616 poly = Polygon(verts, facecolor='0.8', edgecolor='k')
644 poly = Polygon(verts, facecolor='0.8', edgecolor='k')
617 ax.add_patch(poly)
645 ax.add_patch(poly)
618
646
619 text(0.5 * (a + b), 30,
647 text(0.5 * (a + b), 30,
620 r"$\int_a^b f(x)\mathrm{d}x$", horizontalalignment='center',
648 r"$\int_a^b f(x)\mathrm{d}x$", horizontalalignment='center',
621 fontsize=20)
649 fontsize=20)
622
650
623 axis([0,10, 0, 180])
651 axis([0,10, 0, 180])
624 figtext(0.9, 0.05, 'x')
652 figtext(0.9, 0.05, 'x')
625 figtext(0.1, 0.9, 'y')
653 figtext(0.1, 0.9, 'y')
626 ax.set_xticks((a,b))
654 ax.set_xticks((a,b))
627 ax.set_xticklabels(('a','b'))
655 ax.set_xticklabels(('a','b'))
628 ax.set_yticks([])
656 ax.set_yticks([])
629 show()
657 show()
630
658
631
659
632 .. image:: _fig_60.png
660 .. image:: _fig_60.png
633
General Comments 0
You need to be logged in to leave comments. Login now