Skip to content

Commit d9b35db

Browse files
committed
Update tests
1 parent 00516b6 commit d9b35db

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

jhu/tests/test_run.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from os import listdir
44
from os.path import join
55

6+
import numpy as np
67
import pandas as pd
7-
from delphi_jhu.run import run_module
88

99

1010
class TestRun:
@@ -48,3 +48,26 @@ def test_output_file_format(self, run_as_module):
4848
join("receiving", "20200310_state_confirmed_cumulative_num.csv")
4949
)
5050
assert (df.columns.values == ["geo_id", "val", "se", "sample_size"]).all()
51+
52+
53+
class TestSmooth:
54+
def test_output_files_smoothed(self, run_as_module):
55+
dates = [str(x) for x in range(20200304, 20200311)]
56+
57+
smoothed = pd.read_csv(
58+
join("receiving", f"{dates[-1]}_state_confirmed_7dav_cumulative_num.csv")
59+
)
60+
61+
raw = pd.concat(
62+
[
63+
pd.read_csv(
64+
join("receiving", f"{date}_state_confirmed_cumulative_num.csv")
65+
)
66+
for date in dates
67+
]
68+
)
69+
70+
raw = raw.groupby("geo_id")["val"].mean()
71+
df = pd.merge(smoothed, raw, on="geo_id", suffixes=("_smoothed", "_raw"))
72+
assert np.allclose(df["val_smoothed"].values, df["val_raw"].values)
73+

0 commit comments

Comments
 (0)