Skip to content

Commit

Permalink
Fixed checkbox import export functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Haider Syed committed Apr 2, 2020
1 parent 3358ac0 commit ac62cf6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/penn_chime/hc_param_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def constants_from_uploaded_file(file: io.StringIO) -> Tuple[Parameters, dict]:
icu_covid_beds=imported_params["TotalNumberOfICUBedsForNCPatients"],
# total_vents=imported_params.get("TotalNumberOfVents", 10), # Deprecated in v1.1.1
covid_ventilators=imported_params["TotalNumberOfVentsForNCPatients"],

max_y_axis_set = imported_params["MaxYAxisSet"],
max_y_axis = imported_params["MaxYAxis"],

covid_census_value=imported_params["CurrentlyHospitalizedCovidPatients"],
covid_census_date = date.fromisoformat(imported_params["CurrentlyHospitalizedCovidPatientsDate"]) if "CurrentlyHospitalizedCovidPatientsDate" in imported_params else (date.today() - timedelta(hours=6)).isoformat(),
Expand Down
4 changes: 3 additions & 1 deletion src/penn_chime/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(
infectious_days: int = 14,
market_share: float = 1.0,
max_y_axis: Optional[int] = None,
max_y_axis_set: bool = False,
n_days: int = 100,
population: Optional[int] = None,
recovered: int = 0,
Expand Down Expand Up @@ -112,9 +113,10 @@ def __init__(
self.infectious_days = StrictlyPositive(value=infectious_days)
self.market_share = Rate(value=market_share)
self.max_y_axis = OptionalStrictlyPositive(value=max_y_axis)
self.max_y_axis_set = max_y_axis_set
self.n_days = StrictlyPositive(value=n_days)
self.recovered = Positive(value=recovered)

self.author = author
self.scenario = scenario

Expand Down
25 changes: 19 additions & 6 deletions src/penn_chime/presentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,20 @@ def display_sidebar(st, d: Parameters) -> Parameters:
"### Spread and Contact Parameters"
)


# parameter.first_hospitalized_date_known = st.sidebar.checkbox("Set the Y-axis on graphs to a static value", value=max_y_axis_set_default)

first_hospitalized_date_known_default = False if uploaded_file is None else d.first_hospitalized_date_known

if st.sidebar.checkbox(
"I know the date of the first hospitalized case."
"I know the date of the first hospitalized case.", value=first_hospitalized_date_known_default
):
date_first_hospitalized = date_first_hospitalized_input()
first_hospitalized_date_known = True
doubling_time = None
else:
doubling_time = doubling_time_input()
first_hospitalized_date_known = False
date_first_hospitalized = None

relative_contact_rate = relative_contact_pct_input()
Expand All @@ -395,12 +402,17 @@ def display_sidebar(st, d: Parameters) -> Parameters:
"### Display Parameters"
)
n_days = n_days_input()
max_y_axis_set = max_y_axis_set_input()

max_y_axis = None

max_y_axis_set_default = False if uploaded_file is None else d.max_y_axis_set
max_y_axis_set = st.sidebar.checkbox("Set the Y-axis on graphs to a static value", value=max_y_axis_set_default)
max_y_axis = 500 if uploaded_file is None else d.max_y_axis
if max_y_axis_set:
max_y_axis = max_y_axis_input()

max_y_axis = st.sidebar.number_input(
"Y-axis static value",
value=max_y_axis,
format="%i",
step=25,
)

parameters = Parameters(
covid_census_value=covid_census_value,
Expand All @@ -422,6 +434,7 @@ def display_sidebar(st, d: Parameters) -> Parameters:
population=population,
author=author,
scenario=scenario,
first_hospitalized_date_known=first_hospitalized_date_known,
)

param_download_widget(
Expand Down

0 comments on commit ac62cf6

Please sign in to comment.