vivarium-public-health 3.1.0__py3-none-any.whl → 3.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vivarium_public_health/_version.py +1 -1
- vivarium_public_health/disease/model.py +29 -9
- vivarium_public_health/disease/special_disease.py +2 -3
- vivarium_public_health/disease/state.py +5 -5
- vivarium_public_health/disease/transition.py +2 -2
- vivarium_public_health/plugins/parser.py +39 -11
- vivarium_public_health/population/mortality.py +1 -1
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.1.dist-info}/METADATA +2 -2
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.1.dist-info}/RECORD +12 -12
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.1.dist-info}/LICENSE.txt +0 -0
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.1.dist-info}/WHEEL +0 -0
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.1.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
__version__ = "3.1.
|
1
|
+
__version__ = "3.1.1"
|
@@ -8,7 +8,8 @@ function is to provide coordination across a set of disease states and
|
|
8
8
|
transitions at simulation initialization and during transitions.
|
9
9
|
|
10
10
|
"""
|
11
|
-
|
11
|
+
import warnings
|
12
|
+
from collections.abc import Iterable
|
12
13
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
13
14
|
|
14
15
|
import numpy as np
|
@@ -38,7 +39,7 @@ class DiseaseModel(Machine):
|
|
38
39
|
return {
|
39
40
|
f"{self.name}": {
|
40
41
|
"data_sources": {
|
41
|
-
"cause_specific_mortality_rate":
|
42
|
+
"cause_specific_mortality_rate": self.load_cause_specific_mortality_rate,
|
42
43
|
},
|
43
44
|
},
|
44
45
|
}
|
@@ -79,16 +80,35 @@ class DiseaseModel(Machine):
|
|
79
80
|
initial_state: Optional[BaseDiseaseState] = None,
|
80
81
|
get_data_functions: Optional[Dict[str, Callable]] = None,
|
81
82
|
cause_type: str = "cause",
|
83
|
+
states: Iterable[BaseDiseaseState] = (),
|
84
|
+
residual_state: BaseDiseaseState | None = None,
|
82
85
|
**kwargs,
|
83
86
|
):
|
84
|
-
super().__init__(cause, **kwargs)
|
87
|
+
super().__init__(cause, states=states, **kwargs)
|
85
88
|
self.cause = cause
|
86
89
|
self.cause_type = cause_type
|
87
90
|
|
88
91
|
if initial_state is not None:
|
89
|
-
|
92
|
+
warnings.warn(
|
93
|
+
"In the future, the 'initial_state' argument to DiseaseModel"
|
94
|
+
" will be used to initialize all simulants into that state. To"
|
95
|
+
" retain the current behavior of defining a residual state, use"
|
96
|
+
" the 'residual_state' argument.",
|
97
|
+
DeprecationWarning,
|
98
|
+
stacklevel=2,
|
99
|
+
)
|
100
|
+
|
101
|
+
if residual_state:
|
102
|
+
raise DiseaseModelError(
|
103
|
+
"A DiseaseModel cannot be initialized with both"
|
104
|
+
" 'initial_state and 'residual_state'."
|
105
|
+
)
|
106
|
+
|
107
|
+
self.residual_state = initial_state.state_id
|
108
|
+
elif residual_state is not None:
|
109
|
+
self.residual_state = residual_state.state_id
|
90
110
|
else:
|
91
|
-
self.
|
111
|
+
self.residual_state = self._get_default_residual_state()
|
92
112
|
|
93
113
|
self._get_data_functions = (
|
94
114
|
get_data_functions if get_data_functions is not None else {}
|
@@ -135,7 +155,7 @@ class DiseaseModel(Machine):
|
|
135
155
|
def on_initialize_simulants(self, pop_data: SimulantData) -> None:
|
136
156
|
population = self.population_view.subview(["age", "sex"]).get(pop_data.index)
|
137
157
|
|
138
|
-
assert self.
|
158
|
+
assert self.residual_state in {s.state_id for s in self.states}
|
139
159
|
|
140
160
|
if pop_data.user_data["sim_state"] == "setup": # simulation start
|
141
161
|
if self.configuration_age_start != self.configuration_age_end != 0:
|
@@ -176,7 +196,7 @@ class DiseaseModel(Machine):
|
|
176
196
|
)
|
177
197
|
else:
|
178
198
|
condition_column = pd.Series(
|
179
|
-
self.
|
199
|
+
self.residual_state, index=population.index, name=self.state_column
|
180
200
|
)
|
181
201
|
self.population_view.update(condition_column)
|
182
202
|
|
@@ -197,7 +217,7 @@ class DiseaseModel(Machine):
|
|
197
217
|
# Helper functions #
|
198
218
|
####################
|
199
219
|
|
200
|
-
def
|
220
|
+
def _get_default_residual_state(self):
|
201
221
|
susceptible_states = [s for s in self.states if isinstance(s, SusceptibleState)]
|
202
222
|
if len(susceptible_states) != 1:
|
203
223
|
raise DiseaseModelError("Disease model must have exactly one SusceptibleState.")
|
@@ -219,7 +239,7 @@ class DiseaseModel(Machine):
|
|
219
239
|
weights = np.array(weights).T
|
220
240
|
weights_bins = np.cumsum(weights, axis=1)
|
221
241
|
|
222
|
-
state_names = [s.state_id for s in states] + [self.
|
242
|
+
state_names = [s.state_id for s in states] + [self.residual_state]
|
223
243
|
|
224
244
|
return state_names, weights_bins
|
225
245
|
|
@@ -14,7 +14,6 @@ from typing import Any, Dict, List, Optional
|
|
14
14
|
|
15
15
|
import pandas as pd
|
16
16
|
from vivarium import Component
|
17
|
-
from vivarium.framework.engine import Builder
|
18
17
|
from vivarium.framework.event import Event
|
19
18
|
from vivarium.framework.population import SimulantData
|
20
19
|
from vivarium.framework.values import list_combiner, union_post_processor
|
@@ -101,8 +100,8 @@ class RiskAttributableDisease(Component):
|
|
101
100
|
self.name: {
|
102
101
|
"data_sources": {
|
103
102
|
"raw_disability_weight": f"{self.cause}.disability_weight",
|
104
|
-
"cause_specific_mortality_rate":
|
105
|
-
"excess_mortality_rate":
|
103
|
+
"cause_specific_mortality_rate": self.load_cause_specific_mortality_rate_data,
|
104
|
+
"excess_mortality_rate": self.load_excess_mortality_rate_data,
|
106
105
|
"population_attributable_fraction": 0,
|
107
106
|
},
|
108
107
|
"threshold": None,
|
@@ -282,11 +282,11 @@ class DiseaseState(BaseDiseaseState):
|
|
282
282
|
return {
|
283
283
|
f"{self.name}": {
|
284
284
|
"data_sources": {
|
285
|
-
"prevalence":
|
286
|
-
"birth_prevalence":
|
287
|
-
"dwell_time":
|
288
|
-
"disability_weight":
|
289
|
-
"excess_mortality_rate":
|
285
|
+
"prevalence": self.load_prevalence,
|
286
|
+
"birth_prevalence": self.load_birth_prevalence,
|
287
|
+
"dwell_time": self.load_dwell_time,
|
288
|
+
"disability_weight": self.load_disability_weight,
|
289
|
+
"excess_mortality_rate": self.load_excess_mortality_rate,
|
290
290
|
},
|
291
291
|
},
|
292
292
|
}
|
@@ -43,7 +43,7 @@ class RateTransition(Transition):
|
|
43
43
|
return {
|
44
44
|
f"{self.name}": {
|
45
45
|
"data_sources": {
|
46
|
-
"transition_rate":
|
46
|
+
"transition_rate": self.load_transition_rate,
|
47
47
|
},
|
48
48
|
},
|
49
49
|
}
|
@@ -156,7 +156,7 @@ class ProportionTransition(Transition):
|
|
156
156
|
return {
|
157
157
|
f"{self.name}": {
|
158
158
|
"data_sources": {
|
159
|
-
"proportion":
|
159
|
+
"proportion": self.load_proportion,
|
160
160
|
},
|
161
161
|
},
|
162
162
|
}
|
@@ -9,7 +9,7 @@ that can parse configurations of components specific to the Vivarium Public
|
|
9
9
|
Health package.
|
10
10
|
|
11
11
|
"""
|
12
|
-
|
12
|
+
import warnings
|
13
13
|
from importlib import import_module
|
14
14
|
from typing import Any, Callable, Dict, List, Optional, Union
|
15
15
|
|
@@ -56,11 +56,13 @@ class CausesConfigurationParser(ComponentConfigurationParser):
|
|
56
56
|
DEFAULT_MODEL_CONFIG = {
|
57
57
|
"model_type": f"{DiseaseModel.__module__}.{DiseaseModel.__name__}",
|
58
58
|
"initial_state": None,
|
59
|
+
"residual_state": None,
|
59
60
|
}
|
60
61
|
"""Default cause model configuration if it's not explicitly specified.
|
61
62
|
|
62
|
-
|
63
|
-
|
63
|
+
Initial state and residual state cannot both be provided. If neither initial
|
64
|
+
state nor residual state has been specified, the cause model must have a
|
65
|
+
state named 'susceptible'.
|
64
66
|
"""
|
65
67
|
|
66
68
|
DEFAULT_STATE_CONFIG = {
|
@@ -104,7 +106,7 @@ class CausesConfigurationParser(ComponentConfigurationParser):
|
|
104
106
|
causes:
|
105
107
|
cause_1:
|
106
108
|
model_type: vivarium_public_health.disease.DiseaseModel
|
107
|
-
|
109
|
+
residual_state: susceptible
|
108
110
|
states:
|
109
111
|
susceptible:
|
110
112
|
cause_type: cause
|
@@ -247,11 +249,13 @@ class CausesConfigurationParser(ComponentConfigurationParser):
|
|
247
249
|
)
|
248
250
|
|
249
251
|
model_type = import_by_path(cause_config.model_type)
|
250
|
-
|
252
|
+
residual_state = states.get(
|
253
|
+
cause_config.residual_state, states.get(cause_config.initial_state, None)
|
254
|
+
)
|
251
255
|
model = model_type(
|
252
256
|
cause_name,
|
253
|
-
initial_state=initial_state,
|
254
257
|
states=list(states.values()),
|
258
|
+
residual_state=residual_state,
|
255
259
|
get_data_functions=data_sources,
|
256
260
|
)
|
257
261
|
cause_models.append(model)
|
@@ -403,7 +407,14 @@ class CausesConfigurationParser(ComponentConfigurationParser):
|
|
403
407
|
# Validation methods #
|
404
408
|
######################
|
405
409
|
|
406
|
-
_CAUSE_KEYS = {
|
410
|
+
_CAUSE_KEYS = {
|
411
|
+
"model_type",
|
412
|
+
"initial_state",
|
413
|
+
"states",
|
414
|
+
"transitions",
|
415
|
+
"data_sources",
|
416
|
+
"residual_state",
|
417
|
+
}
|
407
418
|
_STATE_KEYS = {
|
408
419
|
"state_type",
|
409
420
|
"cause_type",
|
@@ -535,11 +546,28 @@ class CausesConfigurationParser(ComponentConfigurationParser):
|
|
535
546
|
)
|
536
547
|
else:
|
537
548
|
initial_state = cause_config.get("initial_state", None)
|
538
|
-
|
549
|
+
residual_state = cause_config.get("residual_state", None)
|
550
|
+
if initial_state is not None:
|
551
|
+
warnings.warn(
|
552
|
+
"In the future, the 'initial_state' cause configuration will"
|
553
|
+
" be used to initialize all simulants into that state. To"
|
554
|
+
" retain the current behavior of defining a residual state,"
|
555
|
+
" use the 'residual_state' cause configuration.",
|
556
|
+
DeprecationWarning,
|
557
|
+
stacklevel=2,
|
558
|
+
)
|
559
|
+
if residual_state is None:
|
560
|
+
residual_state = initial_state
|
561
|
+
else:
|
562
|
+
error_messages.append(
|
563
|
+
"A cause may not have both 'initial_state and"
|
564
|
+
" 'residual_state' configurations."
|
565
|
+
)
|
566
|
+
|
567
|
+
if residual_state is not None and residual_state not in states_config:
|
539
568
|
error_messages.append(
|
540
|
-
f"
|
541
|
-
f"
|
542
|
-
f"'{cause_name}."
|
569
|
+
f"Residual state '{residual_state}' for cause '{cause_name}'"
|
570
|
+
f" must be present in the states for cause '{cause_name}."
|
543
571
|
)
|
544
572
|
for state_name, state_config in states_config.items():
|
545
573
|
error_messages += self._validate_state(cause_name, state_name, state_config)
|
@@ -105,7 +105,7 @@ class Mortality(Component):
|
|
105
105
|
"mortality": {
|
106
106
|
"data_sources": {
|
107
107
|
"all_cause_mortality_rate": "cause.all_causes.cause_specific_mortality_rate",
|
108
|
-
"unmodeled_cause_specific_mortality_rate":
|
108
|
+
"unmodeled_cause_specific_mortality_rate": self.load_unmodeled_csmr,
|
109
109
|
"life_expectancy": "population.theoretical_minimum_risk_life_expectancy",
|
110
110
|
},
|
111
111
|
"unmodeled_causes": [],
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: vivarium_public_health
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.1
|
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,7 +26,7 @@ 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 >=3.0
|
29
|
+
Requires-Dist: vivarium >=3.2.0
|
30
30
|
Requires-Dist: layered-config-tree >=1.0.1
|
31
31
|
Requires-Dist: loguru
|
32
32
|
Requires-Dist: numpy <2.0.0
|
@@ -1,13 +1,13 @@
|
|
1
1
|
vivarium_public_health/__about__.py,sha256=RgWycPypKZS80TpSX7o41cREnG8PfguNHDHLuLyl820,487
|
2
2
|
vivarium_public_health/__init__.py,sha256=GDeeP-7OlCBwPuv_xQoB1wNmvCaFsqfTB7qnnYApm0w,1343
|
3
|
-
vivarium_public_health/_version.py,sha256=
|
3
|
+
vivarium_public_health/_version.py,sha256=14eImCCNxRh4pWMIfkKe4h5OCS1ICfRjHSj2AfgEXa0,22
|
4
4
|
vivarium_public_health/utilities.py,sha256=5cl9jjVkOQ1UeXT4DjDMAhaBNNjAsDo-SVJwpv6FDw0,3071
|
5
5
|
vivarium_public_health/disease/__init__.py,sha256=VUJHDLlE6ngo2qHNQUtZ8OWH5H_T7_ao-xsYKDkRmHw,443
|
6
|
-
vivarium_public_health/disease/model.py,sha256=
|
6
|
+
vivarium_public_health/disease/model.py,sha256=wbQvRQF6faTjx6OzokLt6u_9vdAvUrx_P8iQmiKNfv4,9128
|
7
7
|
vivarium_public_health/disease/models.py,sha256=01UK7yB2zGPFzmlIpvhd-XnGe6vSCMDza3QTidgY7Nc,3479
|
8
|
-
vivarium_public_health/disease/special_disease.py,sha256=
|
9
|
-
vivarium_public_health/disease/state.py,sha256=
|
10
|
-
vivarium_public_health/disease/transition.py,sha256=
|
8
|
+
vivarium_public_health/disease/special_disease.py,sha256=ZBtS-eDVptbZ1OjD35dhJvkKw78oDUfTyQSLY7g74dw,14562
|
9
|
+
vivarium_public_health/disease/state.py,sha256=ON1RGVLV2BAmq2aGR7u94j3Q0btb0Hz3flr1FCEQHtQ,22355
|
10
|
+
vivarium_public_health/disease/transition.py,sha256=G2-L0JvX4tWaHN5zrYXMR2jFj_JXFe9LEbrWjIbplCc,6446
|
11
11
|
vivarium_public_health/mslt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
vivarium_public_health/mslt/delay.py,sha256=aOYjMpMSHEVlJs0FuC2gdq3uj6_vKmkhDjoBtC4i9G0,22812
|
13
13
|
vivarium_public_health/mslt/disease.py,sha256=TBqa7yj6k1oUbgkAe0rIgLpbdMLMFs4DiZ1Igi2BQBg,16663
|
@@ -16,12 +16,12 @@ vivarium_public_health/mslt/magic_wand_components.py,sha256=pnl-7MwIJIus6UjtvVmM
|
|
16
16
|
vivarium_public_health/mslt/observer.py,sha256=O4rysQzAGE5oDkdXb0E-qjD9TPFphQHTn7_3Qj7pBL0,15225
|
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
|
-
vivarium_public_health/plugins/parser.py,sha256=
|
19
|
+
vivarium_public_health/plugins/parser.py,sha256=WuhgV47EVUAMSR8pQxQfNfQWkR3QtAOL0zhqvLNGdBQ,32946
|
20
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
22
|
vivarium_public_health/population/base_population.py,sha256=jJMVWv_EO0ckUZHhh01dRbsRgL491Eg3thRxPwNiAeg,18866
|
23
23
|
vivarium_public_health/population/data_transformations.py,sha256=YmqyrlrIBtHGp1nFyhesqlNryvB7Vr33eVu4fU4HWsA,22260
|
24
|
-
vivarium_public_health/population/mortality.py,sha256=
|
24
|
+
vivarium_public_health/population/mortality.py,sha256=WAHtqXOgkX7li_lLvfwJsvJvVjlS5RLvm0DVpu0K3n0,10261
|
25
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
|
@@ -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.1.
|
46
|
-
vivarium_public_health-3.1.
|
47
|
-
vivarium_public_health-3.1.
|
48
|
-
vivarium_public_health-3.1.
|
49
|
-
vivarium_public_health-3.1.
|
45
|
+
vivarium_public_health-3.1.1.dist-info/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
|
46
|
+
vivarium_public_health-3.1.1.dist-info/METADATA,sha256=T9qvhChXoRbfWilAVz8Rbi2GkPMnDxsy-bcY16jZggk,4061
|
47
|
+
vivarium_public_health-3.1.1.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
|
48
|
+
vivarium_public_health-3.1.1.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
|
49
|
+
vivarium_public_health-3.1.1.dist-info/RECORD,,
|
{vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.1.dist-info}/LICENSE.txt
RENAMED
File without changes
|
File without changes
|
{vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.1.dist-info}/top_level.txt
RENAMED
File without changes
|