From: Katy Huff Date: Fri, 11 Jan 2013 22:35:17 +0000 (-0600) Subject: added readme from library section that @jiffyclub taught in berkeley. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f734840;p=swc-testing-nose.git added readme from library section that @jiffyclub taught in berkeley. --- diff --git a/python/testing/Readme.md b/python/testing/Readme.md index 562892b..5a3dfdb 100644 --- a/python/testing/Readme.md +++ b/python/testing/Readme.md @@ -543,8 +543,7 @@ p1 = np.array([0.0, 0.0]) p2 = np.array([1.0, 1.0]) data = np.array([[0.3, 0.6], [0.25, 0.5], [1.0, 0.75]]) ``` -Building a Library of Code you Trust -==================================== +# Building a Library of Code you Trust Suppose we’re going to be dealing a lot with these animal count files, and doing many different kinds of analysis with them. In the @@ -560,19 +559,16 @@ stored in \`.py\` files and then used in other \`.py\` files where it has been pulled in using an \`import\` statement. Today we’ll show you how to do that. -Exercises -========= +## Exercises -Exercise 1 ----------- +### Exercise 1 Make a new text file called \`animals.py\`. Copy the file reading function from yesterday’s IPython notebook into the file and modify it so that it returns the columns of the file as lists (instead of printing certain lines). -Exercise 2 ----------- +### Exercise 2 We’re going to make a function to calculate the mean of all the values in a list, but we’re going to write the tests for it first. Make a new @@ -580,20 +576,17 @@ text file called \`test\_animals.py\`. Make a function called \`test\_mean\` that runs your theoretical mean function through several tests. -Exercise 3 ----------- +### Exercise 3 Write the mean function in \`animals.py\` and verify that it passes your tests. -Exercise 4 ----------- +### Exercise 4 Write tests for a function that will take a file name and animal name as arguments, and return the average number of animals per sighting. -Exercise 5 ----------- +### Exercise 5 Write a function that takes a file name and animal name and returns the average number of animals per sighting. Make sure it passes your tests.