1
1
"""effectful functions for streamlit io"""
2
2
3
- from typing import Optional
4
-
5
- import altair as alt # type: ignore
6
3
import numpy as np # type: ignore
7
4
import pandas as pd # type: ignore
8
5
13
10
DATE_FORMAT = "%b, %d" # see https://strftime.org
14
11
DOCS_URL = "https://code-for-philly.gitbook.io/chime"
15
12
13
+ FLOAT_INPUT_MIN = 0.001
14
+ FLOAT_INPUT_STEP = FLOAT_INPUT_MIN
15
+
16
16
hide_menu_style = """
17
17
<style>
18
18
#MainMenu {visibility: hidden;}
@@ -158,33 +158,33 @@ def display_sidebar(st, d: Constants) -> Parameters:
158
158
"Number of days to project" ,
159
159
min_value = 30 ,
160
160
value = d .n_days ,
161
- step = 10 ,
161
+ step = 1 ,
162
162
format = "%i" ,
163
163
)
164
164
doubling_time_input = NumberInputWrapper (
165
165
st_obj ,
166
166
"Doubling time before social distancing (days)" ,
167
- min_value = 0 ,
167
+ min_value = FLOAT_INPUT_MIN ,
168
168
value = d .doubling_time ,
169
- step = 1 ,
170
- format = "%i " ,
169
+ step = FLOAT_INPUT_STEP ,
170
+ format = "%f " ,
171
171
)
172
172
relative_contact_rate_input = NumberInputWrapper (
173
173
st_obj ,
174
174
"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 " ,
180
180
)
181
181
hospitalized_rate_input = NumberInputWrapper (
182
182
st_obj ,
183
183
"Hospitalization %(total infections)" ,
184
- min_value = 0.001 ,
184
+ min_value = 0.0 ,
185
185
max_value = 100.0 ,
186
186
value = d .hospitalized .rate * 100 ,
187
- step = 1.0 ,
187
+ step = FLOAT_INPUT_STEP ,
188
188
format = "%f" ,
189
189
)
190
190
icu_rate_input = NumberInputWrapper (
@@ -193,7 +193,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
193
193
min_value = 0.0 ,
194
194
max_value = 100.0 ,
195
195
value = d .icu .rate * 100 ,
196
- step = 1.0 ,
196
+ step = FLOAT_INPUT_STEP ,
197
197
format = "%f" ,
198
198
)
199
199
ventilated_rate_input = NumberInputWrapper (
@@ -202,7 +202,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
202
202
min_value = 0.0 ,
203
203
max_value = 100.0 ,
204
204
value = d .ventilated .rate * 100 ,
205
- step = 1.0 ,
205
+ step = FLOAT_INPUT_STEP ,
206
206
format = "%f" ,
207
207
)
208
208
hospitalized_los_input = NumberInputWrapper (
@@ -232,33 +232,32 @@ def display_sidebar(st, d: Constants) -> Parameters:
232
232
market_share_input = NumberInputWrapper (
233
233
st_obj ,
234
234
"Hospital Market Share (%)" ,
235
- min_value = 0.001 ,
235
+ min_value = FLOAT_INPUT_MIN ,
236
236
max_value = 100.0 ,
237
237
value = d .market_share * 100 ,
238
- step = 1.0 ,
238
+ step = FLOAT_INPUT_STEP ,
239
239
format = "%f" ,
240
240
)
241
241
population_input = NumberInputWrapper (
242
242
st_obj ,
243
243
"Regional Population" ,
244
244
min_value = 1 ,
245
245
value = d .region .population ,
246
- step = 100000 ,
246
+ step = 1 ,
247
247
format = "%i" ,
248
248
)
249
249
known_infected_input = NumberInputWrapper (
250
250
st_obj ,
251
251
"Currently Known Regional Infections (only used to compute detection rate - does not change projections)" ,
252
252
min_value = 0 ,
253
253
value = d .known_infected ,
254
- step = 10 ,
254
+ step = 1 ,
255
255
format = "%i" ,
256
256
)
257
257
as_date_input = CheckboxWrapper (st_obj , "Present result as dates instead of days" , value = False )
258
258
max_y_axis_set_input = CheckboxWrapper (st_obj , "Set the Y-axis on graphs to a static value" )
259
259
max_y_axis_input = NumberInputWrapper (st_obj , "Y-axis static value" , value = 500 , format = "%i" , step = 25 )
260
260
261
-
262
261
# Build in desired order
263
262
st .sidebar .markdown ("### Regional Parameters [ℹ]({docs_url}/what-is-chime/parameters)" .format (docs_url = DOCS_URL ))
264
263
population = population_input ()
@@ -291,7 +290,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
291
290
return Parameters (
292
291
as_date = as_date ,
293
292
current_hospitalized = current_hospitalized ,
294
- market_share = market_share ,
293
+ market_share = market_share / 100.0 ,
295
294
known_infected = known_infected ,
296
295
doubling_time = doubling_time ,
297
296
@@ -300,9 +299,9 @@ def display_sidebar(st, d: Constants) -> Parameters:
300
299
relative_contact_rate = relative_contact_rate / 100.0 ,
301
300
population = population ,
302
301
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 ),
306
305
)
307
306
308
307
0 commit comments