From d5b36a0e18adb28ed7ea594bf6e8a027b1a78432 Mon Sep 17 00:00:00 2001 From: Ed Bennett Date: Thu, 27 Jul 2023 16:26:08 +0100 Subject: [PATCH] always use spaces after commas --- episodes/02-numpy.md | 4 ++-- episodes/03-matplotlib.md | 4 ++-- episodes/04-lists.md | 2 +- episodes/06-files.md | 10 +++++----- episodes/08-func.md | 2 +- episodes/10-defensive.md | 2 +- episodes/12-cmdline.md | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/episodes/02-numpy.md b/episodes/02-numpy.md index 55fa82710..bb927b035 100644 --- a/episodes/02-numpy.md +++ b/episodes/02-numpy.md @@ -218,7 +218,7 @@ It takes a bit of getting used to, but one way to remember the rule is that the index is how many steps we have to take from the start to get the item we want. -![](fig/python-zero-index.svg){alt="'data' is a 3 by 3 numpy array containing row 0: \['A', 'B', 'C'\], row 1: \['D', 'E', 'F'\], androw 2: \['G', 'H', 'I'\]. Starting in the upper left hand corner, data\[0, 0\] = 'A', data\[0, 1\] = 'B',data\[0, 2\] = 'C', data\[1, 0\] = 'D', data\[1, 1\] = 'E', data\[1, 2\] = 'F', data\[2, 0\] = 'G',data\[2, 1\] = 'H', and data\[2, 2\] = 'I',in the bottom right hand corner."} +![](fig/python-zero-index.svg){alt="'data' is a 3 by 3 numpy array containing row 0: \['A', 'B', 'C'\], row 1: \['D', 'E', 'F'\], androw 2: \['G', 'H', 'I'\]. Starting in the upper left hand corner, data\[0, 0\] = 'A', data\[0, 1\] = 'B',data\[0, 2\] = 'C', data\[1, 0\] = 'D', data\[1, 1\] = 'E', data\[1, 2\] = 'F', data\[2, 0\] = 'G',data\[2, 1\] = 'H', and data\[2, 2\] = 'I', in the bottom right hand corner."} ::::::::::::::::::::::::::::::::::::::::: callout @@ -585,7 +585,7 @@ using NumPy's `vstack` and `hstack` functions for vertical and horizontal stacki ```python import numpy -A = numpy.array([[1,2,3], [4,5,6], [7, 8, 9]]) +A = numpy.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) print('A = ') print(A) diff --git a/episodes/03-matplotlib.md b/episodes/03-matplotlib.md index b58e6750c..baccbdb7f 100644 --- a/episodes/03-matplotlib.md +++ b/episodes/03-matplotlib.md @@ -202,7 +202,7 @@ If we want to change this, we can use the `set_ylim(min, max)` method of each 'a for example: ```python -axes3.set_ylim(0,6) +axes3.set_ylim(0, 6) ``` Update your plotting code to automatically set a more appropriate scale. @@ -216,7 +216,7 @@ Update your plotting code to automatically set a more appropriate scale. # One method axes3.set_ylabel('min') axes3.plot(numpy.amin(data, axis=0)) -axes3.set_ylim(0,6) +axes3.set_ylim(0, 6) ``` ::::::::::::::::::::::::: diff --git a/episodes/04-lists.md b/episodes/04-lists.md index 3110c9976..b356b7471 100644 --- a/episodes/04-lists.md +++ b/episodes/04-lists.md @@ -506,7 +506,7 @@ print(repeats) 1. `[2, 4, 6, 8, 10, 2, 4, 6, 8, 10]` 2. `[4, 8, 12, 16, 20]` -3. `[[2, 4, 6, 8, 10],[2, 4, 6, 8, 10]]` +3. `[[2, 4, 6, 8, 10], [2, 4, 6, 8, 10]]` 4. `[2, 4, 6, 8, 10, 4, 8, 12, 16, 20]` The technical term for this is *operator overloading*: diff --git a/episodes/06-files.md b/episodes/06-files.md index 64dea5662..4d8b3af83 100644 --- a/episodes/06-files.md +++ b/episodes/06-files.md @@ -87,19 +87,19 @@ for filename in filenames: inflammation-01.csv ``` -![](fig/03-loop_49_1.png){alt='Output from the first iteration of the for loop. Three line graphs showing the daily average,maximum and minimum inflammation over a 40-day period for all patients in the first dataset.'} +![](fig/03-loop_49_1.png){alt='Output from the first iteration of the for loop. Three line graphs showing the daily average, maximum and minimum inflammation over a 40-day period for all patients in the first dataset.'} ```output inflammation-02.csv ``` -![](fig/03-loop_49_3.png){alt='Output from the second iteration of the for loop. Three line graphs showing the daily average,maximum and minimum inflammation over a 40-day period for all patients in the seconddataset.'} +![](fig/03-loop_49_3.png){alt='Output from the second iteration of the for loop. Three line graphs showing the daily average, maximum and minimum inflammation over a 40-day period for all patients in the seconddataset.'} ```output inflammation-03.csv ``` -![](fig/03-loop_49_5.png){alt='Output from the third iteration of the for loop. Three line graphs showing the daily average,maximum and minimum inflammation over a 40-day period for all patients in the thirddataset.'} +![](fig/03-loop_49_5.png){alt='Output from the third iteration of the for loop. Three line graphs showing the daily average, maximum and minimum inflammation over a 40-day period for all patients in the thirddataset.'} The plots generated for the second clinical trial file look very similar to the plots for the first file: their average plots show similar "noisy" rises and falls; their maxima plots @@ -161,7 +161,7 @@ Use each of the files once to generate a dataset containing values averaged over ```python filenames = glob.glob('inflammation*.csv') -composite_data = numpy.zeros((60,40)) +composite_data = numpy.zeros((60, 40)) for filename in filenames: # sum each new file's data into composite_data as it's read # @@ -181,7 +181,7 @@ import numpy import matplotlib.pyplot filenames = glob.glob('inflammation*.csv') -composite_data = numpy.zeros((60,40)) +composite_data = numpy.zeros((60, 40)) for filename in filenames: data = numpy.loadtxt(fname = filename, delimiter=',') diff --git a/episodes/08-func.md b/episodes/08-func.md index e6f41e525..2312e4bbf 100644 --- a/episodes/08-func.md +++ b/episodes/08-func.md @@ -286,7 +286,7 @@ let's use NumPy to create a matrix of 0's and then offset its values to have a mean value of 3: ```python -z = numpy.zeros((2,2)) +z = numpy.zeros((2, 2)) print(offset_mean(z, 3)) ``` diff --git a/episodes/10-defensive.md b/episodes/10-defensive.md index 8b9e8d681..5967bcce6 100644 --- a/episodes/10-defensive.md +++ b/episodes/10-defensive.md @@ -264,7 +264,7 @@ The range of each time series is represented as a pair of numbers, which are the time the interval started and ended. The output is the largest range that they all include: -![](fig/python-overlapping-ranges.svg){alt='Graph showing three number lines and, at the bottom,the interval that they overlap.'} +![](fig/python-overlapping-ranges.svg){alt='Graph showing three number lines and, at the bottom, the interval that they overlap.'} Most novice programmers would solve this problem like this: diff --git a/episodes/12-cmdline.md b/episodes/12-cmdline.md index bde7292f2..08696d28a 100644 --- a/episodes/12-cmdline.md +++ b/episodes/12-cmdline.md @@ -994,7 +994,7 @@ def main(): def count_file(filename): """count the number of lines in a file""" - f = open(filename,'r') + f = open(filename, 'r') nlines = len(f.readlines()) f.close() return(nlines)