Skip to content

Commit

Permalink
deal with None cases
Browse files Browse the repository at this point in the history
  • Loading branch information
pearsonca committed Oct 11, 2024
1 parent 032071c commit d00b97a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions flepimop/gempyor_pkg/src/gempyor/model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(

# SEIR modifiers
self.npi_config_seir = None
if config["seir_modifiers"].exists():
if config["seir_modifiers"].exists() and self.seir_modifiers_scenario is not None:
if config["seir_modifiers"]["scenarios"].exists():
self.npi_config_seir = config["seir_modifiers"]["modifiers"][seir_modifiers_scenario]
self.seir_modifiers_library = config["seir_modifiers"]["modifiers"].get()
Expand All @@ -165,7 +165,7 @@ def __init__(
self.outcomes_config = config["outcomes"] if config["outcomes"].exists() else None
if self.outcomes_config is not None:
self.npi_config_outcomes = None
if config["outcome_modifiers"].exists():
if config["outcome_modifiers"].exists() and self.outcome_modifiers_scenario is not None:
if config["outcome_modifiers"]["scenarios"].exists():
self.npi_config_outcomes = config["outcome_modifiers"]["modifiers"][self.outcome_modifiers_scenario]
self.outcome_modifiers_library = config["outcome_modifiers"]["modifiers"].get()
Expand Down
11 changes: 8 additions & 3 deletions flepimop/gempyor_pkg/src/gempyor/shared_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,20 @@ def parse_config_files(
if seir_modifiers_scenarios:
config["seir_modifiers"]["scenarios"] = seir_modifiers_scenarios
else:
config["seir_modifiers"] = {"scenarios": as_list(seir_modifiers_scenarios)}
if seir_modifiers_scenarios:
config["seir_modifiers"] = {"scenarios": as_list(seir_modifiers_scenarios)}
else:
config["seir_modifiers"] = {"scenarios": [None]}


if config["outcome_modifiers"].exists():
if outcome_modifiers_scenarios:
config["outcome_modifiers"]["scenarios"] = outcome_modifiers_scenarios
else:
config["outcome_modifiers"] = {"scenarios": as_list(outcome_modifiers_scenarios)}

if outcome_modifiers_scenarios:
config["outcome_modifiers"] = {"scenarios": as_list(outcome_modifiers_scenarios)}
else:
config["outcome_modifiers"] = {"scenarios": [None]}
if nslots:
config["nslots"] = nslots

Expand Down
5 changes: 2 additions & 3 deletions flepimop/gempyor_pkg/src/gempyor/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ def simulate(
"""Forward simulate a model"""
largs = locals()
parse_config_files(**largs)
print(config.dump())

print(outcome_modifiers_scenarios, seir_modifiers_scenarios)
outcome_modifiers_scenarios = config["outcome_modifiers"]["scenarios"].as_str_seq()
seir_modifiers_scenarios = config["seir_modifiers"]["scenarios"].as_str_seq()
outcome_modifiers_scenarios = config["outcome_modifiers"]["scenarios"].get()
seir_modifiers_scenarios = config["seir_modifiers"]["scenarios"].get()
print(outcome_modifiers_scenarios, seir_modifiers_scenarios)

scenarios_combinations = [[s, d] for s in seir_modifiers_scenarios for d in outcome_modifiers_scenarios]
Expand Down

0 comments on commit d00b97a

Please sign in to comment.