Skip to content

Commit 95e60b1

Browse files
ValentinaValentina
authored andcommitted
Merge branch 'msleigh-fix-code-zip' into gh-pages
2 parents 14c7b07 + 19a89ed commit 95e60b1

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

_episodes/03-lists.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ print("With known last position:", sond)
468468
sond = months[8:len(months)]
469469
print("Using len() to get last entry:", sond)
470470
sond = months[8:]
471-
("Omitting ending index:", sond)
471+
print("Omitting ending index:", sond)
472472
~~~
473473
{: .python}
474474

_episodes/04-files.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ while `?` matches any one character.
2828
We can use this to get the names of all the CSV files in the current directory:
2929

3030
~~~
31-
print(glob.glob('data/inflammation*.csv'))
31+
print(glob.glob('inflammation*.csv'))
3232
~~~
3333
{: .python}
3434

3535
~~~
36-
['data/inflammation-05.csv', 'data/inflammation-11.csv', 'data/inflammation-12.csv', 'data/inflammation-08.csv', 'data/inflammation-03.csv', 'data/inflammation-06.csv', 'data/inflammation-09.csv', 'data/inflammation-07.csv', 'data/inflammation-10.csv', 'data/inflammation-02.csv', 'data/inflammation-04.csv', 'data/inflammation-01.csv']
36+
['inflammation-05.csv', 'inflammation-11.csv', 'inflammation-12.csv', 'inflammation-08.csv', 'inflammation-03.csv', 'inflammation-06.csv', 'inflammation-09.csv', 'inflammation-07.csv', 'inflammation-10.csv', 'inflammation-02.csv', 'inflammation-04.csv', 'inflammation-01.csv']
3737
~~~
3838
{: .output}
3939

@@ -49,7 +49,7 @@ If we want to start by analyzing just the first three files in alphabetical orde
4949
import numpy
5050
import matplotlib.pyplot
5151
52-
filenames = sorted(glob.glob('data/inflammation*.csv'))
52+
filenames = sorted(glob.glob('inflammation*.csv'))
5353
filenames = filenames[0:3]
5454
for f in filenames:
5555
print(f)
@@ -115,7 +115,7 @@ where the maxima are a bit less regular, but the minima are consistently zero.
115115
> > import numpy
116116
> > import matplotlib.pyplot
117117
> >
118-
> > filenames = glob.glob('data/inflammation*.csv')
118+
> > filenames = glob.glob('inflammation*.csv')
119119
> >
120120
> > data0 = numpy.loadtxt(fname=filenames[0], delimiter=',')
121121
> > data1 = numpy.loadtxt(fname=filenames[1], delimiter=',')
@@ -137,7 +137,7 @@ where the maxima are a bit less regular, but the minima are consistently zero.
137137
> Use each of the files once to generate a dataset containing values averaged over all patients:
138138
>
139139
> ~~~
140-
> filenames = glob.glob('data/inflammation*.csv')
140+
> filenames = glob.glob('inflammation*.csv')
141141
> composite_data = numpy.zeros((60,40))
142142
> for f in filenames:
143143
> # sum each new file's data into as it's read

_episodes/10-cmdline.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This program does exactly what we want - it prints the average inflammation per
3636
for a given file.
3737

3838
~~~
39-
$ python code/readings_04.py --mean data/inflammation-01.csv
39+
$ python ../code/readings_04.py --mean inflammation-01.csv
4040
5.45
4141
5.425
4242
6.1
@@ -50,14 +50,14 @@ $ python code/readings_04.py --mean data/inflammation-01.csv
5050
We might also want to look at the minimum of the first four lines
5151

5252
~~~
53-
$ head -4 data/inflammation-01.csv | python code/readings_04.py --min
53+
$ head -4 inflammation-01.csv | python ../code/readings_04.py --min
5454
~~~
5555
{: .bash}
5656

5757
or the maximum inflammations in several files one after another:
5858

5959
~~~
60-
$ python code/readings_04.py --max data/inflammation-*.csv
60+
$ python ../code/readings_04.py --max inflammation-*.csv
6161
~~~
6262
{: .bash}
6363

@@ -149,7 +149,7 @@ By convention this function is usually called `main`,
149149
though we can call it whatever we want:
150150

151151
~~~
152-
$ cat readings_01.py
152+
$ cat ../code/readings_01.py
153153
~~~
154154
{: .bash}
155155

@@ -172,7 +172,7 @@ and the name of the file to process from `sys.argv[1]`.
172172
Here's a simple test:
173173

174174
~~~
175-
$ python readings_01.py inflammation-01.csv
175+
$ python ../code/readings_01.py inflammation-01.csv
176176
~~~
177177
{: .bash}
178178

@@ -181,7 +181,7 @@ but haven't actually called it.
181181
Let's add a call to `main`:
182182

183183
~~~
184-
$ cat readings_02.py
184+
$ cat ../code/readings_02.py
185185
~~~
186186
{: .bash}
187187

@@ -204,7 +204,7 @@ if __name__ == '__main__':
204204
and run that:
205205

206206
~~~
207-
$ python readings_02.py inflammation-01.csv
207+
$ python ../code/readings_02.py inflammation-01.csv
208208
~~~
209209
{: .bash}
210210

@@ -342,7 +342,7 @@ $ cat small-01.csv
342342
{: .output}
343343
344344
~~~
345-
$ python readings_02.py small-01.csv
345+
$ python ../code/readings_02.py small-01.csv
346346
~~~
347347
{: .bash}
348348
@@ -380,7 +380,7 @@ Here's our changed program
380380
`readings_03.py`:
381381
382382
~~~
383-
$ cat readings_03.py
383+
$ cat ../code/readings_03.py
384384
~~~
385385
{: .bash}
386386
@@ -403,7 +403,7 @@ if __name__ == '__main__':
403403
and here it is in action:
404404
405405
~~~
406-
$ python readings_03.py small-01.csv small-02.csv
406+
$ python ../code/readings_03.py small-01.csv small-02.csv
407407
~~~
408408
{: .bash}
409409
@@ -436,7 +436,7 @@ These always appear before the names of the files,
436436
so we could just do this:
437437
438438
~~~
439-
$ cat readings_04.py
439+
$ cat ../code/readings_04.py
440440
~~~
441441
{: .bash}
442442
@@ -470,7 +470,7 @@ if __name__ == '__main__':
470470
This works:
471471
472472
~~~
473-
$ python readings_04.py --max small-01.csv
473+
$ python ../code/readings_04.py --max small-01.csv
474474
~~~
475475
{: .bash}
476476
@@ -499,7 +499,7 @@ before doing any processing,
499499
so that the program fails fast:
500500
501501
~~~
502-
$ cat readings_05.py
502+
$ cat ../code/readings_05.py
503503
~~~
504504
{: .bash}
505505
@@ -546,7 +546,7 @@ and so on.
546546
Let's experiment in another script called `count_stdin.py`:
547547
548548
~~~
549-
$ cat count_stdin.py
549+
$ cat ../code/count_stdin.py
550550
~~~
551551
{: .bash}
552552
@@ -569,7 +569,7 @@ but we can do almost anything with it that we could do to a regular file.
569569
Let's try running it as if it were a regular command-line program:
570570
571571
~~~
572-
$ python count_stdin.py < small-01.csv
572+
$ python ../code/count_stdin.py < small-01.csv
573573
~~~
574574
{: .bash}
575575
@@ -581,7 +581,7 @@ $ python count_stdin.py < small-01.csv
581581
A common mistake is to try to run something that reads from standard input like this:
582582
583583
~~~
584-
$ python count_stdin.py small-01.csv
584+
$ python ../code/count_stdin.py small-01.csv
585585
~~~
586586
{: .bash}
587587
@@ -600,7 +600,7 @@ so we don't actually need to change `process`.
600600
Only `main` changes:
601601
602602
~~~
603-
$ cat readings_06.py
603+
$ cat ../code/readings_06.py
604604
~~~
605605
{: .bash}
606606
@@ -641,7 +641,7 @@ if __name__ == '__main__':
641641
Let's try it out:
642642
643643
~~~
644-
$ python readings_06.py --mean < small-01.csv
644+
$ python ../code/readings_06.py --mean < small-01.csv
645645
~~~
646646
{: .bash}
647647

0 commit comments

Comments
 (0)