Skip to content

Commit

Permalink
Bug fix compute_all_multioutcomes
Browse files Browse the repository at this point in the history
Added a bug fix to `compute_all_multioutcomes` to look for if a sourced
outcome exists and has not been processed yet and if so skip that
outcome for now and re-add it to the end of the outcomes to process.
Required for the `test_outcomes_pcomp` and
`test_outcomes_pcomp_read_write` tests to pass. Also minor edits to
`config_mc_selection.yml` to add the required 'compartments'/'seir'
sections.
  • Loading branch information
TimothyWillard committed Nov 21, 2024
1 parent 0c1bb46 commit e3cb537
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
6 changes: 5 additions & 1 deletion flepimop/gempyor_pkg/src/gempyor/outcomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def compute_all_multioutcomes(
else:
seir_sim = bypass_seir_df

for new_comp in parameters:
parameters_keys = list(parameters.keys())
for new_comp in parameters_keys:
if "source" in parameters[new_comp]:
# Read the config for this compartment: if a source is specified, we
# 1. compute incidence from binomial draw
Expand Down Expand Up @@ -400,6 +401,9 @@ def compute_all_multioutcomes(
else: # already defined outcomes
if source_name in all_data:
source_array = all_data[source_name]
elif source_name in parameters_keys:
parameters_keys.append(new_comp)
continue
else:
raise ValueError(
f"ERROR with outcome {new_comp}: the specified source {source_name} is not a dictionnary (for seir outcome) nor an existing pre-identified outcomes."
Expand Down
45 changes: 45 additions & 0 deletions flepimop/gempyor_pkg/tests/outcomes/config_mc_selection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,51 @@ subpop_setup:
geodata: data/geodata.csv


compartments:
infection_stage:
- S
- I1
- R
vaccination_stage:
- unvaccinated
- first_dose


seir:
integration:
method: rk4
dt: 1
transitions:
- source: [
["S"],
["unvaccinated", "first_dose"]
]
destination: [
["I1"],
["unvaccinated", "first_dose"]
]
proportional_to: [
"source",
[
[
["I1"]
],
[
["unvaccinated", "first_dose"],
["unvaccinated"],
],
]
]
rate: [
[0.85],
[1, 0.5]
]
proportion_exponent: [
[1, [1, 1]],
[1, [1, 1]]
]


outcomes:
method: delayframe
param_from_file: False
Expand Down

0 comments on commit e3cb537

Please sign in to comment.