Skip to content

Commit e6fc068

Browse files
committed
Example vaccine pytest
1 parent 499ff29 commit e6fc068

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

examples/covasim_/vaccinating_elderly/example_vaccine.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ROOT = os.path.realpath(os.path.dirname(__file__))
1515

1616

17-
def setup_test_case(verbose: bool = False):
17+
def run_test_case(verbose: bool = False):
1818
"""Run the causal test case for the effect of changing vaccine to prioritise elderly from observational
1919
data that was previously simulated.
2020
@@ -23,7 +23,7 @@ def setup_test_case(verbose: bool = False):
2323
"""
2424

2525
# 1. Read in the Causal DAG
26-
causal_dag = CausalDAG(f"{ROOT}/dag.dot")
26+
causal_dag = CausalDAG(os.path.join(ROOT, "dag.dot"))
2727

2828
# 2. Create variables
2929
vaccine = Input("vaccine", int)
@@ -33,7 +33,7 @@ def setup_test_case(verbose: bool = False):
3333
max_doses = Output("max_doses", int)
3434

3535
# 5. Read the previously simulated data
36-
obs_df = pd.read_csv("simulated_data.csv")
36+
obs_df = pd.read_csv(os.path.join(ROOT, "simulated_data.csv"))
3737

3838
# 6. Express expected outcomes
3939
expected_outcome_effects = {
@@ -82,8 +82,12 @@ def setup_test_case(verbose: bool = False):
8282
return results_dict
8383

8484

85+
def test_example_vaccine():
86+
run_test_case()
87+
88+
8589
if __name__ == "__main__":
8690

87-
test_results = setup_test_case(verbose=True)
91+
test_results = run_test_case(verbose=True)
8892

8993
logging.info("%s", test_results)

0 commit comments

Comments
 (0)