Skip to content

Commit f8171ee

Browse files
author
Tania Allard
committed
Edit cell metadata
1 parent ede7113 commit f8171ee

File tree

3 files changed

+120
-23
lines changed

3 files changed

+120
-23
lines changed

03_ProcessData.ipynb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@
173173
"If you want to know more about documentation styles and Python style visit: [Google Python style guidelines](https://google.github.io/styleguide/pyguide.html#Comments)"
174174
]
175175
},
176+
{
177+
"cell_type": "markdown",
178+
"metadata": {},
179+
"source": [
180+
"![automate](assets/automate.png)"
181+
]
182+
},
176183
{
177184
"cell_type": "markdown",
178185
"metadata": {
@@ -204,7 +211,7 @@
204211
}
205212
},
206213
"source": [
207-
"# Creating the `run all` script\n",
214+
"# Creating the **run all** script\n",
208215
"\n",
209216
"<div class='info'> \n",
210217
" We will run everything from the root directory.<br>\n",

04_Testing.ipynb

Lines changed: 112 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,76 @@
1212
"\n",
1313
"We now have a fully automated script! 🎉👏🏻🦄\n",
1414
"\n",
15-
"The next step is to include **tests**... in fact testing should be a core part of our development process. In fact all of our **reproducible workflows** are analogous to experimental design in the scientific world\n",
15+
"😕 Such a shame we still cannot guarantee the results are correct... or that there are no bugs.\n",
1616
"\n",
17+
"The next step is to include **tests**... in fact testing should be a core part of our development process. In fact all of our **reproducible workflows** are analogous to experimental design in the scientific world"
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {
23+
"slideshow": {
24+
"slide_type": "subslide"
25+
}
26+
},
27+
"source": [
1728
"![science](./assets/the_difference.png)\n",
1829
"\n",
1930
"<small> https://xkcd.com/242/ </small>"
2031
]
2132
},
2233
{
2334
"cell_type": "markdown",
24-
"metadata": {},
35+
"metadata": {
36+
"slideshow": {
37+
"slide_type": "subslide"
38+
}
39+
},
2540
"source": [
26-
"There are various approaches to tests software:\n",
41+
"There are various approaches to test software:\n",
2742
"- **Assertions**: 🦄 == 🦄\n",
28-
"- **Exceptions**: within the code serve as warnings ⚠️\n",
43+
"- **Exceptions**: (within the code) serve as warnings ⚠️\n",
2944
"- **Unit tests**: investigate the behaviour of units of code (e.g functions)\n",
3045
"- **Regression tests**: defends against 🐛\n",
3146
"- **Integration tests**: ⚙️ checks that the pieces work together as expected"
3247
]
3348
},
3449
{
3550
"cell_type": "markdown",
36-
"metadata": {},
51+
"metadata": {
52+
"slideshow": {
53+
"slide_type": "subslide"
54+
}
55+
},
3756
"source": [
3857
"## Exceptions \n",
3958
"Remember when you tried to run `02_visualize-wines.py`? It woud not work unless you had created a figures directory beforehand.\n",
4059
"\n",
4160
"We can catch this kinds of errors by adding this piece of code:\n",
4261
"```python\n",
4362
"try:\n",
63+
" # try to save the figure\n",
4464
" fig.savefig(fname, bbox_inches = 'tight')\n",
4565
" except OSError as e:\n",
66+
" # wowza! the directory does not exist\n",
4667
" os.makedirs('figures')\n",
4768
" print('Creating figures directory')\n",
4869
" fig.savefig(fname, bbox_inches='tight')\n",
4970
"```\n",
50-
"Now our `runall` should work!!! 🎉🎉"
71+
"Now our `runall` should work!!! 🎉🎉\n",
72+
"\n",
73+
"```\n",
74+
"$ python src.runall-wine-analysis\n",
75+
"```"
5176
]
5277
},
5378
{
5479
"cell_type": "markdown",
55-
"metadata": {},
80+
"metadata": {
81+
"slideshow": {
82+
"slide_type": "subslide"
83+
}
84+
},
5685
"source": [
5786
"## Unit testing\n",
5887
"Open `03_country-subset.py` and add the following function:\n",
@@ -64,8 +93,17 @@
6493
" wine = pd.read_csv(filename)\n",
6594
" mean_price = wine['price'].mean()\n",
6695
" return round(mean_price, 4)\n",
67-
"```\n",
68-
"\n",
96+
"```"
97+
]
98+
},
99+
{
100+
"cell_type": "markdown",
101+
"metadata": {
102+
"slideshow": {
103+
"slide_type": "subslide"
104+
}
105+
},
106+
"source": [
69107
"And we will modify this function too:\n",
70108
"```python\n",
71109
"def get_country(filename, country):\n",
@@ -89,7 +127,11 @@
89127
},
90128
{
91129
"cell_type": "markdown",
92-
"metadata": {},
130+
"metadata": {
131+
"slideshow": {
132+
"slide_type": "subslide"
133+
}
134+
},
93135
"source": [
94136
"Now we are going to create our testing suite. \n",
95137
"To run the tests we are going to use **pytest**.\n",
@@ -108,7 +150,11 @@
108150
},
109151
{
110152
"cell_type": "markdown",
111-
"metadata": {},
153+
"metadata": {
154+
"slideshow": {
155+
"slide_type": "subslide"
156+
}
157+
},
112158
"source": [
113159
"Your test script should look like this:\n",
114160
"``` python\n",
@@ -132,7 +178,11 @@
132178
},
133179
{
134180
"cell_type": "markdown",
135-
"metadata": {},
181+
"metadata": {
182+
"slideshow": {
183+
"slide_type": "subslide"
184+
}
185+
},
136186
"source": [
137187
"### What if you want all the decimal numbers?\n",
138188
"\n",
@@ -156,7 +206,11 @@
156206
},
157207
{
158208
"cell_type": "markdown",
159-
"metadata": {},
209+
"metadata": {
210+
"slideshow": {
211+
"slide_type": "subslide"
212+
}
213+
},
160214
"source": [
161215
"### What else could go wrong?\n",
162216
"\n",
@@ -188,7 +242,11 @@
188242
},
189243
{
190244
"cell_type": "markdown",
191-
"metadata": {},
245+
"metadata": {
246+
"slideshow": {
247+
"slide_type": "subslide"
248+
}
249+
},
192250
"source": [
193251
"Pytest tells us which tests passed and which did not:\n",
194252
"\n",
@@ -211,7 +269,11 @@
211269
},
212270
{
213271
"cell_type": "markdown",
214-
"metadata": {},
272+
"metadata": {
273+
"slideshow": {
274+
"slide_type": "subslide"
275+
}
276+
},
215277
"source": [
216278
"We now know what kind of bugs we can encounter.\n",
217279
"Let's fix this, open `03_subset-country.py` and add the following lines\n",
@@ -239,7 +301,11 @@
239301
},
240302
{
241303
"cell_type": "markdown",
242-
"metadata": {},
304+
"metadata": {
305+
"slideshow": {
306+
"slide_type": "subslide"
307+
}
308+
},
243309
"source": [
244310
"### See what we did in the previous steps?\n",
245311
"\n",
@@ -258,7 +324,11 @@
258324
},
259325
{
260326
"cell_type": "markdown",
261-
"metadata": {},
327+
"metadata": {
328+
"slideshow": {
329+
"slide_type": "subslide"
330+
}
331+
},
262332
"source": [
263333
"## Past as Truth (regression tests)\n",
264334
"\n",
@@ -271,7 +341,11 @@
271341
},
272342
{
273343
"cell_type": "markdown",
274-
"metadata": {},
344+
"metadata": {
345+
"slideshow": {
346+
"slide_type": "subslide"
347+
}
348+
},
275349
"source": [
276350
"# nbval\n",
277351
"\n",
@@ -285,7 +359,11 @@
285359
},
286360
{
287361
"cell_type": "markdown",
288-
"metadata": {},
362+
"metadata": {
363+
"slideshow": {
364+
"slide_type": "subslide"
365+
}
366+
},
289367
"source": [
290368
"Try it on your shell \n",
291369
"\n",
@@ -302,7 +380,11 @@
302380
},
303381
{
304382
"cell_type": "markdown",
305-
"metadata": {},
383+
"metadata": {
384+
"slideshow": {
385+
"slide_type": "slide"
386+
}
387+
},
306388
"source": [
307389
"# Provenance\n",
308390
"\n",
@@ -313,7 +395,11 @@
313395
},
314396
{
315397
"cell_type": "markdown",
316-
"metadata": {},
398+
"metadata": {
399+
"slideshow": {
400+
"slide_type": "subslide"
401+
}
402+
},
317403
"source": [
318404
"<div class='warn'>Make sure everything is commited to git before carrying on.</div>\n",
319405
"<br>\n",
@@ -327,7 +413,11 @@
327413
},
328414
{
329415
"cell_type": "markdown",
330-
"metadata": {},
416+
"metadata": {
417+
"slideshow": {
418+
"slide_type": "subslide"
419+
}
420+
},
331421
"source": [
332422
"You can now track the provenance of your project. \n",
333423
"\n",

assets/automate.png

484 KB
Loading

0 commit comments

Comments
 (0)