Skip to content

Commit 62ffe34

Browse files
authored
Update inputs
Updates to number input step, min val, and types
2 parents a879ce6 + 1364e4c commit 62ffe34

File tree

5 files changed

+32
-31
lines changed

5 files changed

+32
-31
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
FROM python:3.7.7-slim-buster
22
RUN mkdir /app
33
WORKDIR /app
4-
COPY .streamlit .streamlit
54
COPY README.md .
65
COPY setup.py .
6+
# Creating an empty src dir is a (hopefully) temporary hack to improve layer caching and speed up image builds
7+
# todo fix once the Pipfile, setup.py, requirements.txt, pyprojec.toml build/dist story is figured out
8+
RUN mkdir src && pip install -q .
9+
COPY .streamlit .streamlit
710
COPY settings.cfg .
811
COPY src src
9-
RUN pip install -q .
1012

1113
CMD ["streamlit", "run", "src/app.py"]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ context('Actions', () => {
1111
// This gets the "first" input from the sidebar. From clicking step up,
1212
// the Regional Population should increase from default 4119405 to 4219405.
1313
cy.get('input.st-al')
14-
.should('has.value', '4219405')
14+
.should('has.value', '4119406')
1515
})
1616
});

src/penn_chime/defaults.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def __init__(
2020
self,
2121
*,
2222
current_hospitalized: int,
23-
doubling_time: int,
23+
doubling_time: float,
2424
known_infected: int,
25-
relative_contact_rate: int,
25+
relative_contact_rate: float,
2626
region: Regions,
2727

2828
hospitalized: RateLos,

src/penn_chime/presentation.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
"""effectful functions for streamlit io"""
22

3-
from typing import Optional
4-
5-
import altair as alt # type: ignore
63
import numpy as np # type: ignore
74
import pandas as pd # type: ignore
85

@@ -13,6 +10,9 @@
1310
DATE_FORMAT = "%b, %d" # see https://strftime.org
1411
DOCS_URL = "https://code-for-philly.gitbook.io/chime"
1512

13+
FLOAT_INPUT_MIN = 0.001
14+
FLOAT_INPUT_STEP = FLOAT_INPUT_MIN
15+
1616
hide_menu_style = """
1717
<style>
1818
#MainMenu {visibility: hidden;}
@@ -158,33 +158,33 @@ def display_sidebar(st, d: Constants) -> Parameters:
158158
"Number of days to project",
159159
min_value=30,
160160
value=d.n_days,
161-
step=10,
161+
step=1,
162162
format="%i",
163163
)
164164
doubling_time_input = NumberInputWrapper(
165165
st_obj,
166166
"Doubling time before social distancing (days)",
167-
min_value=0,
167+
min_value=FLOAT_INPUT_MIN,
168168
value=d.doubling_time,
169-
step=1,
170-
format="%i",
169+
step=FLOAT_INPUT_STEP,
170+
format="%f",
171171
)
172172
relative_contact_rate_input = NumberInputWrapper(
173173
st_obj,
174174
"Social distancing (% reduction in social contact)",
175-
min_value=0,
176-
max_value=100,
177-
value=int(d.relative_contact_rate * 100),
178-
step=5,
179-
format="%i",
175+
min_value=0.0,
176+
max_value=100.0,
177+
value=d.relative_contact_rate * 100.0,
178+
step=FLOAT_INPUT_STEP,
179+
format="%f",
180180
)
181181
hospitalized_rate_input = NumberInputWrapper(
182182
st_obj,
183183
"Hospitalization %(total infections)",
184-
min_value=0.001,
184+
min_value=0.0,
185185
max_value=100.0,
186186
value=d.hospitalized.rate * 100,
187-
step=1.0,
187+
step=FLOAT_INPUT_STEP,
188188
format="%f",
189189
)
190190
icu_rate_input = NumberInputWrapper(
@@ -193,7 +193,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
193193
min_value=0.0,
194194
max_value=100.0,
195195
value=d.icu.rate * 100,
196-
step=1.0,
196+
step=FLOAT_INPUT_STEP,
197197
format="%f",
198198
)
199199
ventilated_rate_input = NumberInputWrapper(
@@ -202,7 +202,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
202202
min_value=0.0,
203203
max_value=100.0,
204204
value=d.ventilated.rate * 100,
205-
step=1.0,
205+
step=FLOAT_INPUT_STEP,
206206
format="%f",
207207
)
208208
hospitalized_los_input = NumberInputWrapper(
@@ -232,33 +232,32 @@ def display_sidebar(st, d: Constants) -> Parameters:
232232
market_share_input = NumberInputWrapper(
233233
st_obj,
234234
"Hospital Market Share (%)",
235-
min_value=0.001,
235+
min_value=FLOAT_INPUT_MIN,
236236
max_value=100.0,
237237
value=d.market_share * 100,
238-
step=1.0,
238+
step=FLOAT_INPUT_STEP,
239239
format="%f",
240240
)
241241
population_input = NumberInputWrapper(
242242
st_obj,
243243
"Regional Population",
244244
min_value=1,
245245
value=d.region.population,
246-
step=100000,
246+
step=1,
247247
format="%i",
248248
)
249249
known_infected_input = NumberInputWrapper(
250250
st_obj,
251251
"Currently Known Regional Infections (only used to compute detection rate - does not change projections)",
252252
min_value=0,
253253
value=d.known_infected,
254-
step=10,
254+
step=1,
255255
format="%i",
256256
)
257257
as_date_input = CheckboxWrapper(st_obj, "Present result as dates instead of days", value=False)
258258
max_y_axis_set_input = CheckboxWrapper(st_obj, "Set the Y-axis on graphs to a static value")
259259
max_y_axis_input = NumberInputWrapper(st_obj, "Y-axis static value", value=500, format="%i", step=25)
260260

261-
262261
# Build in desired order
263262
st.sidebar.markdown("### Regional Parameters [ℹ]({docs_url}/what-is-chime/parameters)".format(docs_url=DOCS_URL))
264263
population = population_input()
@@ -291,7 +290,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
291290
return Parameters(
292291
as_date=as_date,
293292
current_hospitalized=current_hospitalized,
294-
market_share=market_share,
293+
market_share=market_share / 100.0,
295294
known_infected=known_infected,
296295
doubling_time=doubling_time,
297296

@@ -300,9 +299,9 @@ def display_sidebar(st, d: Constants) -> Parameters:
300299
relative_contact_rate=relative_contact_rate / 100.0,
301300
population=population,
302301

303-
hospitalized=RateLos(hospitalized_rate/ 100.0, hospitalized_los),
304-
icu=RateLos(icu_rate/ 100.0, icu_los),
305-
ventilated=RateLos(ventilated_rate/ 100.0, ventilated_los),
302+
hospitalized=RateLos(hospitalized_rate / 100.0, hospitalized_los),
303+
icu=RateLos(icu_rate / 100.0, icu_los),
304+
ventilated=RateLos(ventilated_rate / 100.0, ventilated_los),
306305
)
307306

308307

src/penn_chime/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
philly=philly,
1919
),
2020
current_hospitalized=14,
21-
doubling_time=4,
21+
doubling_time=4.0,
2222
known_infected=510,
2323
n_days=60,
2424
market_share=0.15,

0 commit comments

Comments
 (0)