vivarium-public-health 3.1.0__py3-none-any.whl → 3.1.2__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 +40 -28
- vivarium_public_health/disease/special_disease.py +7 -8
- vivarium_public_health/disease/state.py +23 -22
- vivarium_public_health/disease/transition.py +11 -10
- vivarium_public_health/mslt/delay.py +5 -5
- vivarium_public_health/mslt/disease.py +5 -5
- vivarium_public_health/mslt/intervention.py +8 -8
- vivarium_public_health/mslt/magic_wand_components.py +3 -3
- vivarium_public_health/mslt/observer.py +4 -6
- vivarium_public_health/mslt/population.py +4 -6
- vivarium_public_health/plugins/parser.py +57 -30
- vivarium_public_health/population/add_new_birth_cohorts.py +3 -5
- vivarium_public_health/population/base_population.py +8 -10
- vivarium_public_health/population/data_transformations.py +4 -5
- vivarium_public_health/population/mortality.py +7 -7
- vivarium_public_health/results/disability.py +1 -3
- vivarium_public_health/results/disease.py +5 -5
- vivarium_public_health/results/mortality.py +3 -3
- vivarium_public_health/results/observer.py +7 -7
- vivarium_public_health/results/risk.py +3 -3
- vivarium_public_health/risks/base_risk.py +4 -4
- vivarium_public_health/risks/distributions.py +15 -15
- vivarium_public_health/risks/effect.py +10 -10
- vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py +17 -16
- vivarium_public_health/treatment/magic_wand.py +3 -3
- vivarium_public_health/treatment/scale_up.py +6 -5
- vivarium_public_health/utilities.py +4 -5
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.2.dist-info}/METADATA +2 -2
- vivarium_public_health-3.1.2.dist-info/RECORD +49 -0
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.2.dist-info}/WHEEL +1 -1
- vivarium_public_health-3.1.0.dist-info/RECORD +0 -49
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.2.dist-info}/LICENSE.txt +0 -0
- {vivarium_public_health-3.1.0.dist-info → vivarium_public_health-3.1.2.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
__version__ = "3.1.
|
1
|
+
__version__ = "3.1.2"
|
@@ -8,8 +8,9 @@ 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
|
-
|
12
|
-
from
|
11
|
+
import warnings
|
12
|
+
from collections.abc import Callable, Iterable
|
13
|
+
from typing import Any
|
13
14
|
|
14
15
|
import numpy as np
|
15
16
|
import pandas as pd
|
@@ -34,25 +35,25 @@ class DiseaseModel(Machine):
|
|
34
35
|
##############
|
35
36
|
|
36
37
|
@property
|
37
|
-
def configuration_defaults(self) ->
|
38
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
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
|
}
|
45
46
|
|
46
47
|
@property
|
47
|
-
def columns_created(self) ->
|
48
|
+
def columns_created(self) -> list[str]:
|
48
49
|
return [self.state_column]
|
49
50
|
|
50
51
|
@property
|
51
|
-
def columns_required(self) ->
|
52
|
+
def columns_required(self) -> list[str] | None:
|
52
53
|
return ["age", "sex"]
|
53
54
|
|
54
55
|
@property
|
55
|
-
def initialization_requirements(self) ->
|
56
|
+
def initialization_requirements(self) -> dict[str, list[str]]:
|
56
57
|
return {
|
57
58
|
"requires_columns": ["age", "sex"],
|
58
59
|
"requires_values": [],
|
@@ -60,11 +61,11 @@ class DiseaseModel(Machine):
|
|
60
61
|
}
|
61
62
|
|
62
63
|
@property
|
63
|
-
def state_names(self) ->
|
64
|
+
def state_names(self) -> list[str]:
|
64
65
|
return [s.state_id for s in self.states]
|
65
66
|
|
66
67
|
@property
|
67
|
-
def transition_names(self) ->
|
68
|
+
def transition_names(self) -> list[TransitionString]:
|
68
69
|
return [
|
69
70
|
state_name for state in self.states for state_name in state.get_transition_names()
|
70
71
|
]
|
@@ -76,19 +77,38 @@ class DiseaseModel(Machine):
|
|
76
77
|
def __init__(
|
77
78
|
self,
|
78
79
|
cause: str,
|
79
|
-
initial_state:
|
80
|
-
get_data_functions:
|
80
|
+
initial_state: BaseDiseaseState | None = None,
|
81
|
+
get_data_functions: dict[str, Callable] | None = 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 {}
|
@@ -111,9 +131,7 @@ class DiseaseModel(Machine):
|
|
111
131
|
# Setup methods #
|
112
132
|
#################
|
113
133
|
|
114
|
-
def load_cause_specific_mortality_rate(
|
115
|
-
self, builder: Builder
|
116
|
-
) -> Union[float, pd.DataFrame]:
|
134
|
+
def load_cause_specific_mortality_rate(self, builder: Builder) -> float | pd.DataFrame:
|
117
135
|
if "cause_specific_mortality_rate" not in self._get_data_functions:
|
118
136
|
only_morbid = builder.data.load(f"cause.{self.cause}.restrictions")["yld_only"]
|
119
137
|
if only_morbid:
|
@@ -135,7 +153,7 @@ class DiseaseModel(Machine):
|
|
135
153
|
def on_initialize_simulants(self, pop_data: SimulantData) -> None:
|
136
154
|
population = self.population_view.subview(["age", "sex"]).get(pop_data.index)
|
137
155
|
|
138
|
-
assert self.
|
156
|
+
assert self.residual_state in {s.state_id for s in self.states}
|
139
157
|
|
140
158
|
if pop_data.user_data["sim_state"] == "setup": # simulation start
|
141
159
|
if self.configuration_age_start != self.configuration_age_end != 0:
|
@@ -176,16 +194,10 @@ class DiseaseModel(Machine):
|
|
176
194
|
)
|
177
195
|
else:
|
178
196
|
condition_column = pd.Series(
|
179
|
-
self.
|
197
|
+
self.residual_state, index=population.index, name=self.state_column
|
180
198
|
)
|
181
199
|
self.population_view.update(condition_column)
|
182
200
|
|
183
|
-
def on_time_step(self, event: Event) -> None:
|
184
|
-
self.transition(event.index, event.time)
|
185
|
-
|
186
|
-
def on_time_step_cleanup(self, event: Event) -> None:
|
187
|
-
self.cleanup(event.index, event.time)
|
188
|
-
|
189
201
|
##################################
|
190
202
|
# Pipeline sources and modifiers #
|
191
203
|
##################################
|
@@ -197,7 +209,7 @@ class DiseaseModel(Machine):
|
|
197
209
|
# Helper functions #
|
198
210
|
####################
|
199
211
|
|
200
|
-
def
|
212
|
+
def _get_default_residual_state(self):
|
201
213
|
susceptible_states = [s for s in self.states if isinstance(s, SusceptibleState)]
|
202
214
|
if len(susceptible_states) != 1:
|
203
215
|
raise DiseaseModelError("Disease model must have exactly one SusceptibleState.")
|
@@ -205,7 +217,7 @@ class DiseaseModel(Machine):
|
|
205
217
|
|
206
218
|
def get_state_weights(
|
207
219
|
self, pop_index: pd.Index, prevalence_type: str
|
208
|
-
) ->
|
220
|
+
) -> tuple[list[str], np.ndarray | None]:
|
209
221
|
states = [state for state in self.states if state.lookup_tables.get(prevalence_type)]
|
210
222
|
|
211
223
|
if not states:
|
@@ -219,7 +231,7 @@ class DiseaseModel(Machine):
|
|
219
231
|
weights = np.array(weights).T
|
220
232
|
weights_bins = np.cumsum(weights, axis=1)
|
221
233
|
|
222
|
-
state_names = [s.state_id for s in states] + [self.
|
234
|
+
state_names = [s.state_id for s in states] + [self.residual_state]
|
223
235
|
|
224
236
|
return state_names, weights_bins
|
225
237
|
|
@@ -10,11 +10,10 @@ This module contains frequently used, but non-standard disease models.
|
|
10
10
|
import re
|
11
11
|
from collections import namedtuple
|
12
12
|
from operator import gt, lt
|
13
|
-
from typing import Any
|
13
|
+
from typing import Any
|
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
|
@@ -96,13 +95,13 @@ class RiskAttributableDisease(Component):
|
|
96
95
|
return f"risk_attributable_disease.{self.cause.name}"
|
97
96
|
|
98
97
|
@property
|
99
|
-
def configuration_defaults(self) ->
|
98
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
100
99
|
return {
|
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,
|
@@ -112,7 +111,7 @@ class RiskAttributableDisease(Component):
|
|
112
111
|
}
|
113
112
|
|
114
113
|
@property
|
115
|
-
def columns_created(self) ->
|
114
|
+
def columns_created(self) -> list[str]:
|
116
115
|
return [
|
117
116
|
self.cause.name,
|
118
117
|
self.diseased_event_time_column,
|
@@ -120,11 +119,11 @@ class RiskAttributableDisease(Component):
|
|
120
119
|
]
|
121
120
|
|
122
121
|
@property
|
123
|
-
def columns_required(self) ->
|
122
|
+
def columns_required(self) -> list[str] | None:
|
124
123
|
return ["alive"]
|
125
124
|
|
126
125
|
@property
|
127
|
-
def initialization_requirements(self) ->
|
126
|
+
def initialization_requirements(self) -> dict[str, list[str]]:
|
128
127
|
return {
|
129
128
|
"requires_columns": [],
|
130
129
|
"requires_values": [f"{self.risk.name}.exposure"],
|
@@ -7,7 +7,8 @@ This module contains tools to manage standard disease states.
|
|
7
7
|
|
8
8
|
"""
|
9
9
|
|
10
|
-
from
|
10
|
+
from collections.abc import Callable
|
11
|
+
from typing import Any
|
11
12
|
|
12
13
|
import numpy as np
|
13
14
|
import pandas as pd
|
@@ -36,11 +37,11 @@ class BaseDiseaseState(State):
|
|
36
37
|
return [self.event_time_column, self.event_count_column]
|
37
38
|
|
38
39
|
@property
|
39
|
-
def columns_required(self) ->
|
40
|
+
def columns_required(self) -> list[str] | None:
|
40
41
|
return [self.model, "alive"]
|
41
42
|
|
42
43
|
@property
|
43
|
-
def initialization_requirements(self) ->
|
44
|
+
def initialization_requirements(self) -> dict[str, list[str]]:
|
44
45
|
return {
|
45
46
|
"requires_columns": [self.model],
|
46
47
|
"requires_values": [],
|
@@ -55,7 +56,7 @@ class BaseDiseaseState(State):
|
|
55
56
|
self,
|
56
57
|
state_id: str,
|
57
58
|
allow_self_transition: bool = False,
|
58
|
-
side_effect_function:
|
59
|
+
side_effect_function: Callable | None = None,
|
59
60
|
cause_type: str = "cause",
|
60
61
|
):
|
61
62
|
super().__init__(state_id, allow_self_transition) # becomes state_id
|
@@ -83,7 +84,7 @@ class BaseDiseaseState(State):
|
|
83
84
|
# Helper methods #
|
84
85
|
##################
|
85
86
|
|
86
|
-
def get_initialization_parameters(self) ->
|
87
|
+
def get_initialization_parameters(self) -> dict[str, Any]:
|
87
88
|
"""Exclude side effect function and cause type from name and __repr__."""
|
88
89
|
initialization_parameters = super().get_initialization_parameters()
|
89
90
|
for key in ["side_effect_function", "cause_type"]:
|
@@ -118,7 +119,7 @@ class BaseDiseaseState(State):
|
|
118
119
|
# Public methods #
|
119
120
|
##################
|
120
121
|
|
121
|
-
def get_transition_names(self) ->
|
122
|
+
def get_transition_names(self) -> list[str]:
|
122
123
|
transitions = []
|
123
124
|
for trans in self.transition_set.transitions:
|
124
125
|
init_state = trans.input_state.name.split(".")[1]
|
@@ -129,7 +130,7 @@ class BaseDiseaseState(State):
|
|
129
130
|
def add_rate_transition(
|
130
131
|
self,
|
131
132
|
output: "BaseDiseaseState",
|
132
|
-
get_data_functions:
|
133
|
+
get_data_functions: dict[str, Callable] = None,
|
133
134
|
triggered=Trigger.NOT_TRIGGERED,
|
134
135
|
) -> RateTransition:
|
135
136
|
"""Builds a RateTransition from this state to the given state.
|
@@ -156,7 +157,7 @@ class BaseDiseaseState(State):
|
|
156
157
|
def add_proportion_transition(
|
157
158
|
self,
|
158
159
|
output: "BaseDiseaseState",
|
159
|
-
get_data_functions:
|
160
|
+
get_data_functions: dict[str, Callable] | None = None,
|
160
161
|
triggered=Trigger.NOT_TRIGGERED,
|
161
162
|
) -> ProportionTransition:
|
162
163
|
"""Builds a ProportionTransition from this state to the given state.
|
@@ -198,7 +199,7 @@ class NonDiseasedState(BaseDiseaseState):
|
|
198
199
|
self,
|
199
200
|
state_id: str,
|
200
201
|
allow_self_transition: bool = False,
|
201
|
-
side_effect_function:
|
202
|
+
side_effect_function: Callable | None = None,
|
202
203
|
cause_type: str = "cause",
|
203
204
|
name_prefix: str = "",
|
204
205
|
):
|
@@ -218,7 +219,7 @@ class NonDiseasedState(BaseDiseaseState):
|
|
218
219
|
def add_rate_transition(
|
219
220
|
self,
|
220
221
|
output: BaseDiseaseState,
|
221
|
-
get_data_functions:
|
222
|
+
get_data_functions: dict[str, Callable] = None,
|
222
223
|
**kwargs,
|
223
224
|
) -> RateTransition:
|
224
225
|
if get_data_functions is None:
|
@@ -241,7 +242,7 @@ class SusceptibleState(NonDiseasedState):
|
|
241
242
|
self,
|
242
243
|
state_id: str,
|
243
244
|
allow_self_transition: bool = False,
|
244
|
-
side_effect_function:
|
245
|
+
side_effect_function: Callable | None = None,
|
245
246
|
cause_type: str = "cause",
|
246
247
|
):
|
247
248
|
super().__init__(
|
@@ -258,7 +259,7 @@ class RecoveredState(NonDiseasedState):
|
|
258
259
|
self,
|
259
260
|
state_id: str,
|
260
261
|
allow_self_transition: bool = False,
|
261
|
-
side_effect_function:
|
262
|
+
side_effect_function: Callable | None = None,
|
262
263
|
cause_type: str = "cause",
|
263
264
|
):
|
264
265
|
super().__init__(
|
@@ -278,15 +279,15 @@ class DiseaseState(BaseDiseaseState):
|
|
278
279
|
##############
|
279
280
|
|
280
281
|
@property
|
281
|
-
def configuration_defaults(self) ->
|
282
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
282
283
|
return {
|
283
284
|
f"{self.name}": {
|
284
285
|
"data_sources": {
|
285
|
-
"prevalence":
|
286
|
-
"birth_prevalence":
|
287
|
-
"dwell_time":
|
288
|
-
"disability_weight":
|
289
|
-
"excess_mortality_rate":
|
286
|
+
"prevalence": self.load_prevalence,
|
287
|
+
"birth_prevalence": self.load_birth_prevalence,
|
288
|
+
"dwell_time": self.load_dwell_time,
|
289
|
+
"disability_weight": self.load_disability_weight,
|
290
|
+
"excess_mortality_rate": self.load_excess_mortality_rate,
|
290
291
|
},
|
291
292
|
},
|
292
293
|
}
|
@@ -299,10 +300,10 @@ class DiseaseState(BaseDiseaseState):
|
|
299
300
|
self,
|
300
301
|
state_id: str,
|
301
302
|
allow_self_transition: bool = False,
|
302
|
-
side_effect_function:
|
303
|
+
side_effect_function: Callable | None = None,
|
303
304
|
cause_type: str = "cause",
|
304
|
-
get_data_functions:
|
305
|
-
cleanup_function:
|
305
|
+
get_data_functions: dict[str, Callable] | None = None,
|
306
|
+
cleanup_function: Callable | None = None,
|
306
307
|
):
|
307
308
|
"""
|
308
309
|
Parameters
|
@@ -472,7 +473,7 @@ class DiseaseState(BaseDiseaseState):
|
|
472
473
|
def add_rate_transition(
|
473
474
|
self,
|
474
475
|
output: BaseDiseaseState,
|
475
|
-
get_data_functions:
|
476
|
+
get_data_functions: dict[str, Callable] = None,
|
476
477
|
**kwargs,
|
477
478
|
) -> RateTransition:
|
478
479
|
if get_data_functions is None:
|
@@ -7,7 +7,8 @@ This module contains tools to model transitions between disease states.
|
|
7
7
|
|
8
8
|
"""
|
9
9
|
|
10
|
-
from
|
10
|
+
from collections.abc import Callable
|
11
|
+
from typing import TYPE_CHECKING, Any
|
11
12
|
|
12
13
|
import pandas as pd
|
13
14
|
from vivarium.framework.engine import Builder
|
@@ -39,17 +40,17 @@ class RateTransition(Transition):
|
|
39
40
|
##############
|
40
41
|
|
41
42
|
@property
|
42
|
-
def configuration_defaults(self) ->
|
43
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
43
44
|
return {
|
44
45
|
f"{self.name}": {
|
45
46
|
"data_sources": {
|
46
|
-
"transition_rate":
|
47
|
+
"transition_rate": self.load_transition_rate,
|
47
48
|
},
|
48
49
|
},
|
49
50
|
}
|
50
51
|
|
51
52
|
@property
|
52
|
-
def columns_required(self) ->
|
53
|
+
def columns_required(self) -> list[str] | None:
|
53
54
|
return ["alive"]
|
54
55
|
|
55
56
|
@property
|
@@ -77,7 +78,7 @@ class RateTransition(Transition):
|
|
77
78
|
self,
|
78
79
|
input_state: "BaseDiseaseState",
|
79
80
|
output_state: "BaseDiseaseState",
|
80
|
-
get_data_functions:
|
81
|
+
get_data_functions: dict[str, Callable] = None,
|
81
82
|
triggered=Trigger.NOT_TRIGGERED,
|
82
83
|
):
|
83
84
|
super().__init__(
|
@@ -108,7 +109,7 @@ class RateTransition(Transition):
|
|
108
109
|
# Setup methods #
|
109
110
|
#################
|
110
111
|
|
111
|
-
def load_transition_rate(self, builder: Builder) ->
|
112
|
+
def load_transition_rate(self, builder: Builder) -> float | pd.DataFrame:
|
112
113
|
if "incidence_rate" in self._get_data_functions:
|
113
114
|
rate_data = self._get_data_functions["incidence_rate"](
|
114
115
|
builder, self.output_state.state_id
|
@@ -152,11 +153,11 @@ class ProportionTransition(Transition):
|
|
152
153
|
##############
|
153
154
|
|
154
155
|
@property
|
155
|
-
def configuration_defaults(self) ->
|
156
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
156
157
|
return {
|
157
158
|
f"{self.name}": {
|
158
159
|
"data_sources": {
|
159
|
-
"proportion":
|
160
|
+
"proportion": self.load_proportion,
|
160
161
|
},
|
161
162
|
},
|
162
163
|
}
|
@@ -169,7 +170,7 @@ class ProportionTransition(Transition):
|
|
169
170
|
self,
|
170
171
|
input_state: "BaseDiseaseState",
|
171
172
|
output_state: "BaseDiseaseState",
|
172
|
-
get_data_functions:
|
173
|
+
get_data_functions: dict[str, Callable] = None,
|
173
174
|
triggered=Trigger.NOT_TRIGGERED,
|
174
175
|
):
|
175
176
|
super().__init__(
|
@@ -183,7 +184,7 @@ class ProportionTransition(Transition):
|
|
183
184
|
# Setup methods #
|
184
185
|
#################
|
185
186
|
|
186
|
-
def load_proportion(self, builder: Builder) ->
|
187
|
+
def load_proportion(self, builder: Builder) -> float | pd.DataFrame:
|
187
188
|
if "proportion" not in self._get_data_functions:
|
188
189
|
raise ValueError("Must supply a proportion function")
|
189
190
|
return self._get_data_functions["proportion"](builder, self.output_state.state_id)
|
@@ -8,7 +8,7 @@ lifetable simulation.
|
|
8
8
|
|
9
9
|
"""
|
10
10
|
|
11
|
-
from typing import Any
|
11
|
+
from typing import Any
|
12
12
|
|
13
13
|
import numpy as np
|
14
14
|
import pandas as pd
|
@@ -93,7 +93,7 @@ class DelayedRisk(Component):
|
|
93
93
|
##############
|
94
94
|
|
95
95
|
@property
|
96
|
-
def configuration_defaults(self) ->
|
96
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
97
97
|
return {
|
98
98
|
self.risk: {
|
99
99
|
"constant_prevalence": False,
|
@@ -103,15 +103,15 @@ class DelayedRisk(Component):
|
|
103
103
|
}
|
104
104
|
|
105
105
|
@property
|
106
|
-
def columns_created(self) ->
|
106
|
+
def columns_created(self) -> list[str]:
|
107
107
|
return self._bin_names
|
108
108
|
|
109
109
|
@property
|
110
|
-
def columns_required(self) ->
|
110
|
+
def columns_required(self) -> list[str] | None:
|
111
111
|
return ["age", "sex", "population"]
|
112
112
|
|
113
113
|
@property
|
114
|
-
def initialization_requirements(self) ->
|
114
|
+
def initialization_requirements(self) -> dict[str, list[str]]:
|
115
115
|
return {
|
116
116
|
"requires_columns": ["age", "sex", "population"],
|
117
117
|
"requires_values": [],
|
@@ -8,7 +8,7 @@ simulations.
|
|
8
8
|
|
9
9
|
"""
|
10
10
|
|
11
|
-
from typing import Any
|
11
|
+
from typing import Any
|
12
12
|
|
13
13
|
import numpy as np
|
14
14
|
import pandas as pd
|
@@ -143,7 +143,7 @@ class Disease(Component):
|
|
143
143
|
##############
|
144
144
|
|
145
145
|
@property
|
146
|
-
def configuration_defaults(self) ->
|
146
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
147
147
|
return {
|
148
148
|
self.disease: {
|
149
149
|
"simplified_no_remission_equations": False,
|
@@ -151,7 +151,7 @@ class Disease(Component):
|
|
151
151
|
}
|
152
152
|
|
153
153
|
@property
|
154
|
-
def columns_created(self) ->
|
154
|
+
def columns_created(self) -> list[str]:
|
155
155
|
columns = []
|
156
156
|
for scenario in ["", "_intervention"]:
|
157
157
|
for rate in ["_S", "_C"]:
|
@@ -160,11 +160,11 @@ class Disease(Component):
|
|
160
160
|
return columns
|
161
161
|
|
162
162
|
@property
|
163
|
-
def columns_required(self) ->
|
163
|
+
def columns_required(self) -> list[str] | None:
|
164
164
|
return ["age", "sex"]
|
165
165
|
|
166
166
|
@property
|
167
|
-
def initialization_requirements(self) ->
|
167
|
+
def initialization_requirements(self) -> dict[str, list[str]]:
|
168
168
|
return {
|
169
169
|
"requires_columns": ["age", "sex"],
|
170
170
|
"requires_values": [],
|
@@ -8,7 +8,7 @@ simulations.
|
|
8
8
|
|
9
9
|
"""
|
10
10
|
|
11
|
-
from typing import Any
|
11
|
+
from typing import Any
|
12
12
|
|
13
13
|
from vivarium import Component
|
14
14
|
from vivarium.framework.engine import Builder
|
@@ -22,7 +22,7 @@ class ModifyAllCauseMortality(Component):
|
|
22
22
|
##############
|
23
23
|
|
24
24
|
@property
|
25
|
-
def configuration_defaults(self) ->
|
25
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
26
26
|
return {
|
27
27
|
"intervention": {
|
28
28
|
self.intervention: {
|
@@ -62,7 +62,7 @@ class ModifyDiseaseRate(Component):
|
|
62
62
|
##############
|
63
63
|
|
64
64
|
@property
|
65
|
-
def configuration_defaults(self) ->
|
65
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
66
66
|
return {
|
67
67
|
"intervention": {
|
68
68
|
self.intervention: {
|
@@ -144,7 +144,7 @@ class ModifyAcuteDiseaseIncidence(Component):
|
|
144
144
|
##############
|
145
145
|
|
146
146
|
@property
|
147
|
-
def configuration_defaults(self) ->
|
147
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
148
148
|
return {
|
149
149
|
"intervention": {
|
150
150
|
self.intervention: {
|
@@ -187,7 +187,7 @@ class ModifyAcuteDiseaseMorbidity(Component):
|
|
187
187
|
##############
|
188
188
|
|
189
189
|
@property
|
190
|
-
def configuration_defaults(self) ->
|
190
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
191
191
|
return {
|
192
192
|
"intervention": {
|
193
193
|
self.intervention: {
|
@@ -228,7 +228,7 @@ class ModifyAcuteDiseaseMortality(Component):
|
|
228
228
|
##############
|
229
229
|
|
230
230
|
@property
|
231
|
-
def configuration_defaults(self) ->
|
231
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
232
232
|
return {
|
233
233
|
"intervention": {
|
234
234
|
self.intervention: {
|
@@ -269,7 +269,7 @@ class TobaccoFreeGeneration(Component):
|
|
269
269
|
##############
|
270
270
|
|
271
271
|
@property
|
272
|
-
def configuration_defaults(self) ->
|
272
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
273
273
|
return {
|
274
274
|
"tobacco_free_generation": {
|
275
275
|
"year": 2020,
|
@@ -310,7 +310,7 @@ class TobaccoEradication(Component):
|
|
310
310
|
##############
|
311
311
|
|
312
312
|
@property
|
313
|
-
def configuration_defaults(self) ->
|
313
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
314
314
|
return {
|
315
315
|
"tobacco_eradication": {
|
316
316
|
"year": 2020,
|
@@ -8,7 +8,7 @@ multi-state lifetable simulations.
|
|
8
8
|
|
9
9
|
"""
|
10
10
|
|
11
|
-
from typing import Any
|
11
|
+
from typing import Any
|
12
12
|
|
13
13
|
from vivarium import Component
|
14
14
|
from vivarium.framework.engine import Builder
|
@@ -73,7 +73,7 @@ class ModifyAcuteDiseaseYLD(Component):
|
|
73
73
|
##############
|
74
74
|
|
75
75
|
@property
|
76
|
-
def configuration_defaults(self) ->
|
76
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
77
77
|
return {
|
78
78
|
"intervention": {
|
79
79
|
self.disease: {
|
@@ -112,7 +112,7 @@ class ModifyAcuteDiseaseMortality(Component):
|
|
112
112
|
##############
|
113
113
|
|
114
114
|
@property
|
115
|
-
def configuration_defaults(self) ->
|
115
|
+
def configuration_defaults(self) -> dict[str, Any]:
|
116
116
|
return {
|
117
117
|
"intervention": {
|
118
118
|
self.disease: {
|
@@ -8,8 +8,6 @@ multi-state lifetable simulations.
|
|
8
8
|
|
9
9
|
"""
|
10
10
|
|
11
|
-
from typing import List, Optional
|
12
|
-
|
13
11
|
import pandas as pd
|
14
12
|
from vivarium import Component
|
15
13
|
from vivarium.framework.engine import Builder
|
@@ -76,7 +74,7 @@ class MorbidityMortality(Component):
|
|
76
74
|
##############
|
77
75
|
|
78
76
|
@property
|
79
|
-
def columns_required(self) ->
|
77
|
+
def columns_required(self) -> list[str] | None:
|
80
78
|
return [
|
81
79
|
"age",
|
82
80
|
"sex",
|
@@ -224,7 +222,7 @@ class Disease(Component):
|
|
224
222
|
##############
|
225
223
|
|
226
224
|
@property
|
227
|
-
def columns_required(self) ->
|
225
|
+
def columns_required(self) -> list[str] | None:
|
228
226
|
return [
|
229
227
|
"age",
|
230
228
|
"sex",
|
@@ -238,7 +236,7 @@ class Disease(Component):
|
|
238
236
|
# Lifecycle methods #
|
239
237
|
#####################
|
240
238
|
|
241
|
-
def __init__(self, disease: str, output_suffix:
|
239
|
+
def __init__(self, disease: str, output_suffix: str | None = None):
|
242
240
|
super().__init__()
|
243
241
|
self.disease = disease
|
244
242
|
if output_suffix is None:
|
@@ -335,7 +333,7 @@ class TobaccoPrevalence(Component):
|
|
335
333
|
##############
|
336
334
|
|
337
335
|
@property
|
338
|
-
def columns_required(self) ->
|
336
|
+
def columns_required(self) -> list[str] | None:
|
339
337
|
return ["age", "sex", "bau_population", "population"] + self._bin_names
|
340
338
|
|
341
339
|
#####################
|