-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Help Charlene to test her package (remember to commit after each step, if appropriate).
-
Choose who in your team is sharing now! (make sure you've pulled the latest changes from your team's fork.)
-
Create a
testsdirectory insidesagittal_averageand add a test similar to what we used last week when we discovered the bug.Hint
You need a
test_somethingfunction that runs all the below- Create an input dataset
data_input = np.zeros((20, 20)) data_input[-1, :] = 1
- Save it into a file
np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',')
- Create an array with expected result
# The expeted result is all zeros, except the last one, it should be 1 expected = np.zeros(20) expected[-1] = 1
- call the function with the files
run_averages(file_input="brain_sample.csv", file_output="brain_average.csv")
- Load the result
result = np.loadtxt(TEST_DIR / "brain_average.csv", delimiter=',')
- Compare the result with the expected values
np.testing.assert_array_equal(result, expected)
What could you do to make sure that these files we are creating don't interfere with our repository or the rest of the package?
- Create an input dataset
-
Add an
__init__.pyfile to the tests folder. -
Fix
sagittal_brain.py(as you may remember from last week, the code wrongly averages over the columns, not the rows), make sure the test passes and commit these changes. -
Try to install it by running
pip install -e .where thesetup.pyis, and then run the tests withpytest. -
Share your solution as a pull request to Charlene's repository mentioning this issue (by including the text
Addresses UCL-MPHY0021-21-22/RSE-Classwork#37in the pull request description), remember to mention your team members too! (with@github_username)