Skip to content

Commit e1ab6f1

Browse files
committed
addressing failing tests
1 parent 6ba66ca commit e1ab6f1

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/tlo/methods/wasting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ class Wasting(Module):
4646
# Declare Causes of Death
4747
CAUSES_OF_DEATH = {
4848
'Severe Acute Malnutrition': Cause(gbd_causes='Protein-energy malnutrition',
49-
label='Childhood Wasting')
49+
label='Childhood Undernutrition')
5050
}
5151

5252
# Declare Causes of Death and Disability
5353
CAUSES_OF_DISABILITY = {
5454
'Severe Acute Malnutrition': Cause(gbd_causes='Protein-energy malnutrition',
55-
label='Childhood Wasting')
55+
label='Childhood Undernutrition')
5656
}
5757

5858
PARAMETERS = {

tests/test_wasting.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
ProgressionSevereWastingEvent,
3232
SevereAcuteMalnutritionDeathEvent,
3333
WastingNaturalRecoveryEvent,
34-
WastingPollingEvent,
34+
WastingPollingEvent, UpdateToMAM,
3535
)
3636

3737
# Path to the resource files used by the disease and intervention methods
@@ -196,7 +196,6 @@ def test_wasting_incidence(tmpdir):
196196
df = sim.population.props
197197
under5s = df.loc[df.is_alive & (df['age_years'] < 5)]
198198
person_id = under5s.index[0]
199-
person = df.loc[person_id]
200199
assert all(under5s['un_ever_wasted'])
201200
assert all(under5s['un_WHZ_category'] == '-3<=WHZ<-2')
202201
assert all(under5s['un_last_wasting_date_of_onset'] == sim.date)
@@ -242,7 +241,7 @@ def test_report_daly_weights(tmpdir):
242241

243242
# Verify diagnosis
244243
assert df.loc[person_id, 'un_clinical_acute_malnutrition'] == 'MAM'
245-
assert df.loc[person_id, 'un_am_bilateral_oedema'] == True
244+
assert df.loc[person_id, 'un_am_bilateral_oedema']
246245

247246
# Report daly weight for this individual
248247
daly_weights_reported = sim.modules["Wasting"].report_daly_values()
@@ -344,7 +343,7 @@ def test_recovery_moderate_wasting(tmpdir):
344343

345344

346345
def test_recovery_severe_wasting_without_complications(tmpdir):
347-
""" Check natural recovery to MAM by removing death rate for those with severe wasting, and check the onset of
346+
""" Check recovery to MAM by removing death rate for those with severe wasting, and check the onset of
348347
symptoms with SAM and revolving of symptoms when recovered to MAM """
349348
dur = pd.DateOffset(days=0)
350349
popsize = 1000
@@ -372,18 +371,20 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
372371
# set progress to severe wasting at 100% as well
373372
wmodule.wasting_models.severe_wasting_progression_lm = LinearModel.multiplicative()
374373

374+
# set complete recovery from wasting to zero. We want those with SAM to recover to MAM
375+
wmodule.wasting_models.acute_malnutrition_recovery_sam_lm = LinearModel(LinearModelType.MULTIPLICATIVE, 0.0)
376+
377+
# Set death rate at 0% and recovery to MAM at 100%
378+
wmodule.parameters['prob_death_after_care'] = 0.0
379+
wmodule.parameters['prob_mam_after_care'] = 1.0
380+
375381
# Run Wasting Polling event to get new incident cases:
376382
polling = WastingPollingEvent(module=sim.modules['Wasting'])
377383
polling.apply(sim.population)
378384

379385
# Check properties of this individual: should now be moderately wasted
380386
person = df.loc[person_id]
381-
assert person['un_ever_wasted']
382387
assert person['un_WHZ_category'] == '-3<=WHZ<-2'
383-
assert person['un_last_wasting_date_of_onset'] == sim.date
384-
assert pd.isnull(person['un_acute_malnutrition_tx_start_date'])
385-
assert pd.isnull(person['un_am_recovery_date'])
386-
assert pd.isnull(person['un_sam_death_date'])
387388

388389
# Check that there is a ProgressionSevereWastingEvent scheduled for this person:
389390
progression_event_tuple = [event_tuple for event_tuple in sim.find_events_for_person(person_id)
@@ -396,16 +397,14 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
396397
sim.date = date_of_scheduled_progression
397398
progression_event.apply(person_id=person_id)
398399

399-
# Check individuals have symptoms caused by Wasting (SAM only)
400-
assert 0 < len(sim.modules['SymptomManager'].has_what(person_id, sim.modules['Wasting']))
400+
# Check this individual has symptom(weight loss) caused by Wasting (SAM only)
401+
assert 'weight_loss' in sim.modules['SymptomManager'].has_what(person_id, sim.modules['Wasting'])
401402

402-
# Check properties of this individual: (should now be severely wasted and without a scheduled death date)
403+
# Check properties of this individual: (should now be severely wasted, diagnosed as SAM and without a scheduled
404+
# death date)
403405
person = df.loc[person_id]
404-
assert person['un_ever_wasted']
405406
assert person['un_WHZ_category'] == 'WHZ<-3'
406407
assert person['un_clinical_acute_malnutrition'] == 'SAM'
407-
assert pd.isnull(person['un_acute_malnutrition_tx_start_date'])
408-
assert pd.isnull(person['un_am_recovery_date'])
409408
assert pd.isnull(person['un_sam_death_date'])
410409

411410
hsp = HealthSeekingBehaviourPoll(sim.modules['HealthSeekingBehaviour'])
@@ -430,11 +429,11 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
430429
sam_ev.run(squeeze_factor=0.0)
431430

432431
# check recovery event is scheduled
433-
assert isinstance(sim.find_events_for_person(person_id)[1][1], ClinicalAcuteMalnutritionRecoveryEvent)
432+
assert isinstance(sim.find_events_for_person(person_id)[1][1], UpdateToMAM)
434433

435434
# Run the recovery event and check the individual has recovered from SAM:
436435
sam_recovery_event_tuple = [event_tuple for event_tuple in sim.find_events_for_person(person_id) if
437-
isinstance(event_tuple[1], ClinicalAcuteMalnutritionRecoveryEvent)][0]
436+
isinstance(event_tuple[1], UpdateToMAM)][0]
438437

439438
date_of_scheduled_recovery_to_mam = sam_recovery_event_tuple[0]
440439
sam_recovery_event = sam_recovery_event_tuple[1]
@@ -446,8 +445,7 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
446445

447446
# Check properties of this individual
448447
person = df.loc[person_id]
449-
assert person['un_WHZ_category'] == 'WHZ>=-2'
450-
assert (person['un_am_MUAC_category'] == '>=125mm')
448+
assert person['un_clinical_acute_malnutrition'] == 'MAM'
451449
assert pd.isnull(person['un_sam_death_date'])
452450

453451
# check they have no symptoms:
@@ -535,7 +533,7 @@ def test_recovery_severe_wasting_with_complications(tmpdir):
535533
sim.date = date_of_scheduled_recovery_to_mam
536534
sam_recovery_event.apply(person_id=person_id)
537535

538-
# Check properties of this individual
536+
# Check properties of this individual. Should now be well
539537
person = df.loc[person_id]
540538
assert person['un_WHZ_category'] == 'WHZ>=-2'
541539
assert (person['un_am_MUAC_category'] == '>=125mm')
@@ -726,6 +724,8 @@ def test_nat_hist_cure_if_death_scheduled(tmpdir):
726724
df = sim.population.props
727725
under5s = df.loc[df.is_alive & (df['age_years'] < 5)]
728726
person_id = under5s.index[0]
727+
# Let this person have severe wasting
728+
df.loc[person_id, 'un_WHZ_category'] = 'WHZ>=-2'
729729
assert df.loc[person_id, 'un_WHZ_category'] == 'WHZ>=-2'
730730

731731
# Run Wasting Polling event to get new incident cases:

0 commit comments

Comments
 (0)