Skip to content

Commit 3687198

Browse files
authored
Merge branch 'develop' into 531_update_defaults
2 parents a52c7e7 + 9f3bcdd commit 3687198

File tree

5 files changed

+6
-141
lines changed

5 files changed

+6
-141
lines changed

e2e/cypress/integration/tests/steppers.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ context('Increment steppers', () => {
66
});
77

88
it('Increment regional population', () => {
9-
cy.contains('Hospitalized Admissions peaks at 300');
9+
cy.contains('Regional population (3600000)');
1010

1111
cy.get('input[type=number]').eq(0)
1212
.should('has.value', '3600000');
@@ -16,11 +16,11 @@ context('Increment steppers', () => {
1616
cy.get('input[type=number]').eq(0)
1717
.should('has.value', '3600001');
1818

19-
cy.contains('Hospitalized Admissions peaks at 300');
19+
cy.contains('Regional population (3600001)');
2020
});
2121

2222
it('Increment hospital market share', () => {
23-
cy.contains('Hospitalized Admissions peaks at 300');
23+
cy.contains('The estimated number of currently infected individuals is 20128.');
2424

2525
cy.get('input[type=number]').eq(1)
2626
.should('has.value', '15');
@@ -30,11 +30,11 @@ context('Increment steppers', () => {
3030
cy.get('input[type=number]').eq(1)
3131
.should('has.value', '15.1');
3232

33-
cy.contains('Hospitalized Admissions peaks at 302');
33+
cy.contains('The estimated number of currently infected individuals is 19996.');
3434
});
3535

3636
it('Increment doubling time', () => {
37-
cy.contains('Hospitalized Admissions peaks at 300');
37+
cy.contains('An initial doubling time of 4.0 days');
3838

3939
cy.get('input[type=number]').eq(3)
4040
.should('has.value', '4');
@@ -44,6 +44,6 @@ context('Increment steppers', () => {
4444
cy.get('input[type=number]').eq(3)
4545
.should('has.value', '4.25');
4646

47-
cy.contains('Hospitalized Admissions peaks at 272');
47+
cy.contains('An initial doubling time of 4.25 days');
4848
});
4949
});

src/app.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
from penn_chime.charts import (
1818
build_admits_chart,
1919
build_census_chart,
20-
build_descriptions,
2120
build_sim_sir_w_date_chart,
22-
build_table,
2321
)
2422

2523
# This is somewhat dangerous:
@@ -38,46 +36,22 @@
3836
st.markdown("Projected number of **daily** COVID-19 admissions. \n\n _NOTE: Now including estimates of prior admissions for comparison._")
3937
admits_chart = build_admits_chart(alt=alt, admits_floor_df=m.admits_floor_df, max_y_axis=p.max_y_axis)
4038
st.altair_chart(admits_chart, use_container_width=True)
41-
st.markdown(build_descriptions(chart=admits_chart, labels=p.labels, prefix="admits_", suffix=" Admissions"))
4239
display_download_link(
4340
st,
4441
filename=f"{p.current_date}_projected_admits.csv",
4542
df=m.admits_df,
4643
)
4744

48-
if st.checkbox("Show Projected Admissions in tabular form"):
49-
admits_modulo = 1
50-
if not st.checkbox("Show Daily Counts"):
51-
admits_modulo = 7
52-
table_df = build_table(
53-
df=m.admits_floor_df,
54-
labels=p.labels,
55-
modulo=admits_modulo)
56-
st.table(table_df)
57-
58-
5945
st.subheader("Admitted Patients (Census)")
6046
st.markdown("Projected **census** of COVID-19 patients, accounting for arrivals and discharges \n\n _NOTE: Now including estimates of prior census for comparison._")
6147
census_chart = build_census_chart(alt=alt, census_floor_df=m.census_floor_df, max_y_axis=p.max_y_axis)
6248
st.altair_chart(census_chart, use_container_width=True)
63-
st.markdown(build_descriptions(chart=census_chart, labels=p.labels, prefix="census_", suffix=" Census"))
6449
display_download_link(
6550
st,
6651
filename=f"{p.current_date}_projected_census.csv",
6752
df=m.census_df,
6853
)
6954

70-
if st.checkbox("Show Projected Census in tabular form"):
71-
census_modulo = 1
72-
if not st.checkbox("Show Daily Census Counts"):
73-
census_modulo = 7
74-
table_df = build_table(
75-
df=m.census_floor_df,
76-
labels=p.labels,
77-
modulo=census_modulo)
78-
st.table(table_df)
79-
80-
8155
st.subheader("Susceptible, Infected, and Recovered")
8256
st.markdown("The number of susceptible, infected, and recovered individuals in the hospital catchment region at any given moment")
8357
sim_sir_w_date_chart = build_sim_sir_w_date_chart(alt=alt, sim_sir_w_date_floor_df=m.sim_sir_w_date_floor_df)
@@ -88,10 +62,4 @@
8862
df=m.sim_sir_w_date_df,
8963
)
9064

91-
if st.checkbox("Show SIR Simulation in tabular form"):
92-
table_df = build_table(
93-
df=m.sim_sir_w_date_floor_df,
94-
labels=p.labels)
95-
st.table(table_df)
96-
9765
display_footer(st)

src/penn_chime/charts.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -125,57 +125,3 @@ def build_sim_sir_w_date_chart(
125125
.configure_legend(orient="bottom")
126126
.interactive()
127127
)
128-
129-
130-
def build_descriptions(
131-
*,
132-
chart: Chart,
133-
labels: Dict[str, str],
134-
prefix: str = "",
135-
suffix: str = ""
136-
) -> str:
137-
"""
138-
139-
:param chart: The alt chart to be used in finding max points
140-
:param suffix: The assumption is that the charts have similar column names.
141-
The census chart adds " Census" to the column names.
142-
Make sure to include a space or underscore as appropriate
143-
:return: Returns a multi-line string description of the results
144-
"""
145-
messages = []
146-
147-
cols = ["hospitalized", "icu", "ventilated"]
148-
asterisk = False
149-
day = "date" if "date" in chart.data.columns else "day"
150-
151-
for col in cols:
152-
if chart.data[prefix+col].idxmax() + 1 == len(chart.data):
153-
asterisk = True
154-
155-
# todo: bring this to an optional arg / i18n
156-
on = datetime.strftime(chart.data[day][chart.data[prefix+col].idxmax()], "%b %d")
157-
158-
messages.append(
159-
"{}{} peaks at {:,} on {}{}".format(
160-
labels[col],
161-
suffix,
162-
ceil(chart.data[prefix+col].max()),
163-
on,
164-
"*" if asterisk else "",
165-
)
166-
)
167-
168-
if asterisk:
169-
messages.append(
170-
"_* The max is at the upper bound of the data, and therefore may not be the actual max_"
171-
)
172-
return "\n\n".join(messages)
173-
174-
175-
def build_table(
176-
*, df: pd.DataFrame, labels: Dict[str, str], modulo: int = 1
177-
) -> pd.DataFrame:
178-
table_df = df[np.mod(df.day, modulo) == 0].copy()
179-
table_df.date = table_df.date.dt.strftime(DATE_FORMAT)
180-
table_df.rename(labels)
181-
return table_df

src/penn_chime/models.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,6 @@ def sir(
287287
s_n = (-beta * s * i) + s
288288
i_n = (beta * s * i - gamma * i) + i
289289
r_n = gamma * i + r
290-
291-
# TODO:
292-
# Post check dfs for negative values and
293-
# warn the user that their input data is bad.
294-
# JL: I suspect that these adjustments covered bugs.
295-
296-
#if s_n < 0.0:
297-
# s_n = 0.0
298-
#if i_n < 0.0:
299-
# i_n = 0.0
300-
#if r_n < 0.0:
301-
# r_n = 0.0
302290
scale = n / (s_n + i_n + r_n)
303291
return s_n * scale, i_n * scale, r_n * scale
304292

tests/penn_chime/test_charts.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
from math import ceil
2-
from datetime import datetime
3-
41
import altair as alt
52
import pytest
63

74
from penn_chime.charts import (
85
build_admits_chart,
96
build_census_chart,
10-
build_descriptions,
117
)
128

13-
# TODO add test for asterisk
14-
15-
169
DISPOSITION_KEYS = ("hospitalized", "icu", "ventilated")
1710

1811

@@ -26,36 +19,6 @@ def test_admits_chart(admits_floor_df):
2619
build_admits_chart()
2720

2821

29-
def test_build_descriptions(admits_floor_df, param):
30-
chart = build_admits_chart(alt=alt, admits_floor_df=admits_floor_df)
31-
description = build_descriptions(chart=chart, labels=param.labels, prefix="admits_")
32-
33-
hosp, icu, vent = description.split("\n\n") # break out the description into lines
34-
35-
max_hosp = chart.data["admits_hospitalized"].max()
36-
assert str(ceil(max_hosp)) in hosp
37-
38-
39-
def test_no_asterisk(admits_floor_df, param):
40-
param.n_days = 600
41-
42-
chart = build_admits_chart(alt=alt, admits_floor_df=admits_floor_df)
43-
description = build_descriptions(chart=chart, labels=param.labels, prefix="admits_")
44-
assert "*" not in description
45-
46-
47-
def test_census(census_floor_df, param):
48-
chart = build_census_chart(alt=alt, census_floor_df=census_floor_df)
49-
description = build_descriptions(chart=chart, labels=param.labels, prefix="census_")
50-
51-
assert str(ceil(chart.data["census_ventilated"].max())) in description
52-
assert str(chart.data["census_icu"].idxmax()) not in description
53-
assert (
54-
datetime.strftime(chart.data.iloc[chart.data["census_icu"].idxmax()].date, "%b %d")
55-
in description
56-
)
57-
58-
5922
def test_census_chart(census_floor_df):
6023
chart = build_census_chart(alt=alt, census_floor_df=census_floor_df)
6124
assert isinstance(chart, (alt.Chart, alt.LayerChart))

0 commit comments

Comments
 (0)