Skip to content

Commit

Permalink
Showing message for when vaccinations finish, minor validation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BlankTiger committed Jun 7, 2022
1 parent c3e06e6 commit 5771b6c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 17 additions & 1 deletion model.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def show_param_window():
validate_params_vac(vac_parameters)
except ValueError:
sg.popup_error(
"Vaccination eff must be a value between 0 and 1, rate, start and end parameters must all be non negative, whole numbers.",
"Vaccination eff must be a value between 0 and 1, rate, start and end parameters must all be non negative, whole numbers. Start parameter must also be less than or equal to the end parameter for all age groups.",
title="Invalid vaccination parameters",
icon=icon,
)
Expand Down Expand Up @@ -584,6 +584,22 @@ while True:
fig_agg = draw_fig(
window["-CANVAS-"].TKCanvas, fig, window["-TOOLBAR-"].TKCanvas
)
msg = ""
for k, v in vac_parameters.items():
if k != "eff" and vac_E and v[0]:
indexes = np.where(
y[
1,
np.searchsorted(t, v[1]) : np.searchsorted(t, v[2]),
int(k[-1]) - 1,
]
== 0
)
if indexes[0].size > 0:
first_zero = t[indexes[0][0]]
msg += f"Age group {k[-1]} fully vaccinated on day: {int(first_zero+v[1])}\n"
if msg:
sg.popup_ok(msg, title="Vaccination", icon=icon)
except ValueError as e:
sg.popup_error(
"Invalid parameters: " + str(e), title="Invalid parameters", icon=icon
Expand Down
4 changes: 4 additions & 0 deletions utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def validate_params_vac(vac_params):
raise ValueError(
"All values like vaccination rate, start day, end day must be positive integers."
)
if vac_params[grp][1] > vac_params[grp][2]:
raise ValueError(
"Start day must be less than or equal to end day for all age groups."
)
if vac_params[grp][0] < 0 or vac_params[grp][1] < 0 or vac_params[grp][2] < 0:
raise ValueError(
"All values like vaccination rate, start day, end day must be positive numbers."
Expand Down

0 comments on commit 5771b6c

Please sign in to comment.