@@ -177,8 +177,8 @@ def load_metadata(
177177
178178
179179def load_categorical_paf (
180- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
181- ) -> pd .DataFrame :
180+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
181+ ) -> pd .DataFrame :
182182 try :
183183 risk = {
184184 # todo add keys as needed
@@ -216,12 +216,14 @@ def load_categorical_paf(
216216
217217
218218def get_pregnancy_end_incidence (
219- location : str , years : Optional [Union [int , str , List [int ]]] = None
220- ) -> pd .DataFrame :
219+ location : str , years : Optional [Union [int , str , List [int ]]] = None
220+ ) -> pd .DataFrame :
221221 asfr = get_data (data_keys .PREGNANCY .ASFR , location , years )
222222 sbr = get_data (data_keys .PREGNANCY .SBR , location , years )
223223 sbr = sbr .reset_index (level = "year_end" , drop = True ).reindex (asfr .index , level = "year_start" )
224- incidence_c995 = get_data (data_keys .PREGNANCY .RAW_INCIDENCE_RATE_MISCARRIAGE , location , years )
224+ incidence_c995 = get_data (
225+ data_keys .PREGNANCY .RAW_INCIDENCE_RATE_MISCARRIAGE , location , years
226+ )
225227 incidence_c374 = get_data (data_keys .PREGNANCY .RAW_INCIDENCE_RATE_ECTOPIC , location , years )
226228 pregnancy_end_rate = (
227229 asfr + asfr .multiply (sbr ["value" ], axis = 0 ) + incidence_c995 + incidence_c374
@@ -230,8 +232,8 @@ def get_pregnancy_end_incidence(
230232
231233
232234def load_asfr (
233- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
234- ) -> pd .DataFrame :
235+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
236+ ) -> pd .DataFrame :
235237 asfr = load_standard_data (key , location , years )
236238 asfr = asfr .reset_index ()
237239 asfr_pivot = asfr .pivot (
@@ -286,17 +288,17 @@ def load_lbwsg_exposure(
286288
287289
288290def load_maternal_csmr (
289- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
290- ) -> pd .DataFrame :
291+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
292+ ) -> pd .DataFrame :
291293 key = EntityKey (key )
292294 entity = get_entity (key )
293295 entity .restrictions .yll_age_group_id_end = 15
294296 return interface .get_measure (entity , key .measure , location , years ).droplevel ("location" )
295297
296298
297299def load_maternal_disorders_ylds (
298- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
299- ) -> pd .DataFrame :
300+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
301+ ) -> pd .DataFrame :
300302 groupby_cols = ["age_group_id" , "sex_id" , "year_id" ]
301303 draw_cols = vi_globals .DRAW_COLUMNS
302304
@@ -329,9 +331,11 @@ def load_maternal_disorders_ylds(
329331
330332
331333def load_pregnant_maternal_disorders_incidence (
332- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
333- ) -> pd .DataFrame :
334- total_incidence = get_data (data_keys .MATERNAL_DISORDERS .RAW_INCIDENCE_RATE , location , years )
334+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
335+ ) -> pd .DataFrame :
336+ total_incidence = get_data (
337+ data_keys .MATERNAL_DISORDERS .RAW_INCIDENCE_RATE , location , years
338+ )
335339 pregnancy_end_rate = get_pregnancy_end_incidence (location , years )
336340 maternal_disorders_incidence = total_incidence / pregnancy_end_rate
337341 ## We have to normalize, since this comes to a probability with some values > 1
@@ -342,17 +346,19 @@ def load_pregnant_maternal_disorders_incidence(
342346
343347
344348def load_maternal_disorders_mortality_probability (
345- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
346- ) -> pd .DataFrame :
349+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
350+ ) -> pd .DataFrame :
347351 total_csmr = get_data (data_keys .MATERNAL_DISORDERS .CSMR , location , years )
348- total_incidence = get_data (data_keys .MATERNAL_DISORDERS .RAW_INCIDENCE_RATE , location , years )
352+ total_incidence = get_data (
353+ data_keys .MATERNAL_DISORDERS .RAW_INCIDENCE_RATE , location , years
354+ )
349355 mortality_probability = total_csmr / total_incidence
350356 return mortality_probability .fillna (0 )
351357
352358
353359def load_pregnant_maternal_hemorrhage_incidence (
354- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
355- ) -> pd .DataFrame :
360+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
361+ ) -> pd .DataFrame :
356362 mh_incidence = get_data (data_keys .MATERNAL_HEMORRHAGE .RAW_INCIDENCE_RATE , location , years )
357363 mh_csmr = get_data (data_keys .MATERNAL_HEMORRHAGE .CSMR , location , years )
358364 pregnancy_end_rate = get_pregnancy_end_incidence (location , years )
@@ -365,8 +371,8 @@ def load_pregnant_maternal_hemorrhage_incidence(
365371
366372
367373def load_hemoglobin_maternal_hemorrhage_rr (
368- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
369- ) -> pd .DataFrame :
374+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
375+ ) -> pd .DataFrame :
370376 if key != data_keys .MATERNAL_HEMORRHAGE .RR_ATTRIBUTABLE_TO_HEMOGLOBIN :
371377 raise ValueError (f"Unrecognized key { key } " )
372378
@@ -388,21 +394,23 @@ def load_hemoglobin_maternal_hemorrhage_rr(
388394
389395
390396def load_hemoglobin_maternal_hemorrhage_paf (
391- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
392- ) -> pd .DataFrame :
397+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
398+ ) -> pd .DataFrame :
393399 if key != data_keys .MATERNAL_HEMORRHAGE .PAF_ATTRIBUTABLE_TO_HEMOGLOBIN :
394400 raise ValueError (f"Unrecognized key { key } " )
395401
396- rr = get_data (data_keys .MATERNAL_HEMORRHAGE .RR_ATTRIBUTABLE_TO_HEMOGLOBIN , location , years )
402+ rr = get_data (
403+ data_keys .MATERNAL_HEMORRHAGE .RR_ATTRIBUTABLE_TO_HEMOGLOBIN , location , years
404+ )
397405 proportion = get_data (
398406 data_keys .HEMOGLOBIN .PREGNANT_PROPORTION_WITH_HEMOGLOBIN_BELOW_70 , location , years
399407 )
400408 return (rr * proportion + (1 - proportion ) - 1 ) / (rr * proportion + (1 - proportion ))
401409
402410
403411def load_hemoglobin_maternal_disorders_rr (
404- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
405- ) -> pd .DataFrame :
412+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
413+ ) -> pd .DataFrame :
406414 if key != data_keys .MATERNAL_DISORDERS .RR_ATTRIBUTABLE_TO_HEMOGLOBIN :
407415 raise ValueError (f"Unrecognized key { key } " )
408416
@@ -415,8 +423,8 @@ def load_hemoglobin_maternal_disorders_rr(
415423
416424
417425def load_hemoglobin_maternal_disorders_paf (
418- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
419- ) -> pd .DataFrame :
426+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
427+ ) -> pd .DataFrame :
420428 location_id = utility_data .get_location_id (location )
421429 demography = get_data (data_keys .POPULATION .DEMOGRAPHY , location , years )
422430
@@ -433,8 +441,8 @@ def load_hemoglobin_maternal_disorders_paf(
433441
434442
435443def get_moderate_hemorrhage_probability (
436- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
437- ) -> pd .DataFrame :
444+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
445+ ) -> pd .DataFrame :
438446 hemorrhage_dist_params = data_values .PROBABILITY_MODERATE_MATERNAL_HEMORRHAGE
439447 # Clip a bit higher than zero to avoid underflow error
440448 dist = sampling .get_truncnorm_from_quantiles (* hemorrhage_dist_params , lower_clip = 0.1 )
@@ -456,8 +464,8 @@ def get_moderate_hemorrhage_probability(
456464
457465
458466def load_background_morbidity (
459- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
460- ) -> pd .DataFrame :
467+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
468+ ) -> pd .DataFrame :
461469 all_cause_yld_rate = extra_gbd .get_all_cause_yld_rate (location )
462470 all_cause_yld_rate = all_cause_yld_rate [
463471 vi_globals .DEMOGRAPHIC_COLUMNS + vi_globals .DRAW_COLUMNS
@@ -521,8 +529,8 @@ def get_hemoglobin_data(
521529
522530
523531def get_hemoglobin_csv_data (
524- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
525- ) -> pd .DataFrame :
532+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
533+ ) -> pd .DataFrame :
526534 location_id = utility_data .get_location_id (location )
527535 demography = get_data (data_keys .POPULATION .DEMOGRAPHY , location , years )
528536
@@ -543,8 +551,8 @@ def get_hemoglobin_csv_data(
543551
544552
545553def load_bmi_prevalence (
546- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
547- ) -> pd .DataFrame :
554+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
555+ ) -> pd .DataFrame :
548556 location_id = utility_data .get_location_id (location )
549557 demography = get_data (data_keys .POPULATION .DEMOGRAPHY , location , years )
550558
@@ -576,8 +584,8 @@ def load_bmi_prevalence(
576584
577585
578586def load_ifa_coverage (
579- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
580- ) -> pd .DataFrame :
587+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
588+ ) -> pd .DataFrame :
581589 df = pd .read_csv (
582590 paths .CSV_RAW_DATA_ROOT / "baseline_ifa_coverage" / (location + ".csv" ), index_col = 0
583591 )
@@ -586,8 +594,8 @@ def load_ifa_coverage(
586594
587595
588596def load_ifa_effect_size (
589- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
590- ) -> pd .DataFrame :
597+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
598+ ) -> pd .DataFrame :
591599 loc , scale = data_values .IFA_EFFECT_SIZE
592600 dist = stats .norm (loc , scale )
593601 rng = np .random .default_rng (get_hash (f"ifa_effect_size_{ location } " ))
@@ -601,8 +609,8 @@ def load_ifa_effect_size(
601609
602610
603611def load_supplementation_stillbirth_rr (
604- key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
605- ) -> pd .DataFrame :
612+ key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
613+ ) -> pd .DataFrame :
606614 try :
607615 distribution = data_values .INTERVENTION_STILLBIRTH_RRS [key ]
608616 except KeyError :
0 commit comments