vivarium-public-health 3.0.9__py3-none-any.whl → 3.0.11__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,45 @@ from vivarium_public_health.__about__ import (
8
8
  __uri__,
9
9
  )
10
10
  from vivarium_public_health._version import __version__
11
+ from vivarium_public_health.disease import (
12
+ SI,
13
+ SIR,
14
+ SIS,
15
+ DiseaseModel,
16
+ DiseaseState,
17
+ NeonatalSWC_with_incidence,
18
+ NeonatalSWC_without_incidence,
19
+ RecoveredState,
20
+ RiskAttributableDisease,
21
+ SIR_fixed_duration,
22
+ SIS_fixed_duration,
23
+ SusceptibleState,
24
+ TransientDiseaseState,
25
+ )
26
+ from vivarium_public_health.plugins import CausesConfigurationParser
27
+ from vivarium_public_health.population import (
28
+ BasePopulation,
29
+ FertilityAgeSpecificRates,
30
+ FertilityCrudeBirthRate,
31
+ FertilityDeterministic,
32
+ Mortality,
33
+ ScaledPopulation,
34
+ )
35
+ from vivarium_public_health.results import (
36
+ CategoricalRiskObserver,
37
+ DisabilityObserver,
38
+ DiseaseObserver,
39
+ MortalityObserver,
40
+ ResultsStratifier,
41
+ )
42
+ from vivarium_public_health.risks import (
43
+ LBWSGRisk,
44
+ LBWSGRiskEffect,
45
+ NonLogLinearRiskEffect,
46
+ Risk,
47
+ RiskEffect,
48
+ )
49
+ from vivarium_public_health.treatment import AbsoluteShift, LinearScaleUp, TherapeuticInertia
11
50
 
12
51
  __all__ = [
13
52
  __author__,
@@ -1 +1 @@
1
- __version__ = "3.0.9"
1
+ __version__ = "3.0.11"
@@ -5,6 +5,7 @@ from .models import (
5
5
  SIS,
6
6
  NeonatalSWC_with_incidence,
7
7
  NeonatalSWC_without_incidence,
8
+ SIR_fixed_duration,
8
9
  SIS_fixed_duration,
9
10
  )
10
11
  from .special_disease import RiskAttributableDisease
@@ -3,5 +3,5 @@ from .add_new_birth_cohorts import (
3
3
  FertilityCrudeBirthRate,
4
4
  FertilityDeterministic,
5
5
  )
6
- from .base_population import BasePopulation, generate_population
6
+ from .base_population import BasePopulation, ScaledPopulation, generate_population
7
7
  from .mortality import Mortality
@@ -8,6 +8,8 @@ characteristics to simulants.
8
8
 
9
9
  """
10
10
 
11
+ from __future__ import annotations
12
+
11
13
  from typing import Callable, Dict, Iterable, List
12
14
 
13
15
  import numpy as np
@@ -76,12 +78,11 @@ class BasePopulation(Component):
76
78
  # Validate configuration for deprecated keys
77
79
  self._validate_config_for_deprecated_keys()
78
80
 
79
- source_population_structure = load_population_structure(builder)
81
+ source_population_structure = self._load_population_structure(builder)
80
82
  self.demographic_proportions = assign_demographic_proportions(
81
83
  source_population_structure,
82
84
  include_sex=self.config.include_sex,
83
85
  )
84
-
85
86
  self.randomness = self.get_randomness_streams(builder)
86
87
  self.register_simulants = builder.randomness.register_simulants
87
88
 
@@ -138,7 +139,6 @@ class BasePopulation(Component):
138
139
  demographic_proportions = self.get_demographic_proportions_for_creation_time(
139
140
  self.demographic_proportions, pop_data.creation_time.year
140
141
  )
141
-
142
142
  self.population_view.update(
143
143
  generate_population(
144
144
  simulant_ids=pop_data.index,
@@ -202,6 +202,50 @@ class BasePopulation(Component):
202
202
  f"Public Health. Use the new key '{mapper[key]}' instead."
203
203
  )
204
204
 
205
+ def _load_population_structure(self, builder: Builder) -> pd.DataFrame:
206
+ return load_population_structure(builder)
207
+
208
+
209
+ class ScaledPopulation(BasePopulation):
210
+ """This component is to be used in place of BasePopulation when all simulants are
211
+ a subset of the total population and need to be rescaled. The base population
212
+ structure is multiplied by a provided scaling factor. This scaling factor
213
+ can be a dataframe passed in or a string that corresponds to an artifact key.
214
+ If providing an artifact key, users can specify that in the configuration file.
215
+ For example:
216
+
217
+ .. code-block:: yaml
218
+
219
+ components:
220
+ vivarium_public_health:
221
+ population:
222
+ - ScaledPopulation("some.artifact.key")
223
+
224
+
225
+ """
226
+
227
+ def __init__(self, scaling_factor: str | pd.DataFrame):
228
+ super().__init__()
229
+ self.scaling_factor = scaling_factor
230
+ """Set a multiplicative scaling factor for the population structure."""
231
+
232
+ def _load_population_structure(self, builder: Builder) -> pd.DataFrame:
233
+ scaling_factor = self.get_data(builder, self.scaling_factor)
234
+ population_structure = load_population_structure(builder)
235
+ if not isinstance(scaling_factor, pd.DataFrame):
236
+ raise ValueError(
237
+ f"Scaling factor must be a pandas DataFrame. Provided value: {scaling_factor}"
238
+ )
239
+ scaling_factor = scaling_factor.set_index(
240
+ [col for col in scaling_factor.columns if col != "value"]
241
+ )
242
+ population_structure = population_structure.set_index(
243
+ [col for col in population_structure.columns if col != "value"]
244
+ )
245
+ scaled_population_structure = (population_structure * scaling_factor).reset_index()
246
+
247
+ return scaled_population_structure
248
+
205
249
 
206
250
  class AgeOutSimulants(Component):
207
251
  """Component for handling aged-out simulants"""
@@ -13,6 +13,7 @@ from typing import Tuple, Union
13
13
 
14
14
  import numpy as np
15
15
  import pandas as pd
16
+ from vivarium.framework.engine import Builder
16
17
  from vivarium.framework.randomness import RandomnessStream
17
18
 
18
19
  _SORT_ORDER = ["location", "year_start", "sex", "age_start"]
@@ -493,11 +494,12 @@ def get_cause_deleted_mortality_rate(all_cause_mortality_rate, list_of_csmrs):
493
494
  )
494
495
 
495
496
 
496
- def load_population_structure(builder):
497
+ def load_population_structure(builder: Builder) -> pd.DataFrame:
497
498
  data = builder.data.load("population.structure")
498
499
  # create an age column which is the midpoint of the age group
499
500
  data["age"] = data.apply(lambda row: (row["age_start"] + row["age_end"]) / 2, axis=1)
500
501
  data["location"] = builder.data.load("population.location")
502
+
501
503
  return data
502
504
 
503
505
 
@@ -4,4 +4,5 @@ from .disease import DiseaseObserver
4
4
  from .mortality import MortalityObserver
5
5
  from .observer import PublicHealthObserver
6
6
  from .risk import CategoricalRiskObserver
7
+ from .simple_cause import SimpleCause
7
8
  from .stratification import ResultsStratifier
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium_public_health
3
- Version: 3.0.9
3
+ Version: 3.0.11
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
@@ -1,8 +1,8 @@
1
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=b7f_Jk61orPy8IHcbLq3V_QwsqzdIv4siu0tsrTXDgQ,22
2
+ vivarium_public_health/__init__.py,sha256=GDeeP-7OlCBwPuv_xQoB1wNmvCaFsqfTB7qnnYApm0w,1343
3
+ vivarium_public_health/_version.py,sha256=W1N6WTKcxezCC9VWuVcJYjP2WH4QF_enZGppktJNiZw,23
4
4
  vivarium_public_health/utilities.py,sha256=5cl9jjVkOQ1UeXT4DjDMAhaBNNjAsDo-SVJwpv6FDw0,3071
5
- vivarium_public_health/disease/__init__.py,sha256=RuuiRcvAJfX9WQGt_WZZjxN7Cu3E5rMTmuaRS-UaFPM,419
5
+ vivarium_public_health/disease/__init__.py,sha256=VUJHDLlE6ngo2qHNQUtZ8OWH5H_T7_ao-xsYKDkRmHw,443
6
6
  vivarium_public_health/disease/model.py,sha256=0WIYDEx-hwlUJp6Zl8m8bUMoWxuVkOWsJvh_YlZiOPs,8234
7
7
  vivarium_public_health/disease/models.py,sha256=01UK7yB2zGPFzmlIpvhd-XnGe6vSCMDza3QTidgY7Nc,3479
8
8
  vivarium_public_health/disease/special_disease.py,sha256=3vS1WsO__IwOK0Oe_CUmh3aaKrXIf2CANtmiqlS3pjc,14614
@@ -17,12 +17,12 @@ vivarium_public_health/mslt/observer.py,sha256=O4rysQzAGE5oDkdXb0E-qjD9TPFphQHTn
17
17
  vivarium_public_health/mslt/population.py,sha256=v_p5VkjndAVJMuXaJQc3lAdzUWHlWCEQWH4A-c4phPA,7255
18
18
  vivarium_public_health/plugins/__init__.py,sha256=oBW_zfgG_LbwfgTDjUe0btfy9FaDvAbtXho1zQFnz0Y,76
19
19
  vivarium_public_health/plugins/parser.py,sha256=v78mj8awpdrB-oqK8udPI_7MZBChoKJOQN_e17fNEj8,31841
20
- vivarium_public_health/population/__init__.py,sha256=17rtbcNVK5LtCCxAex7P7Q_vYpwbeTepyf3nazS90Yc,225
20
+ vivarium_public_health/population/__init__.py,sha256=x_9rB93q64Krw-kbBDI1-_U_JsPO1_QrL03AwiFlwXI,243
21
21
  vivarium_public_health/population/add_new_birth_cohorts.py,sha256=k65Li0LYWl-JFHBUvLjJxkRv12EJw_FVxrOYgbd44q8,9078
22
- vivarium_public_health/population/base_population.py,sha256=4lUc8EZwzj5Ba36lSmW9yyxcRuBSMLqi_8Fy69ssq5E,17026
23
- vivarium_public_health/population/data_transformations.py,sha256=QVh_63Wwg9BUkaQm1pMSvBb-wsYrsgyADKIERAiEOVg,22188
22
+ vivarium_public_health/population/base_population.py,sha256=jJMVWv_EO0ckUZHhh01dRbsRgL491Eg3thRxPwNiAeg,18866
23
+ vivarium_public_health/population/data_transformations.py,sha256=YmqyrlrIBtHGp1nFyhesqlNryvB7Vr33eVu4fU4HWsA,22260
24
24
  vivarium_public_health/population/mortality.py,sha256=w7b_TUssHjRcnULdXu7MXKfZBjCrlYWbB94oO3JWogI,10264
25
- vivarium_public_health/results/__init__.py,sha256=XKuX9HTXUur1kpHM7zuMSnkJxlg-W7eMAPmh8LP9Xp4,281
25
+ vivarium_public_health/results/__init__.py,sha256=rKUZGlRXJgEyFY4a_WJeg3XnC0l34S5guYZ0N9JJS4E,319
26
26
  vivarium_public_health/results/columns.py,sha256=V-L3JgTcsk51Zx9PcUwSgaE1iZjuGyfZ8aShPjynadU,495
27
27
  vivarium_public_health/results/disability.py,sha256=JQm3Q7CoGCT2AgxaoH6MKkvnq4xF83wfFmEvEOvTmvA,9876
28
28
  vivarium_public_health/results/disease.py,sha256=OwxhPrfDsCnCZSaw8Yiq2AnibWikoqI-gM7xDdhFLcM,12529
@@ -42,8 +42,8 @@ vivarium_public_health/treatment/__init__.py,sha256=wONElu9aJbBYwpYIovYPYaN_GYfV
42
42
  vivarium_public_health/treatment/magic_wand.py,sha256=i9N57-MEuQv5B6dQ5iVMTAdOPghYcgiRRz-dTzigf1s,1980
43
43
  vivarium_public_health/treatment/scale_up.py,sha256=9Cl3_MaCNPtUPPKXf3hWYepIwMCFlFY24jt2jeyFQO4,7006
44
44
  vivarium_public_health/treatment/therapeutic_inertia.py,sha256=8Z97s7GfcpfLu1U1ESJSqeEk4L__a3M0GbBV21MFg2s,2346
45
- vivarium_public_health-3.0.9.dist-info/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
46
- vivarium_public_health-3.0.9.dist-info/METADATA,sha256=x4sdoB5_G1dhy6ex3qKrGkDwxIqXDgxN1Z9TKFm9I2M,4061
47
- vivarium_public_health-3.0.9.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
48
- vivarium_public_health-3.0.9.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
49
- vivarium_public_health-3.0.9.dist-info/RECORD,,
45
+ vivarium_public_health-3.0.11.dist-info/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
46
+ vivarium_public_health-3.0.11.dist-info/METADATA,sha256=u0zd8NuWIzdLxDYVFI-XfgksSIjwmiQtzJC7ermq4w0,4062
47
+ vivarium_public_health-3.0.11.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
48
+ vivarium_public_health-3.0.11.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
49
+ vivarium_public_health-3.0.11.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.2)
2
+ Generator: setuptools (75.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5