|
12 | 12 | build_census_chart,
|
13 | 13 | build_descriptions,
|
14 | 14 | )
|
15 |
| -from src.penn_chime.models import ( |
16 |
| - SimSirModel as Model, |
17 |
| - sir, |
18 |
| - sim_sir_df, |
19 |
| - build_admits_df, |
20 |
| - get_growth_rate, |
21 |
| -) |
| 15 | + |
22 | 16 | from src.penn_chime.parameters import (
|
23 | 17 | Parameters,
|
24 | 18 | Disposition,
|
@@ -51,79 +45,6 @@ def test_defaults_repr(DEFAULTS):
|
51 | 45 |
|
52 | 46 | # Test the math
|
53 | 47 |
|
54 |
| - |
55 |
| -def test_sir(): |
56 |
| - """ |
57 |
| - Someone who is good at testing, help |
58 |
| - """ |
59 |
| - sir_test = sir(100, 1, 0, 0.2, 0.5, 1) |
60 |
| - assert sir_test == ( |
61 |
| - 0.7920792079207921, |
62 |
| - 0.20297029702970298, |
63 |
| - 0.0049504950495049506, |
64 |
| - ), "This contrived example should work" |
65 |
| - |
66 |
| - assert isinstance(sir_test, tuple) |
67 |
| - for v in sir_test: |
68 |
| - assert isinstance(v, float) |
69 |
| - assert v >= 0 |
70 |
| - |
71 |
| - # Certain things should *not* work |
72 |
| - with pytest.raises(TypeError) as error: |
73 |
| - sir("S", 1, 0, 0.2, 0.5, 1) |
74 |
| - assert str(error.value) == "can't multiply sequence by non-int of type 'float'" |
75 |
| - |
76 |
| - with pytest.raises(TypeError) as error: |
77 |
| - sir(100, "I", 0, 0.2, 0.5, 1) |
78 |
| - assert str(error.value) == "can't multiply sequence by non-int of type 'float'" |
79 |
| - |
80 |
| - with pytest.raises(TypeError) as error: |
81 |
| - sir(100, 1, "R", 0.2, 0.5, 1) |
82 |
| - assert str(error.value) == "unsupported operand type(s) for +: 'float' and 'str'" |
83 |
| - |
84 |
| - with pytest.raises(TypeError) as error: |
85 |
| - sir(100, 1, 0, "beta", 0.5, 1) |
86 |
| - assert str(error.value) == "bad operand type for unary -: 'str'" |
87 |
| - |
88 |
| - with pytest.raises(TypeError) as error: |
89 |
| - sir(100, 1, 0, 0.2, "gamma", 1) |
90 |
| - assert str(error.value) == "unsupported operand type(s) for -: 'float' and 'str'" |
91 |
| - |
92 |
| - with pytest.raises(TypeError) as error: |
93 |
| - sir(100, 1, 0, 0.2, 0.5, "N") |
94 |
| - assert str(error.value) == "unsupported operand type(s) for /: 'str' and 'float'" |
95 |
| - |
96 |
| - # Zeros across the board should fail |
97 |
| - with pytest.raises(ZeroDivisionError): |
98 |
| - sir(0, 0, 0, 0, 0, 0) |
99 |
| - |
100 |
| - |
101 |
| -def test_sim_sir(): |
102 |
| - """ |
103 |
| - Rounding to move fast past decimal place issues |
104 |
| - """ |
105 |
| - raw_df = sim_sir_df( |
106 |
| - 5, # s |
107 |
| - 6, # i |
108 |
| - 7, # r |
109 |
| - 0.1, # gamma |
110 |
| - 0, # i_day |
111 |
| - 0.1, # beta1 |
112 |
| - 40, # n_days1 |
113 |
| - ) |
114 |
| - |
115 |
| - first = raw_df.iloc[0, :] |
116 |
| - last = raw_df.iloc[-1, :] |
117 |
| - |
118 |
| - assert round(first.susceptible, 0) == 5 |
119 |
| - assert round(first.infected, 2) == 6 |
120 |
| - assert round(first.recovered, 0) == 7 |
121 |
| - assert round(last.susceptible, 2) == 0 |
122 |
| - assert round(last.infected, 2) == 0.18 |
123 |
| - assert round(last.recovered, 2) == 17.82 |
124 |
| - |
125 |
| - assert isinstance(raw_df, pd.DataFrame) |
126 |
| - |
127 | 48 | def test_admits_chart(admits_df):
|
128 | 49 | chart = build_admits_chart(alt=alt, admits_df=admits_df)
|
129 | 50 | assert isinstance(chart, (alt.Chart, alt.LayerChart))
|
@@ -228,12 +149,6 @@ def test_model_cumulative_census(param, model):
|
228 | 149 | assert (diff.abs() < 0.1).all()
|
229 | 150 |
|
230 | 151 |
|
231 |
| -def test_growth_rate(): |
232 |
| - assert np.round(get_growth_rate(5) * 100.0, decimals=4) == 14.8698 |
233 |
| - assert np.round(get_growth_rate(0) * 100.0, decimals=4) == 0.0 |
234 |
| - assert np.round(get_growth_rate(-4) * 100.0, decimals=4) == -15.9104 |
235 |
| - |
236 |
| - |
237 | 152 | def test_build_descriptions(admits_df, param):
|
238 | 153 | chart = build_admits_chart(alt=alt, admits_df=admits_df)
|
239 | 154 | description = build_descriptions(chart=chart, labels=param.labels)
|
|
0 commit comments