Skip to content

Commit d9c1f27

Browse files
Merge pull request #216 from CodeForPhilly/issue_155
Update to mitigation summary text for `Rt < 1` (issue 155)
2 parents b262797 + 6dbfa81 commit d9c1f27

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/penn_chime/presentation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def display_header(st, m, p):
6363
**{r_naught:.2f}**.
6464
6565
**Mitigation**: A **{relative_contact_rate:.0%}** reduction in social contact after the onset of the
66-
outbreak reduces the doubling time to **{doubling_time_t:.1f}** days, implying an effective $R_t$ of **${r_t:.2f}$**.
66+
outbreak **{impact_statement:s} {doubling_time_t:.1f}** days, implying an effective $R_t$ of **${r_t:.2f}$**.
6767
""".format(
6868
total_infections=m.infected,
6969
initial_infections=p.known_infected,
@@ -77,7 +77,8 @@ def display_header(st, m, p):
7777
doubling_time=p.doubling_time,
7878
relative_contact_rate=p.relative_contact_rate,
7979
r_t=m.r_t,
80-
doubling_time_t=m.doubling_time_t,
80+
doubling_time_t=abs(m.doubling_time_t),
81+
impact_statement=("halves the infections every" if m.r_t < 1 else "reduces the doubling time to")
8182
)
8283
)
8384

tests/test_app.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,33 @@ def test_the_rest_of_header_shows_up():
7373
), "The whole header should render"
7474

7575

76+
def test_mitigation_statement():
77+
st.cleanup()
78+
expected_doubling = "outbreak **reduces the doubling time to 7.8** days"
79+
display_header(st, MODEL, PARAM)
80+
assert [s for s in st.render_store if expected_doubling in s]
81+
# assert len((list(filter(lambda s: expected_doubling in s, st.render_store))))
82+
st.cleanup()
83+
expected_halving = "outbreak **halves the infections every 51.9** days"
84+
halving_params = Parameters(
85+
current_hospitalized=100,
86+
doubling_time=6.0,
87+
known_infected=5000,
88+
market_share=0.05,
89+
relative_contact_rate=0.7,
90+
susceptible=500000,
91+
hospitalized=RateLos(0.05, 7),
92+
icu=RateLos(0.02, 9),
93+
ventilated=RateLos(0.01, 10),
94+
n_days=60,
95+
)
96+
halving_model = SimSirModel(halving_params)
97+
display_header(st, halving_model, halving_params)
98+
assert [s for s in st.render_store if expected_halving in s]
99+
#assert len((list(filter(lambda s: expected_halving in s, st.render_store))))
100+
st.cleanup()
101+
102+
76103
st.cleanup()
77104

78105

0 commit comments

Comments
 (0)