vivarium-public-health 2.3.2__py3-none-any.whl → 3.0.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. vivarium_public_health/_version.py +1 -1
  2. vivarium_public_health/disease/model.py +23 -21
  3. vivarium_public_health/disease/models.py +1 -0
  4. vivarium_public_health/disease/special_disease.py +40 -41
  5. vivarium_public_health/disease/state.py +42 -125
  6. vivarium_public_health/disease/transition.py +70 -27
  7. vivarium_public_health/mslt/delay.py +1 -0
  8. vivarium_public_health/mslt/disease.py +1 -0
  9. vivarium_public_health/mslt/intervention.py +1 -0
  10. vivarium_public_health/mslt/magic_wand_components.py +1 -0
  11. vivarium_public_health/mslt/observer.py +1 -0
  12. vivarium_public_health/mslt/population.py +1 -0
  13. vivarium_public_health/plugins/parser.py +61 -31
  14. vivarium_public_health/population/add_new_birth_cohorts.py +2 -3
  15. vivarium_public_health/population/base_population.py +2 -1
  16. vivarium_public_health/population/mortality.py +83 -80
  17. vivarium_public_health/{metrics → results}/__init__.py +2 -0
  18. vivarium_public_health/results/columns.py +22 -0
  19. vivarium_public_health/results/disability.py +187 -0
  20. vivarium_public_health/results/disease.py +222 -0
  21. vivarium_public_health/results/mortality.py +186 -0
  22. vivarium_public_health/results/observer.py +78 -0
  23. vivarium_public_health/results/risk.py +138 -0
  24. vivarium_public_health/results/simple_cause.py +18 -0
  25. vivarium_public_health/{metrics → results}/stratification.py +10 -8
  26. vivarium_public_health/risks/__init__.py +1 -2
  27. vivarium_public_health/risks/base_risk.py +134 -29
  28. vivarium_public_health/risks/data_transformations.py +65 -326
  29. vivarium_public_health/risks/distributions.py +315 -145
  30. vivarium_public_health/risks/effect.py +376 -75
  31. vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py +61 -89
  32. vivarium_public_health/treatment/magic_wand.py +1 -0
  33. vivarium_public_health/treatment/scale_up.py +1 -0
  34. vivarium_public_health/treatment/therapeutic_inertia.py +1 -0
  35. vivarium_public_health/utilities.py +17 -2
  36. {vivarium_public_health-2.3.2.dist-info → vivarium_public_health-3.0.0.dist-info}/METADATA +13 -3
  37. vivarium_public_health-3.0.0.dist-info/RECORD +49 -0
  38. {vivarium_public_health-2.3.2.dist-info → vivarium_public_health-3.0.0.dist-info}/WHEEL +1 -1
  39. vivarium_public_health/metrics/disability.py +0 -118
  40. vivarium_public_health/metrics/disease.py +0 -136
  41. vivarium_public_health/metrics/mortality.py +0 -144
  42. vivarium_public_health/metrics/risk.py +0 -110
  43. vivarium_public_health/testing/__init__.py +0 -0
  44. vivarium_public_health/testing/mock_artifact.py +0 -145
  45. vivarium_public_health/testing/utils.py +0 -71
  46. vivarium_public_health-2.3.2.dist-info/RECORD +0 -49
  47. {vivarium_public_health-2.3.2.dist-info → vivarium_public_health-3.0.0.dist-info}/LICENSE.txt +0 -0
  48. {vivarium_public_health-2.3.2.dist-info → vivarium_public_health-3.0.0.dist-info}/top_level.txt +0 -0
@@ -6,24 +6,21 @@ Low Birth Weight and Short Gestation
6
6
  Low birth weight and short gestation (LBWSG) is a non-standard risk
7
7
  implementation that has been used in several public health models.
8
8
  """
9
+
9
10
  import pickle
10
- from typing import Callable, Dict, List, Optional
11
+ from typing import Any, Callable, Dict, List, Optional, Tuple
11
12
 
12
13
  import numpy as np
13
14
  import pandas as pd
14
15
  from vivarium.framework.engine import Builder
15
16
  from vivarium.framework.lifecycle import LifeCycleError
16
- from vivarium.framework.lookup import LookupTable
17
17
  from vivarium.framework.population import SimulantData
18
18
  from vivarium.framework.values import Pipeline
19
19
 
20
20
  from vivarium_public_health.risks import Risk, RiskEffect
21
- from vivarium_public_health.risks.data_transformations import (
22
- get_exposure_data,
23
- get_exposure_post_processor,
24
- )
21
+ from vivarium_public_health.risks.data_transformations import get_exposure_post_processor
25
22
  from vivarium_public_health.risks.distributions import PolytomousDistribution
26
- from vivarium_public_health.utilities import EntityString, to_snake_case
23
+ from vivarium_public_health.utilities import get_lookup_columns, to_snake_case
27
24
 
28
25
  CATEGORICAL = "categorical"
29
26
  BIRTH_WEIGHT = "birth_weight"
@@ -31,63 +28,16 @@ GESTATIONAL_AGE = "gestational_age"
31
28
 
32
29
 
33
30
  class LBWSGDistribution(PolytomousDistribution):
34
- CONFIGURATION_DEFAULTS = {
35
- "lbwsg_distribution": {
36
- "age_column": "age",
37
- "sex_column": "sex",
38
- "year_column": "year",
39
- }
40
- }
41
-
42
- #####################
43
- # Lifecycle methods #
44
- #####################
45
31
 
46
- def __init__(self, exposure_data: pd.DataFrame = None):
47
- super().__init__(
48
- EntityString("risk_factor.low_birth_weight_and_short_gestation"), exposure_data
49
- )
32
+ #################
33
+ # Setup methods #
34
+ #################
50
35
 
51
36
  # noinspection PyAttributeOutsideInit
52
37
  def setup(self, builder: Builder) -> None:
53
- self.config = builder.configuration.lbwsg_distribution
54
- self._exposure_data = self.get_exposure_data(builder)
55
-
56
38
  super().setup(builder)
57
39
  self.category_intervals = self.get_category_intervals(builder)
58
40
 
59
- #################
60
- # Setup methods #
61
- #################
62
-
63
- def get_exposure_data(self, builder: Builder) -> pd.DataFrame:
64
- if self._exposure_data is None:
65
- self._exposure_data = get_exposure_data(builder, self.risk)
66
-
67
- return self._exposure_data.rename(
68
- columns={
69
- "sex": self.config.sex_column,
70
- "age_start": f"{self.config.age_column}_start",
71
- "age_end": f"{self.config.age_column}_end",
72
- "year_start": f"{self.config.year_column}_start",
73
- "year_end": f"{self.config.year_column}_end",
74
- }
75
- )
76
-
77
- def get_exposure_parameters(self, builder: Builder) -> Pipeline:
78
- return builder.value.register_value_producer(
79
- self.exposure_parameters_pipeline_name,
80
- source=builder.lookup.build_table(
81
- self._exposure_data,
82
- key_columns=[self.config.sex_column],
83
- parameter_columns=[self.config.age_column, self.config.year_column],
84
- ),
85
- requires_columns=[
86
- self.config.sex_column,
87
- self.config.age_column,
88
- ],
89
- )
90
-
91
41
  def get_category_intervals(self, builder: Builder) -> Dict[str, Dict[str, pd.Interval]]:
92
42
  """
93
43
  Gets the intervals for each category. It is a dictionary from the string
@@ -96,7 +46,7 @@ class LBWSGDistribution(PolytomousDistribution):
96
46
  :param builder:
97
47
  :return:
98
48
  """
99
- categories = builder.data.load(f"{self.risk}.categories")
49
+ categories: Dict[str, str] = builder.data.load(f"{self.risk}.categories")
100
50
  category_intervals = {
101
51
  axis: {
102
52
  category: self._parse_description(axis, description)
@@ -160,8 +110,8 @@ class LBWSGDistribution(PolytomousDistribution):
160
110
 
161
111
  if (categorical_propensity is None) == (categorical_exposure is None):
162
112
  raise ValueError(
163
- "Either categorical propensity of categorical exposure may be provided, but not"
164
- " both or neither."
113
+ "Exactly one of categorical propensity or categorical exposure "
114
+ "must be provided."
165
115
  )
166
116
 
167
117
  if categorical_exposure is None:
@@ -185,17 +135,26 @@ class LBWSGDistribution(PolytomousDistribution):
185
135
  def _parse_description(axis: str, description: str) -> pd.Interval:
186
136
  """
187
137
  Parses a string corresponding to a low birth weight and short gestation
188
- category to an Interval
138
+ category to an Interval.
139
+ An example of a standard description:
140
+ 'Neonatal preterm and LBWSG (estimation years) - [0, 24) wks, [0, 500) g'
141
+ An example of an edge case for gestational age:
142
+ 'Neonatal preterm and LBWSG (estimation years) - [40, 42+] wks, [2000, 2500) g'
143
+ An example of an edge case of birth weight:
144
+ 'Neonatal preterm and LBWSG (estimation years) - [36, 37) wks, [4000, 9999] g'
145
+
189
146
  :param axis:
190
147
  :param description:
191
148
  :return:
192
149
  """
193
150
  endpoints = {
194
151
  BIRTH_WEIGHT: [
195
- float(val) for val in description.split(", [")[1].split(")")[0].split(", ")
152
+ float(val)
153
+ for val in description.split(", [")[1].split(")")[0].split("]")[0].split(", ")
196
154
  ],
197
155
  GESTATIONAL_AGE: [
198
- float(val) for val in description.split("- [")[1].split(")")[0].split(", ")
156
+ float(val)
157
+ for val in description.split("- [")[1].split(")")[0].split("+")[0].split(", ")
199
158
  ],
200
159
  }[axis]
201
160
  return pd.Interval(*endpoints, closed="left") # noqa
@@ -204,6 +163,8 @@ class LBWSGDistribution(PolytomousDistribution):
204
163
  class LBWSGRisk(Risk):
205
164
  AXES = [BIRTH_WEIGHT, GESTATIONAL_AGE]
206
165
 
166
+ exposure_distributions = {"lbwsg": LBWSGDistribution}
167
+
207
168
  @staticmethod
208
169
  def birth_exposure_pipeline_name(axis: str) -> str:
209
170
  return f"{axis}.birth_exposure"
@@ -216,6 +177,12 @@ class LBWSGRisk(Risk):
216
177
  # Properties #
217
178
  ##############
218
179
 
180
+ @property
181
+ def configuration_defaults(self) -> Dict[str, Any]:
182
+ configuration_defaults = super().configuration_defaults
183
+ configuration_defaults[self.name]["distribution_type"] = "lbwsg"
184
+ return configuration_defaults
185
+
219
186
  @property
220
187
  def columns_created(self) -> List[str]:
221
188
  return [self.exposure_column_name(axis) for axis in self.AXES]
@@ -232,13 +199,6 @@ class LBWSGRisk(Risk):
232
199
  super().setup(builder)
233
200
  self.birth_exposures = self.get_birth_exposure_pipelines(builder)
234
201
 
235
- ##########################
236
- # Initialization methods #
237
- ##########################
238
-
239
- def get_exposure_distribution(self) -> LBWSGDistribution:
240
- return LBWSGDistribution()
241
-
242
202
  #################
243
203
  # Setup methods #
244
204
  #################
@@ -252,13 +212,17 @@ class LBWSGRisk(Risk):
252
212
  return None
253
213
 
254
214
  def get_birth_exposure_pipelines(self, builder: Builder) -> Dict[str, Pipeline]:
215
+ required_columns = get_lookup_columns(
216
+ self.exposure_distribution.lookup_tables.values()
217
+ )
218
+
255
219
  def get_pipeline(axis_: str):
256
220
  return builder.value.register_value_producer(
257
221
  self.birth_exposure_pipeline_name(axis_),
258
222
  source=lambda index: self.get_birth_exposure(axis_, index),
259
- requires_columns=["age", "sex"],
223
+ requires_columns=required_columns,
260
224
  requires_streams=[self.randomness_stream_name],
261
- preferred_post_processor=get_exposure_post_processor(builder, self.risk),
225
+ preferred_post_processor=get_exposure_post_processor(builder, self.name),
262
226
  )
263
227
 
264
228
  return {
@@ -307,7 +271,7 @@ class LBWSGRiskEffect(RiskEffect):
307
271
 
308
272
  @property
309
273
  def columns_created(self) -> List[str]:
310
- return self._rr_column_names
274
+ return self.rr_column_names
311
275
 
312
276
  @property
313
277
  def columns_required(self) -> Optional[List[str]]:
@@ -321,6 +285,10 @@ class LBWSGRiskEffect(RiskEffect):
321
285
  "requires_streams": [],
322
286
  }
323
287
 
288
+ @property
289
+ def rr_column_names(self) -> List[str]:
290
+ return [self.relative_risk_column_name(age_group) for age_group in self.age_intervals]
291
+
324
292
  #####################
325
293
  # Lifecycle methods #
326
294
  #####################
@@ -335,7 +303,7 @@ class LBWSGRiskEffect(RiskEffect):
335
303
  f"effect_of_{self.risk.name}_on_{self.target.name}.relative_risk"
336
304
  )
337
305
 
338
- def relative_risk_column_name(self, age_group_id) -> str:
306
+ def relative_risk_column_name(self, age_group_id: str) -> str:
339
307
  return (
340
308
  f"effect_of_{self.risk.name}_on_{age_group_id}_{self.target.name}_relative_risk"
341
309
  )
@@ -343,21 +311,35 @@ class LBWSGRiskEffect(RiskEffect):
343
311
  # noinspection PyAttributeOutsideInit
344
312
  def setup(self, builder: Builder) -> None:
345
313
  self.age_intervals = self.get_age_intervals(builder)
346
- self._rr_column_names = self.get_rr_column_names()
347
314
 
348
315
  super().setup(builder)
349
316
  self.interpolator = self.get_interpolator(builder)
317
+ self.relative_risk = self.get_relative_risk_pipeline(builder)
350
318
 
351
319
  #################
352
320
  # Setup methods #
353
321
  #################
354
322
 
323
+ # noinspection PyAttributeOutsideInit
324
+ def build_all_lookup_tables(self, builder: Builder) -> None:
325
+ paf_data, paf_value_cols = self.get_population_attributable_fraction_source(builder)
326
+ self.lookup_tables["population_attributable_fraction"] = self.build_lookup_table(
327
+ builder, paf_data, paf_value_cols
328
+ )
329
+
355
330
  def get_risk_exposure(self, builder: Builder) -> Callable[[pd.Index], pd.DataFrame]:
356
331
  def exposure(index: pd.Index) -> pd.DataFrame:
357
332
  return self.population_view.subview(self.lbwsg_exposure_column_names).get(index)
358
333
 
359
334
  return exposure
360
335
 
336
+ def get_population_attributable_fraction_source(
337
+ self, builder: Builder
338
+ ) -> Tuple[pd.DataFrame, List[str]]:
339
+ paf_key = f"{self.risk}.population_attributable_fraction"
340
+ paf_data = builder.data.load(paf_key)
341
+ return paf_data, builder.data.value_columns()(paf_key)
342
+
361
343
  def get_target_modifier(
362
344
  self, builder: Builder
363
345
  ) -> Callable[[pd.Index, pd.Series], pd.Series]:
@@ -370,7 +352,7 @@ class LBWSGRiskEffect(RiskEffect):
370
352
  builder.value.register_value_modifier(
371
353
  self.target_pipeline_name,
372
354
  modifier=self.target_modifier,
373
- requires_columns=["age", "sex"],
355
+ requires_values=[self.relative_risk_pipeline_name],
374
356
  )
375
357
 
376
358
  def get_age_intervals(self, builder: Builder) -> Dict[str, pd.Interval]:
@@ -389,21 +371,11 @@ class LBWSGRiskEffect(RiskEffect):
389
371
  for age_start in exposed_age_group_starts
390
372
  }
391
373
 
392
- def get_rr_column_names(self) -> List[str]:
393
- return [self.relative_risk_column_name(age_group) for age_group in self.age_intervals]
394
-
395
- def get_relative_risk_source(self, builder: Builder) -> Pipeline:
374
+ def get_relative_risk_pipeline(self, builder: Builder) -> Pipeline:
396
375
  return builder.value.register_value_producer(
397
376
  self.relative_risk_pipeline_name,
398
377
  source=self.get_relative_risk,
399
- requires_columns=["age"] + self._rr_column_names,
400
- )
401
-
402
- def get_population_attributable_fraction_source(self, builder: Builder) -> LookupTable:
403
- return builder.lookup.build_table(
404
- builder.data.load(f"{self.risk}.population_attributable_fraction"),
405
- key_columns=["sex"],
406
- parameter_columns=["age", "year"],
378
+ requires_columns=["age"] + self.rr_column_names,
407
379
  )
408
380
 
409
381
  def get_interpolator(self, builder: Builder) -> pd.Series:
@@ -448,7 +420,7 @@ class LBWSGRiskEffect(RiskEffect):
448
420
  self.TMREL_BIRTH_WEIGHT_INTERVAL.left <= birth_weight
449
421
  )
450
422
 
451
- def get_relative_risk_for_age_group(age_group: int) -> pd.Series:
423
+ def get_relative_risk_for_age_group(age_group: str) -> pd.Series:
452
424
  column_name = self.relative_risk_column_name(age_group)
453
425
  log_relative_risk = pd.Series(0.0, index=pop_data.index, name=column_name)
454
426
 
@@ -7,6 +7,7 @@ This module contains simple intervention models that work at the population
7
7
  level by providing direct shifts to epidemiological measures.
8
8
 
9
9
  """
10
+
10
11
  from typing import Any, Dict, List, Optional
11
12
 
12
13
  from vivarium import Component
@@ -6,6 +6,7 @@ Linear Scale-Up Model
6
6
  This module contains tools for applying a linear scale-up to an intervention
7
7
 
8
8
  """
9
+
9
10
  from typing import Any, Callable, Dict, Tuple
10
11
 
11
12
  import pandas as pd
@@ -7,6 +7,7 @@ This module contains a model for therapeutic inertia which represents the
7
7
  variety of reasons why a treatment algorithm might deviate from guidelines.
8
8
 
9
9
  """
10
+
10
11
  import pandas as pd
11
12
  import scipy.stats
12
13
  from vivarium import Component
@@ -7,10 +7,12 @@ This module contains utility classes and functions for use across
7
7
  vivarium_public_health components.
8
8
 
9
9
  """
10
- from typing import Iterable, Union
10
+
11
+ from pathlib import Path
12
+ from typing import Any, Dict, Iterable, List, Optional, Union
11
13
 
12
14
  import pandas as pd
13
- from vivarium.framework.lookup import ScalarValue
15
+ from vivarium.framework.lookup import LookupTable, ScalarValue
14
16
 
15
17
 
16
18
  class EntityString(str):
@@ -97,3 +99,16 @@ def is_non_zero(data: Union[Iterable[ScalarValue], ScalarValue, pd.DataFrame]) -
97
99
  attribute_sum = data
98
100
 
99
101
  return attribute_sum != 0.0
102
+
103
+
104
+ def get_lookup_columns(
105
+ lookup_tables: Iterable[LookupTable], necessary_columns: Iterable = ()
106
+ ) -> List[str]:
107
+ necessary_columns = set(necessary_columns)
108
+ for lookup_table in lookup_tables:
109
+ necessary_columns.update(set(lookup_table.key_columns))
110
+ necessary_columns.update(set(lookup_table.parameter_columns))
111
+ if "year" in necessary_columns:
112
+ necessary_columns.remove("year")
113
+
114
+ return list(necessary_columns)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium_public_health
3
- Version: 2.3.2
3
+ Version: 3.0.0
4
4
  Summary: Components for modelling diseases, risks, and interventions with ``vivarium``
5
5
  Home-page: https://github.com/ihmeuw/vivarium_public_health
6
6
  Author: The vivarium developers
@@ -26,31 +26,41 @@ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
26
26
  Classifier: Topic :: Scientific/Engineering :: Physics
27
27
  Classifier: Topic :: Software Development :: Libraries
28
28
  License-File: LICENSE.txt
29
- Requires-Dist: vivarium >=2.0.0
29
+ Requires-Dist: vivarium >=3.0.0
30
+ Requires-Dist: layered-config-tree >=1.0.1
30
31
  Requires-Dist: loguru
31
- Requires-Dist: numpy
32
+ Requires-Dist: numpy <2.0.0
32
33
  Requires-Dist: pandas
33
34
  Requires-Dist: scipy
34
35
  Requires-Dist: tables
35
36
  Requires-Dist: risk-distributions >=2.0.11
37
+ Requires-Dist: pyarrow
36
38
  Provides-Extra: dev
37
39
  Requires-Dist: sphinx <7.0 ; extra == 'dev'
38
40
  Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
39
41
  Requires-Dist: sphinx-click ; extra == 'dev'
42
+ Requires-Dist: sphinx-autodoc-typehints ; extra == 'dev'
40
43
  Requires-Dist: IPython ; extra == 'dev'
41
44
  Requires-Dist: matplotlib ; extra == 'dev'
45
+ Requires-Dist: vivarium-testing-utils ; extra == 'dev'
42
46
  Requires-Dist: pytest ; extra == 'dev'
47
+ Requires-Dist: pytest-cov ; extra == 'dev'
43
48
  Requires-Dist: pytest-mock ; extra == 'dev'
44
49
  Requires-Dist: hypothesis ; extra == 'dev'
45
50
  Requires-Dist: pyyaml ; extra == 'dev'
51
+ Requires-Dist: black ==22.3.0 ; extra == 'dev'
52
+ Requires-Dist: isort ; extra == 'dev'
46
53
  Provides-Extra: docs
47
54
  Requires-Dist: sphinx <7.0 ; extra == 'docs'
48
55
  Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
49
56
  Requires-Dist: sphinx-click ; extra == 'docs'
57
+ Requires-Dist: sphinx-autodoc-typehints ; extra == 'docs'
50
58
  Requires-Dist: IPython ; extra == 'docs'
51
59
  Requires-Dist: matplotlib ; extra == 'docs'
52
60
  Provides-Extra: test
61
+ Requires-Dist: vivarium-testing-utils ; extra == 'test'
53
62
  Requires-Dist: pytest ; extra == 'test'
63
+ Requires-Dist: pytest-cov ; extra == 'test'
54
64
  Requires-Dist: pytest-mock ; extra == 'test'
55
65
  Requires-Dist: hypothesis ; extra == 'test'
56
66
  Requires-Dist: pyyaml ; extra == 'test'
@@ -0,0 +1,49 @@
1
+ vivarium_public_health/__about__.py,sha256=RgWycPypKZS80TpSX7o41cREnG8PfguNHDHLuLyl820,487
2
+ vivarium_public_health/__init__.py,sha256=tomMOl3PI7O8GdxDWGBiBjT0Bwd31GpyQTYTzwIv108,361
3
+ vivarium_public_health/_version.py,sha256=EPmgXOdWKks5S__ZMH7Nu6xpAeVrZpfxaFy4pykuyeI,22
4
+ vivarium_public_health/utilities.py,sha256=5cl9jjVkOQ1UeXT4DjDMAhaBNNjAsDo-SVJwpv6FDw0,3071
5
+ vivarium_public_health/disease/__init__.py,sha256=RuuiRcvAJfX9WQGt_WZZjxN7Cu3E5rMTmuaRS-UaFPM,419
6
+ vivarium_public_health/disease/model.py,sha256=0WIYDEx-hwlUJp6Zl8m8bUMoWxuVkOWsJvh_YlZiOPs,8234
7
+ vivarium_public_health/disease/models.py,sha256=01UK7yB2zGPFzmlIpvhd-XnGe6vSCMDza3QTidgY7Nc,3479
8
+ vivarium_public_health/disease/special_disease.py,sha256=3vS1WsO__IwOK0Oe_CUmh3aaKrXIf2CANtmiqlS3pjc,14614
9
+ vivarium_public_health/disease/state.py,sha256=G9rmbpH-l9OZyM2-glLpV_Zefz800cNx6t-N-irg0t8,22106
10
+ vivarium_public_health/disease/transition.py,sha256=ZxYXZBo2EEXzuQCbaj2pHTyj61hYkdqBH1ce2Htdnb4,6412
11
+ vivarium_public_health/mslt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ vivarium_public_health/mslt/delay.py,sha256=X_MPxcHYkGHORW8RKPNbx5m85yilJK1_6DaCVQQUpiM,22582
13
+ vivarium_public_health/mslt/disease.py,sha256=FaA9bpKpkaopRCeKNHMh7qWuCtLpGdEyUEo59HuORyM,15684
14
+ vivarium_public_health/mslt/intervention.py,sha256=33HZqYo335H9nxILymoDqmBvmqTJDijRBv8i9u05pLY,10336
15
+ vivarium_public_health/mslt/magic_wand_components.py,sha256=pnl-7MwIJIus6UjtvVmM15pIZOCbSS1mNfP7nS2bAtw,3981
16
+ vivarium_public_health/mslt/observer.py,sha256=UUQBVH47-MhtcMX1_IpaGt2xqbCECY-Txx8Og_raCEk,13941
17
+ vivarium_public_health/mslt/population.py,sha256=6XedM2ZZzaU7U70GQLXj2VcyAvLp0Yjpq5rini-_g6s,7286
18
+ vivarium_public_health/plugins/__init__.py,sha256=oBW_zfgG_LbwfgTDjUe0btfy9FaDvAbtXho1zQFnz0Y,76
19
+ vivarium_public_health/plugins/parser.py,sha256=dlH-tafOGCFvOUZx_QdOkSScMCwH4CbqR8dwPwX7dVw,32851
20
+ vivarium_public_health/population/__init__.py,sha256=17rtbcNVK5LtCCxAex7P7Q_vYpwbeTepyf3nazS90Yc,225
21
+ vivarium_public_health/population/add_new_birth_cohorts.py,sha256=ZpKURSS6DSsKcHPtkAfC59OYe2hYpduFAOm_goBD9mY,9084
22
+ vivarium_public_health/population/base_population.py,sha256=Xn0sjPOT9KJZKILr1NchCwQFarvb3qWtgQ3Uvu999UU,17091
23
+ vivarium_public_health/population/data_transformations.py,sha256=PsvE1-S-Q_K4viBgF2Ss0DaaoH0WyhRX26ZJYwJ0O84,22322
24
+ vivarium_public_health/population/mortality.py,sha256=8T5W4D3oxx-4wjHT-0P1jCLiQI6_zznGLuJ-wobF1BY,10272
25
+ vivarium_public_health/results/__init__.py,sha256=XKuX9HTXUur1kpHM7zuMSnkJxlg-W7eMAPmh8LP9Xp4,281
26
+ vivarium_public_health/results/columns.py,sha256=YUI43jdJ3KwvTrm2Gmxk7By2CJjNFzocLwYHhO2pnn0,447
27
+ vivarium_public_health/results/disability.py,sha256=juaR8eue3pJfD4QNwzIhSqMHqCU6XPZHGX9l-jHHV5Q,7456
28
+ vivarium_public_health/results/disease.py,sha256=7xUcyxx_d2T3DQD-WFRHaRxb0qKIOCCpIGWNpEXzixg,8209
29
+ vivarium_public_health/results/mortality.py,sha256=4KUEPzzo1-kD4TdG0PeRMWW69aJcMQJtho9ED0cpErs,6865
30
+ vivarium_public_health/results/observer.py,sha256=mzQEmWpY910eRUpdIxsS9S9eDwDMKm6SB_60EeH4Zyo,3079
31
+ vivarium_public_health/results/risk.py,sha256=80kQoWrC4oxAMKAmPGpYLHk2k1GtzH1uzxrm8d619KA,4453
32
+ vivarium_public_health/results/simple_cause.py,sha256=sr8M8zxCqf2mqAGfc46WNXtML5hZV4fqnCMrRbyk1xY,561
33
+ vivarium_public_health/results/stratification.py,sha256=I7YWUjN2WtWshePwJM38XHTn4tp5qy6LHgP_pknJaPI,4692
34
+ vivarium_public_health/risks/__init__.py,sha256=z8DcnZGxqNVAyFZm2WAV-IVNGvrSS4izju_0DNe2Ghw,212
35
+ vivarium_public_health/risks/base_risk.py,sha256=CTKx3eywW1pi0XL6zoQfPu9tlgAfLqnJvGJ3wQ45SsQ,10494
36
+ vivarium_public_health/risks/data_transformations.py,sha256=xfhi1nbH49c-fO6q7-41ZJcHGWmpfVWFBhS2UQNztv4,9225
37
+ vivarium_public_health/risks/distributions.py,sha256=roQf8sluFGXlbTptl7KclXYyV_uLSkcYvEnBn_ugWQs,18198
38
+ vivarium_public_health/risks/effect.py,sha256=0B7x0IcoU8Kd6XlhtZbPH3qCMobC78mFEtGK67QsSJs,20410
39
+ vivarium_public_health/risks/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
+ vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py,sha256=MtxlBioQ_EdJb6a-1eAaOx5IxTfzhBEdHsWG_KGiPqA,17366
41
+ vivarium_public_health/treatment/__init__.py,sha256=wONElu9aJbBYwpYIovYPYaN_GYfVhPXtTeFWSdQMgA0,222
42
+ vivarium_public_health/treatment/magic_wand.py,sha256=i9N57-MEuQv5B6dQ5iVMTAdOPghYcgiRRz-dTzigf1s,1980
43
+ vivarium_public_health/treatment/scale_up.py,sha256=kifn7oKTjCJ2l1XiYm4U3FAH98USZ1gLPvf4z5-3wsU,7079
44
+ vivarium_public_health/treatment/therapeutic_inertia.py,sha256=uOvMgIj-Bl5qTk4z7ZnTPUwOVH-xGeKs1pw8WYuE1f4,2340
45
+ vivarium_public_health-3.0.0.dist-info/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
46
+ vivarium_public_health-3.0.0.dist-info/METADATA,sha256=IwrmajCn7LOdIURzRO9e_hgxCsafR-ZzEqEp158GAno,4061
47
+ vivarium_public_health-3.0.0.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
48
+ vivarium_public_health-3.0.0.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
49
+ vivarium_public_health-3.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,118 +0,0 @@
1
- """
2
- ===================
3
- Disability Observer
4
- ===================
5
-
6
- This module contains tools for observing years lived with disability (YLDs)
7
- in the simulation.
8
-
9
- """
10
- from typing import List
11
-
12
- import pandas as pd
13
- from vivarium import Component
14
- from vivarium.framework.engine import Builder
15
- from vivarium.framework.values import Pipeline, list_combiner, union_post_processor
16
-
17
- from vivarium_public_health.disease import DiseaseState, RiskAttributableDisease
18
- from vivarium_public_health.utilities import to_years
19
-
20
-
21
- class DisabilityObserver(Component):
22
- """Counts years lived with disability.
23
-
24
- By default, this counts both aggregate and cause-specific years lived
25
- with disability over the full course of the simulation.
26
-
27
- In the model specification, your configuration for this component should
28
- be specified as, e.g.:
29
-
30
- .. code-block:: yaml
31
-
32
- configuration:
33
- observers:
34
- disability:
35
- exclude:
36
- - "sex"
37
- include:
38
- - "sample_stratification"
39
- """
40
-
41
- CONFIGURATION_DEFAULTS = {
42
- "stratification": {
43
- "disability": {
44
- "exclude": [],
45
- "include": [],
46
- }
47
- }
48
- }
49
-
50
- ##############
51
- # Properties #
52
- ##############
53
-
54
- @property
55
- def disease_classes(self) -> List:
56
- return [DiseaseState, RiskAttributableDisease]
57
-
58
- #####################
59
- # Lifecycle methods #
60
- #####################
61
-
62
- def __init__(self):
63
- super().__init__()
64
- self.disability_weight_pipeline_name = "disability_weight"
65
-
66
- # noinspection PyAttributeOutsideInit
67
- def setup(self, builder: Builder) -> None:
68
- self.config = builder.configuration.stratification.disability
69
- self.step_size = pd.Timedelta(days=builder.configuration.time.step_size)
70
- self.disability_weight = self.get_disability_weight_pipeline(builder)
71
- cause_states = builder.components.get_components_by_type(tuple(self.disease_classes))
72
-
73
- builder.results.register_observation(
74
- name="ylds_due_to_all_causes",
75
- pop_filter='tracked == True and alive == "alive"',
76
- aggregator_sources=[self.disability_weight_pipeline_name],
77
- aggregator=self.disability_weight_aggregator,
78
- requires_columns=["alive"],
79
- requires_values=["disability_weight"],
80
- additional_stratifications=self.config.include,
81
- excluded_stratifications=self.config.exclude,
82
- when="time_step__prepare",
83
- )
84
-
85
- for cause_state in cause_states:
86
- cause_disability_weight_pipeline_name = (
87
- f"{cause_state.state_id}.disability_weight"
88
- )
89
- builder.results.register_observation(
90
- name=f"ylds_due_to_{cause_state.state_id}",
91
- pop_filter='tracked == True and alive == "alive"',
92
- aggregator_sources=[cause_disability_weight_pipeline_name],
93
- aggregator=self.disability_weight_aggregator,
94
- requires_columns=["alive"],
95
- requires_values=[cause_disability_weight_pipeline_name],
96
- additional_stratifications=self.config.include,
97
- excluded_stratifications=self.config.exclude,
98
- when="time_step__prepare",
99
- )
100
-
101
- #################
102
- # Setup methods #
103
- #################
104
-
105
- def get_disability_weight_pipeline(self, builder: Builder) -> Pipeline:
106
- return builder.value.register_value_producer(
107
- self.disability_weight_pipeline_name,
108
- source=lambda index: [pd.Series(0.0, index=index)],
109
- preferred_combiner=list_combiner,
110
- preferred_post_processor=union_post_processor,
111
- )
112
-
113
- ###############
114
- # Aggregators #
115
- ###############
116
-
117
- def disability_weight_aggregator(self, dw: pd.DataFrame) -> float:
118
- return (dw * to_years(self.step_size)).sum().squeeze()