Skip to content

Commit d29c8de

Browse files
author
Eric Smyth
committed
- Adds daily_growth and daily_growth_t instance attributes on Parameters class.
- Adds `daily_growth_helper` function to `src/penn_chime/parameters.py` to calculate daily growth rate as a function of doubling time. - Updates `display_header` function in `src/penn_chime/presentation.py` to display initial and mitigated daily growth rates. - Adds `test_daily_growth` test to `tests/test_app.py` to test above changes Fixes #90
1 parent 16c17a8 commit d29c8de

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/penn_chime/presentation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ def display_header(st, m, p):
6060
and Hospital market share (**{market_share:.0%}**).
6161
6262
An initial doubling time of **{doubling_time}** days and a recovery time of **{recovery_days}** days imply an $R_0$ of
63-
**{r_naught:.2f}**.
63+
**{r_naught:.2f}** and daily growth rate of **{daily_growth:.2f}%**.
6464
6565
**Mitigation**: A **{relative_contact_rate:.0%}** reduction in social contact after the onset of the
66-
outbreak **{impact_statement:s} {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}$** and daily
67+
growth rate of **{daily_growth_t:.2f}%**..
6768
""".format(
6869
total_infections=m.infected,
6970
initial_infections=p.known_infected,
@@ -76,6 +77,8 @@ def display_header(st, m, p):
7677
r_naught=m.r_naught,
7778
doubling_time=p.doubling_time,
7879
relative_contact_rate=p.relative_contact_rate,
80+
daily_growth=p.daily_growth,
81+
daily_growth_t=p.daily_growth_t,
7982
r_t=m.r_t,
8083
doubling_time_t=abs(m.doubling_time_t),
8184
impact_statement=("halves the infections every" if m.r_t < 1 else "reduces the doubling time to")

tests/test_app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def test_mitigation_statement():
100100
st.cleanup()
101101

102102

103+
def test_daily_growth():
104+
st.cleanup()
105+
initial_growth = "and daily growth rate of **12.25%**."
106+
mitigated_growth = "and daily growth rate of **1.18%**."
107+
display_header(st, PARAM)
108+
assert len((list(filter(lambda s: initial_growth in s, st.render_store))))
109+
assert len((list(filter(lambda s: mitigated_growth in s, st.render_store))))
110+
st.cleanup()
111+
112+
103113
st.cleanup()
104114

105115

0 commit comments

Comments
 (0)