Skip to content

Commit

Permalink
Address first round of comments on test for this R
Browse files Browse the repository at this point in the history
  • Loading branch information
marghe-molaro committed Oct 30, 2023
1 parent 045e37b commit e1c758c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/tlo/methods/healthsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,9 @@ def __init__(
# Check that the name of policy being evaluated is included
self.priority_policy = None
if policy_name is not None:
assert policy_name in ['', 'Default', 'Test', 'Random', 'Naive', 'RMNCH',
assert policy_name in ['', 'Default', 'Test', 'Test Mode 1', 'Random', 'Naive', 'RMNCH',
'VerticalProgrammes', 'ClinicallyVulnerable', 'EHP_III',
'LCOA_EHP', 'No Services']
'LCOA_EHP']
self.arg_policy_name = policy_name

self.tclose_overwrite = None
Expand Down
32 changes: 11 additions & 21 deletions tests/test_healthsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ def test_run_no_interventions_allowed(tmpdir, seed):

@pytest.mark.slow
def test_policy_has_no_effect_on_mode1(tmpdir, seed):
# Events ran in mode 1 should be identical regardless of policy assumed.
# In policy "No Services", have set all HSIs to priority below lowest_priority_considered,
# in mode 1 they should all be scheduled and delivered regardless
"""Events ran in mode 1 should be identical regardless of policy assumed.
In policy "No Services", have set all HSIs to priority below lowest_priority_considered,
in mode 1 they should all be scheduled and delivered regardless"""

output = []
for i, policy in enumerate(["Naive", "No Services"]):
for i, policy in enumerate(["Naive", "Test Mode 1"]):
# Establish the simulation object
sim = Simulation(
start_date=start_date,
Expand All @@ -215,19 +215,10 @@ def test_policy_has_no_effect_on_mode1(tmpdir, seed):
)

# Register the core modules
sim.register(demography.Demography(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
capabilities_coefficient=1.0,
mode_appt_constraints=1,
policy_name=policy),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
epi.Epi(resourcefilepath=resourcefilepath),
hiv.Hiv(resourcefilepath=resourcefilepath, run_with_checks=False),
tb.Tb(resourcefilepath=resourcefilepath),
)
sim.register(*fullmodel(resourcefilepath=resourcefilepath,
module_kwargs={'HealthSystem': {'capabilities_coefficient': 1.0,
'mode_appt_constraints': 1,
'policy_name': policy}}))

# Run the simulation
sim.make_initial_population(n=popsize)
Expand All @@ -239,10 +230,9 @@ def test_policy_has_no_effect_on_mode1(tmpdir, seed):
# read the results
output.append(parse_log_file(sim.log_filepath, level=logging.DEBUG))

# Check that the outputs are the same and that all HSIs ran even with policy specifying "No Services"
assert len(output[0]['tlo.methods.healthsystem']['HSI_Event']) == \
len(output[1]['tlo.methods.healthsystem']['HSI_Event'])
assert output[1]['tlo.methods.healthsystem']['HSI_Event']['did_run'].all()
# Check that the outputs are the same
pd.testing.assert_frame_equal(output[0]['tlo.methods.healthsystem']['HSI_Event'],
output[1]['tlo.methods.healthsystem']['HSI_Event'])


@pytest.mark.slow
Expand Down

0 comments on commit e1c758c

Please sign in to comment.