This repository has been archived by the owner on Jan 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df5bd3f
commit 3d9e9f3
Showing
6 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
- xarray | ||
- pip | ||
- ffmpeg | ||
- pytest | ||
- pip: | ||
- python-awips | ||
- mpldatacursor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Testing | ||
======= | ||
|
||
What is Software Testing? | ||
------------------------- | ||
- Testing is a way to make sure that software keeps working like you expect | ||
- You write code that runs other code and validates the results | ||
|
||
Types of Tests | ||
-------------- | ||
- Unit tests | ||
- Tests of individual units of code (functions, classes). | ||
- Test wide array of inputs and cases try to exhaustively capture cases | ||
- Regression tests | ||
- Test that nothing has broken after making changes | ||
- Integration tests | ||
- Test that different pieces of code work together properly | ||
- Acceptance tests | ||
- Test that code meets certain sets of external requirements | ||
|
||
- None of that matters to us as scientists | ||
|
||
Testing Strategies | ||
------------------ | ||
- The right kind of test for your code: the kind you're willing to write | ||
- Requirements: | ||
- Automated: computer can evaluate whether the test passes | ||
- Consistent: no spurious failures | ||
- Self-contained: no external resources, the test completely controls everything | ||
- At the very least, when you write code, you run it and verify the results | ||
- Why not turn this into an automated test | ||
- Doesn't prove correct | ||
- Verifies that results you thought were sufficient haven't changed | ||
- For some code, can use e.g. values from source reference | ||
- In an ideal world, you write several tests spanning: | ||
- input types (e.g. arrays, scalars) | ||
- input domains | ||
- edge cases | ||
|
||
Interactive: | ||
- Add tests for `temperature.py` to `tests/test_temperature.py` | ||
- values | ||
- round trip | ||
- How do we run tests: `pytest | ||
|
||
Exercise: | ||
- Add calculations for mean and median to `stats.py` | ||
- Add tests to make sure everything is working fine | ||
- Make sure it works for both even- and odd-sized arrays | ||
|
||
Exercise: | ||
- Use tests to find the bugs in the `moving_average` function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import numpy as np | ||
|
||
def median(): | ||
pass | ||
|
||
def mean(): | ||
pass | ||
|
||
def moving_average(vals, n): | ||
out = [] | ||
for i in range(len(val) - n - 1): | ||
out[i] = vals[i:i + n].mean() | ||
return np.arry(vals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
def to_kelvin(celsius): | ||
return celsius + 273.15 | ||
|
||
def to_celsius(fahrenheit): | ||
return (fahrenheit - 32) / 1.8 | ||
|
||
def to_fahrenheit(celsius): | ||
return 1.8 * celsius + 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# | ||
# ADD TESTS HERE | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# | ||
# ADD TESTS HERE | ||
# |