-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add tests #36
Open
glwagner
wants to merge
2
commits into
master
Choose a base branch
from
glw/add-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
WIP: Add tests #36
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Get the epiforecast package onto our path: | ||
import os, sys; sys.path.append(os.path.join("..")) | ||
|
||
import numpy as np | ||
|
||
from epiforecast.scenarios import king_county_transition_rates | ||
|
||
def get_rates(rates_name): | ||
return getattr(king_county_transition_rates(population=3, random_seed=1234), rates_name) | ||
|
||
transition_rates = king_county_transition_rates(population=3, random_seed=1234) | ||
|
||
for name in ( | ||
'latent_periods', | ||
'community_infection_periods', | ||
'hospital_infection_periods', | ||
'hospitalization_fraction', | ||
'community_mortality_fraction', | ||
'hospital_mortality_fraction', | ||
): | ||
|
||
print(get_rates(name)) | ||
|
||
def test_latent_periods(): | ||
assert get_rates('latent_periods')[1] == 6.635600468016812 | ||
|
||
def test_community_infection_periods(): | ||
assert get_rates('community_infection_periods')[1] == 1.9142295330323456 | ||
|
||
def test_hospital_infection_periods(): | ||
assert get_rates('hospital_infection_periods')[1] == 8.100370683584359 | ||
|
||
def test_hospitalization_fraction(): | ||
assert get_rates('hospitalization_fraction')[1] == 0.37838525036214415 | ||
|
||
def test_community_mortality_fraction(): | ||
assert get_rates('community_mortality_fraction')[1] == 5.031976849805044e-38 | ||
|
||
def test_hospital_mortality_fraction(): | ||
assert get_rates('hospital_mortality_fraction')[1] == 7.305220148909824e-07 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems outdated now because
scenarios
don't haveking_count_transition_rates
anymorebut I like this test and overall idea, could you massage this into a running test? I'd start adding tests then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this PR has gone stale. I agree this PR should be revived.
A low-effort solution would be to implement a few simple tests for our most high-level objects, since this will implicitly test lower-level functionality.
We can also consider running some of the examples during testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually strip apart some of the examples into shorter tests, but, one way or another, we must start writing them, there are so many bugs right now that it's actually scary :/