Skip to content

Commit 890a5e8

Browse files
committed
Done conversion, now checking.
1 parent 2f956fa commit 890a5e8

File tree

101 files changed

+28975
-23925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+28975
-23925
lines changed

notebooks/chapter01_basic/04_magic.ipynb

Lines changed: 246 additions & 226 deletions
Large diffs are not rendered by default.

notebooks/chapter01_basic/05_config.ipynb

Lines changed: 267 additions & 252 deletions
Large diffs are not rendered by default.

notebooks/chapter01_basic/06_kernel.ipynb

Lines changed: 388 additions & 377 deletions
Large diffs are not rendered by default.

notebooks/chapter02_best_practices/07_unittests.ipynb

Lines changed: 253 additions & 236 deletions
Large diffs are not rendered by default.

notebooks/chapter02_best_practices/07_unittests_py2.ipynb

Lines changed: 253 additions & 236 deletions
Large diffs are not rendered by default.

notebooks/chapter03_notebook/01_blocks.ipynb

Lines changed: 245 additions & 228 deletions
Large diffs are not rendered by default.

notebooks/chapter03_notebook/02_nbformat.ipynb

Lines changed: 316 additions & 294 deletions
Large diffs are not rendered by default.
Lines changed: 163 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,165 @@
11
{
2-
"metadata": {
3-
"signature": "sha256:3ac8512f1eab399da758b33b61abb8225f8d6b129cf9456e316cb5e44f2bbb2c",
4-
"name": ""
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"> This is one of the 100 recipes of the [IPython Cookbook](http://ipython-books.github.io/), the definitive guide to high-performance scientific computing and data science in Python.\n"
8+
]
59
},
6-
"nbformat": 3,
7-
"nbformat_minor": 0,
8-
"worksheets": [
9-
{
10-
"metadata": {},
11-
"cells": [
12-
{
13-
"cell_type": "markdown",
14-
"source": [
15-
"> This is one of the 100 recipes of the [IPython Cookbook](http://ipython-books.github.io/), the definitive guide to high-performance scientific computing and data science in Python.\n"
16-
],
17-
"metadata": {}
18-
},
19-
{
20-
"cell_type": "markdown",
21-
"source": [
22-
"# 3.3. Adding custom controls in the notebook toolbar"
23-
],
24-
"metadata": {}
25-
},
26-
{
27-
"cell_type": "markdown",
28-
"source": [
29-
"The CSS and Javascript of the HTML notebook can be customized through the files in `~/.ipython/profile_default/static/custom`, where `~` is your `HOME` directory, and `default` is your IPython profile. In this short recipe, we will use this feature to add a new button in the notebook toolbar on top of every notebook. Specifically, this button renumbers linearly all code cells."
30-
],
31-
"metadata": {}
32-
},
33-
{
34-
"cell_type": "markdown",
35-
"source": [
36-
"1. First, we are going to inject Javascript code directly in the notebook. This is useful for testing purposes, or if you don't want your changes to be permanent. The Javascript code will be loaded with that notebook only. To do this, we can just use the `%%javascript` cell magic."
37-
],
38-
"metadata": {}
39-
},
40-
{
41-
"collapsed": false,
42-
"metadata": {},
43-
"cell_type": "code",
44-
"outputs": [],
45-
"input": [
46-
"%%javascript\n",
47-
"// This function allows us to add buttons \n",
48-
"// to the notebook toolbar.\n",
49-
"IPython.toolbar.add_buttons_group([\n",
50-
"{\n",
51-
" // The button's label.\n",
52-
" 'label': 'renumber all code cells',\n",
53-
" \n",
54-
" // The button's icon.\n",
55-
" // See a list of Font-Awesome icons here:\n",
56-
" // http://fortawesome.github.io/Font-Awesome/icons/\n",
57-
" 'icon': 'icon-list-ol',\n",
58-
" \n",
59-
" // The callback function.\n",
60-
" 'callback': function () {\n",
61-
" \n",
62-
" // We retrieve the lists of all cells.\n",
63-
" var cells = IPython.notebook.get_cells();\n",
64-
" \n",
65-
" // We only keep the code cells.\n",
66-
" cells = cells.filter(function(c)\n",
67-
" {\n",
68-
" return c instanceof IPython.CodeCell; \n",
69-
" })\n",
70-
" \n",
71-
" // We set the input prompt of all code cells.\n",
72-
" for (var i = 0; i < cells.length; i++) {\n",
73-
" cells[i].set_input_prompt(i + 1);\n",
74-
" }\n",
75-
" }\n",
76-
"}]);"
77-
],
78-
"language": "python"
79-
},
80-
{
81-
"cell_type": "markdown",
82-
"source": [
83-
"Running this code cell adds a button in the toolbar. Clicking on this button automatically updates the prompt numbers of all code cells."
84-
],
85-
"metadata": {}
86-
},
87-
{
88-
"cell_type": "markdown",
89-
"source": [
90-
"2. To make these changes permanent, i.e. to add this button on every notebook open within the current profile, we can open the file `~/.ipython/profile_default/static/custom/custom.js` and add the following code:"
91-
],
92-
"metadata": {}
93-
},
94-
{
95-
"cell_type": "markdown",
96-
"source": [
97-
"```javascript\n",
98-
"$([IPython.events]).on('app_initialized.NotebookApp',\n",
99-
" function(){\n",
100-
"\n",
101-
" // Copy of the Javascript code above (step 1).\n",
102-
" IPython.toolbar.add_buttons_group([\n",
103-
" {\n",
104-
" // The button's label.\n",
105-
" 'label': 'renumber all code cells',\n",
106-
"\n",
107-
" // The button's icon.\n",
108-
" // See a list of Font-Awesome icons here:\n",
109-
" // http://fortawesome.github.io/Font-Awesome/icons/\n",
110-
" 'icon': 'icon-list-ol',\n",
111-
"\n",
112-
" // The callback function.\n",
113-
" 'callback': function () {\n",
114-
"\n",
115-
" // We retrieve the lists of all cells.\n",
116-
" var cells = IPython.notebook.get_cells();\n",
117-
"\n",
118-
" // We only keep the code cells.\n",
119-
" cells = cells.filter(function(c)\n",
120-
" {\n",
121-
" return c instanceof IPython.CodeCell; \n",
122-
" })\n",
123-
"\n",
124-
" // We set the input prompt of all code cells.\n",
125-
" for (var i = 0; i < cells.length; i++) {\n",
126-
" cells[i].set_input_prompt(i + 1);\n",
127-
" }\n",
128-
" }\n",
129-
" }]);\n",
130-
"});\n",
131-
"```"
132-
],
133-
"metadata": {}
134-
},
135-
{
136-
"cell_type": "markdown",
137-
"source": [
138-
"The code put here will be automatically loaded as soon as a notebook page is loaded."
139-
],
140-
"metadata": {}
141-
},
142-
{
143-
"cell_type": "markdown",
144-
"source": [
145-
"> You'll find all the explanations, figures, references, and much more in the book (to be released later this summer).\n",
146-
"\n",
147-
"> [IPython Cookbook](http://ipython-books.github.io/), by [Cyrille Rossant](http://cyrille.rossant.net), Packt Publishing, 2014 (500 pages)."
148-
],
149-
"metadata": {}
150-
}
151-
]
152-
}
153-
]
154-
}
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"# 3.3. Adding custom controls in the notebook toolbar"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"The CSS and Javascript of the HTML notebook can be customized through the files in `~/.ipython/profile_default/static/custom`, where `~` is your `HOME` directory, and `default` is your IPython profile. In this short recipe, we will use this feature to add a new button in the notebook toolbar on top of every notebook. Specifically, this button renumbers linearly all code cells."
22+
]
23+
},
24+
{
25+
"cell_type": "markdown",
26+
"metadata": {},
27+
"source": [
28+
"1. First, we are going to inject Javascript code directly in the notebook. This is useful for testing purposes, or if you don't want your changes to be permanent. The Javascript code will be loaded with that notebook only. To do this, we can just use the `%%javascript` cell magic."
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": null,
34+
"metadata": {
35+
"collapsed": false
36+
},
37+
"outputs": [],
38+
"source": [
39+
"%%javascript\n",
40+
"// This function allows us to add buttons \n",
41+
"// to the notebook toolbar.\n",
42+
"IPython.toolbar.add_buttons_group([\n",
43+
"{\n",
44+
" // The button's label.\n",
45+
" 'label': 'renumber all code cells',\n",
46+
" \n",
47+
" // The button's icon.\n",
48+
" // See a list of Font-Awesome icons here:\n",
49+
" // http://fortawesome.github.io/Font-Awesome/icons/\n",
50+
" 'icon': 'icon-list-ol',\n",
51+
" \n",
52+
" // The callback function.\n",
53+
" 'callback': function () {\n",
54+
" \n",
55+
" // We retrieve the lists of all cells.\n",
56+
" var cells = IPython.notebook.get_cells();\n",
57+
" \n",
58+
" // We only keep the code cells.\n",
59+
" cells = cells.filter(function(c)\n",
60+
" {\n",
61+
" return c instanceof IPython.CodeCell; \n",
62+
" })\n",
63+
" \n",
64+
" // We set the input prompt of all code cells.\n",
65+
" for (var i = 0; i < cells.length; i++) {\n",
66+
" cells[i].set_input_prompt(i + 1);\n",
67+
" }\n",
68+
" }\n",
69+
"}]);"
70+
]
71+
},
72+
{
73+
"cell_type": "markdown",
74+
"metadata": {},
75+
"source": [
76+
"Running this code cell adds a button in the toolbar. Clicking on this button automatically updates the prompt numbers of all code cells."
77+
]
78+
},
79+
{
80+
"cell_type": "markdown",
81+
"metadata": {},
82+
"source": [
83+
"2. To make these changes permanent, i.e. to add this button on every notebook open within the current profile, we can open the file `~/.ipython/profile_default/static/custom/custom.js` and add the following code:"
84+
]
85+
},
86+
{
87+
"cell_type": "markdown",
88+
"metadata": {},
89+
"source": [
90+
"```javascript\n",
91+
"$([IPython.events]).on('app_initialized.NotebookApp',\n",
92+
" function(){\n",
93+
"\n",
94+
" // Copy of the Javascript code above (step 1).\n",
95+
" IPython.toolbar.add_buttons_group([\n",
96+
" {\n",
97+
" // The button's label.\n",
98+
" 'label': 'renumber all code cells',\n",
99+
"\n",
100+
" // The button's icon.\n",
101+
" // See a list of Font-Awesome icons here:\n",
102+
" // http://fortawesome.github.io/Font-Awesome/icons/\n",
103+
" 'icon': 'icon-list-ol',\n",
104+
"\n",
105+
" // The callback function.\n",
106+
" 'callback': function () {\n",
107+
"\n",
108+
" // We retrieve the lists of all cells.\n",
109+
" var cells = IPython.notebook.get_cells();\n",
110+
"\n",
111+
" // We only keep the code cells.\n",
112+
" cells = cells.filter(function(c)\n",
113+
" {\n",
114+
" return c instanceof IPython.CodeCell; \n",
115+
" })\n",
116+
"\n",
117+
" // We set the input prompt of all code cells.\n",
118+
" for (var i = 0; i < cells.length; i++) {\n",
119+
" cells[i].set_input_prompt(i + 1);\n",
120+
" }\n",
121+
" }\n",
122+
" }]);\n",
123+
"});\n",
124+
"```"
125+
]
126+
},
127+
{
128+
"cell_type": "markdown",
129+
"metadata": {},
130+
"source": [
131+
"The code put here will be automatically loaded as soon as a notebook page is loaded."
132+
]
133+
},
134+
{
135+
"cell_type": "markdown",
136+
"metadata": {},
137+
"source": [
138+
"> You'll find all the explanations, figures, references, and much more in the book (to be released later this summer).\n",
139+
"\n",
140+
"> [IPython Cookbook](http://ipython-books.github.io/), by [Cyrille Rossant](http://cyrille.rossant.net), Packt Publishing, 2014 (500 pages)."
141+
]
142+
}
143+
],
144+
"metadata": {
145+
"kernelspec": {
146+
"display_name": "Python 3",
147+
"language": "python",
148+
"name": "python3"
149+
},
150+
"language_info": {
151+
"codemirror_mode": {
152+
"name": "ipython",
153+
"version": 3
154+
},
155+
"file_extension": ".py",
156+
"mimetype": "text/x-python",
157+
"name": "python",
158+
"nbconvert_exporter": "python",
159+
"pygments_lexer": "ipython3",
160+
"version": "3.4.2"
161+
}
162+
},
163+
"nbformat": 4,
164+
"nbformat_minor": 0
165+
}

0 commit comments

Comments
 (0)