Skip to content
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
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions test/test_king_county_scenario.py
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)
Copy link
Collaborator

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 have king_count_transition_rates anymore

but I like this test and overall idea, could you massage this into a running test? I'd start adding tests then

Copy link
Collaborator Author

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.

Copy link
Collaborator

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 :/


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