Skip to content

Commit 00cd03f

Browse files
authored
add docstrings for build_all_lookup_tables custom behavior (#562)
* add docstrings for build_all_lookup_tables custom behavior * [COPILOT] Add documentation to config defaults * remove types from data sources args * my edits to config defaults * formatting * remove return blocks * use consistent structure * clarify docstring around PAF * empty commit * Update CHANGELOG for version 4.3.15 Added documentation for configuration defaults and build_all_lookup_table overrides.
1 parent fade52c commit 00cd03f

File tree

17 files changed

+614
-4
lines changed

17 files changed

+614
-4
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**4.3.16 - 12/15/25**
2+
3+
- Add documentation for configuration defaults and build_all_lookup_table overrides
4+
15
**4.3.15 - 12/12/25**
26

37
- Update PublicHealthObserver to use empty string as default value for required columns

src/vivarium_public_health/disease/model.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ class DiseaseModel(Machine):
3434

3535
@property
3636
def configuration_defaults(self) -> dict[str, Any]:
37+
"""Provides default configuration values for this disease model.
38+
39+
Configuration structure::
40+
41+
{disease_name}:
42+
data_sources:
43+
cause_specific_mortality_rate:
44+
Source for cause-specific mortality rate (CSMR) data.
45+
Default uses the ``load_cause_specific_mortality_rate``
46+
method which loads from artifact at
47+
``cause.{cause_name}.cause_specific_mortality_rate``.
48+
"""
3749
return {
3850
f"{self.name}": {
3951
"data_sources": {

src/vivarium_public_health/disease/special_disease.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,39 @@ def name(self):
9797

9898
@property
9999
def configuration_defaults(self) -> dict[str, Any]:
100+
"""Provides default configuration values for this component.
101+
102+
Configuration structure::
103+
104+
{component_name}:
105+
data_sources:
106+
raw_disability_weight:
107+
Source for disability weight data. Default is the
108+
artifact key ``{cause}.disability_weight``.
109+
cause_specific_mortality_rate:
110+
Source for cause-specific mortality rate data. Default
111+
uses ``load_cause_specific_mortality_rate_data`` method
112+
which loads from artifact if ``mortality`` is True.
113+
excess_mortality_rate:
114+
Source for excess mortality rate data. Default uses
115+
``load_excess_mortality_rate_data`` method which loads
116+
from artifact if ``mortality`` is True.
117+
population_attributable_fraction:
118+
Source for PAF data. Default is 0, indicating no
119+
mediated effects from other risks.
120+
threshold: str or list
121+
Exposure threshold defining disease state. For continuous
122+
risks, provide a string like ``">7"`` or ``"<5"``.
123+
For categorical risks, provide a list of categories
124+
(e.g., ``['cat1', 'cat2']``).
125+
mortality: bool
126+
Whether this disease has associated mortality. Default
127+
is True.
128+
recoverable: bool
129+
Whether simulants can recover from this disease when
130+
their exposure falls outside the threshold. Default
131+
is True.
132+
"""
100133
return {
101134
self.name: {
102135
"data_sources": {

src/vivarium_public_health/disease/state.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
This module contains tools to manage standard disease states.
77
88
"""
9+
910
import warnings
1011
from collections.abc import Callable
1112
from typing import Any
@@ -37,6 +38,24 @@ class BaseDiseaseState(State):
3738

3839
@property
3940
def configuration_defaults(self) -> dict[str, Any]:
41+
"""Provides default configuration values for this state.
42+
43+
Extends the parent State's configuration with disease-specific
44+
data sources for prevalence.
45+
46+
Configuration structure::
47+
48+
{component_name}:
49+
data_sources:
50+
prevalence:
51+
Source for prevalence data used to initialize simulants
52+
into this state. Default is the value set on the instance
53+
(typically 0.0).
54+
birth_prevalence:
55+
Source for birth prevalence data used to initialize
56+
newborn simulants. Default is the value set on the
57+
instance (typically 0.0).
58+
"""
4059
configuration_defaults = super().configuration_defaults
4160
additional_defaults = {
4261
"prevalence": self.prevalence,
@@ -330,6 +349,42 @@ def initialization_requirements(self) -> list[str | Resource]:
330349

331350
@property
332351
def configuration_defaults(self) -> dict[str, Any]:
352+
"""Provides default configuration values for this disease state.
353+
354+
Extends BaseDiseaseState's configuration with additional data sources
355+
for disease burden metrics.
356+
357+
Configuration structure::
358+
359+
{component_name}:
360+
data_sources:
361+
prevalence:
362+
Source for prevalence data. Defaults to the
363+
``prevalence`` constructor argument, or if not
364+
provided, loads from artifact at
365+
``cause.{state_id}.prevalence``.
366+
birth_prevalence:
367+
Source for birth prevalence data. Defaults to the
368+
``birth_prevalence`` constructor argument, or if not
369+
provided, loads from artifact at
370+
``cause.{state_id}.birth_prevalence``.
371+
dwell_time:
372+
Source for dwell time data (minimum time in state
373+
before transition). Defaults to the ``dwell_time``
374+
constructor argument, or if not provided, defaults
375+
to 0 (no minimum dwell time).
376+
disability_weight:
377+
Source for disability weight data used to calculate
378+
years lived with disability (YLDs). Defaults to the
379+
``disability_weight`` constructor argument, or if not
380+
provided, loads from artifact at
381+
``cause.{state_id}.disability_weight``.
382+
excess_mortality_rate:
383+
Source for excess mortality rate data. Defaults to the
384+
``excess_mortality_rate`` constructor argument, or if
385+
not provided, loads from artifact at
386+
``cause.{state_id}.excess_mortality_rate``.
387+
"""
333388
configuration_defaults = super().configuration_defaults
334389
additional_defaults = {
335390
"prevalence": self._prevalence_source,

src/vivarium_public_health/disease/transition.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
This module contains tools to model transitions between disease states.
77
88
"""
9+
910
import warnings
1011
from collections.abc import Callable
1112
from typing import TYPE_CHECKING, Any
@@ -43,6 +44,20 @@ class RateTransition(Transition):
4344

4445
@property
4546
def configuration_defaults(self) -> dict[str, Any]:
47+
"""Provides default configuration values for this transition.
48+
49+
Configuration structure::
50+
51+
{transition_name}:
52+
data_sources:
53+
transition_rate:
54+
Source for transition rate data. The default value is
55+
determined by the ``transition_rate`` constructor argument.
56+
rate_conversion_type: str
57+
Method for converting rates to probabilities. Options
58+
are ``"linear"`` (default) or ``"exponential"``. Linear
59+
uses ``rate * dt``, exponential uses ``1 - exp(-rate * dt)``.
60+
"""
4661
return {
4762
f"{self.name}": {
4863
"data_sources": {
@@ -202,6 +217,18 @@ class ProportionTransition(Transition):
202217

203218
@property
204219
def configuration_defaults(self) -> dict[str, Any]:
220+
"""Provides default configuration values for this transition.
221+
222+
Configuration structure::
223+
224+
{transition_name}:
225+
data_sources:
226+
proportion:
227+
Source for the proportion of simulants transitioning
228+
at each time step. The default uses the
229+
``load_proportion`` method which resolves data from
230+
the ``proportion`` constructor argument.
231+
"""
205232
return {
206233
f"{self.name}": {
207234
"data_sources": {

src/vivarium_public_health/mslt/delay.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ class DelayedRisk(Component):
9595

9696
@property
9797
def configuration_defaults(self) -> dict[str, Any]:
98+
"""Provides default configuration values for this component.
99+
100+
Configuration structure::
101+
102+
{risk_name}:
103+
constant_prevalence: bool
104+
If True, smoking prevalence remains constant over time
105+
(no remission). If False, prevalence can change as
106+
simulants quit smoking. Default is False.
107+
tobacco_tax: bool
108+
If True, applies tobacco tax intervention effects.
109+
Default is False.
110+
delay: int
111+
Number of years of delay before health effects manifest
112+
after exposure changes. Default is 20 years.
113+
"""
98114
return {
99115
self.risk: {
100116
"constant_prevalence": False,

src/vivarium_public_health/mslt/disease.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ class Disease(Component):
149149

150150
@property
151151
def configuration_defaults(self) -> dict[str, Any]:
152+
"""Provides default configuration values for this disease model.
153+
154+
Configuration structure::
155+
156+
{disease_name}:
157+
simplified_no_remission_equations: bool
158+
If True, uses simplified differential equations for
159+
diseases with no remission. This can improve
160+
computational efficiency. Default is False.
161+
"""
152162
return {
153163
self.disease: {
154164
"simplified_no_remission_equations": False,

src/vivarium_public_health/mslt/intervention.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ class ModifyAllCauseMortality(Component):
2323

2424
@property
2525
def configuration_defaults(self) -> dict[str, Any]:
26+
"""Provides default configuration values for this intervention.
27+
28+
Configuration structure::
29+
30+
intervention:
31+
{intervention_name}:
32+
scale: float
33+
Multiplicative factor applied to all-cause mortality
34+
rate. Values < 1 reduce mortality, values > 1
35+
increase mortality. Default is 1.0 (no effect).
36+
"""
2637
return {
2738
"intervention": {
2839
self.intervention: {
@@ -65,6 +76,17 @@ class ModifyDiseaseRate(Component):
6576

6677
@property
6778
def configuration_defaults(self) -> dict[str, Any]:
79+
"""Provides default configuration values for this intervention.
80+
81+
Configuration structure::
82+
83+
intervention:
84+
{intervention_name}:
85+
{disease}_{rate}_scale: float
86+
Multiplicative factor applied to the specified
87+
disease rate. Values < 1 reduce the rate, values > 1
88+
increase it. Default is 1.0 (no effect).
89+
"""
6890
return {
6991
"intervention": {
7092
self.intervention: {
@@ -147,6 +169,18 @@ class ModifyAcuteDiseaseIncidence(Component):
147169

148170
@property
149171
def configuration_defaults(self) -> dict[str, Any]:
172+
"""Provides default configuration values for this intervention.
173+
174+
Configuration structure::
175+
176+
intervention:
177+
{intervention_name}:
178+
incidence_scale: float
179+
Multiplicative factor applied to both disability
180+
and mortality rates for the acute disease. Values < 1
181+
reduce incidence, values > 1 increase it.
182+
Default is 1.0 (no effect).
183+
"""
150184
return {
151185
"intervention": {
152186
self.intervention: {
@@ -190,6 +224,17 @@ class ModifyAcuteDiseaseMorbidity(Component):
190224

191225
@property
192226
def configuration_defaults(self) -> dict[str, Any]:
227+
"""Provides default configuration values for this intervention.
228+
229+
Configuration structure::
230+
231+
intervention:
232+
{intervention_name}:
233+
yld_scale: float
234+
Multiplicative factor applied to the disability
235+
(YLD) rate. Values < 1 reduce disability, values > 1
236+
increase it. Default is 1.0 (no effect).
237+
"""
193238
return {
194239
"intervention": {
195240
self.intervention: {
@@ -233,6 +278,17 @@ class ModifyAcuteDiseaseMortality(Component):
233278

234279
@property
235280
def configuration_defaults(self) -> dict[str, Any]:
281+
"""Provides default configuration values for this intervention.
282+
283+
Configuration structure::
284+
285+
intervention:
286+
{intervention_name}:
287+
mortality_scale: float
288+
Multiplicative factor applied to the acute disease
289+
mortality rate. Values < 1 reduce mortality,
290+
values > 1 increase it. Default is 1.0 (no effect).
291+
"""
236292
return {
237293
"intervention": {
238294
self.intervention: {
@@ -274,6 +330,16 @@ class TobaccoFreeGeneration(Component):
274330

275331
@property
276332
def configuration_defaults(self) -> dict[str, Any]:
333+
"""Provides default configuration values for this intervention.
334+
335+
Configuration structure::
336+
337+
tobacco_free_generation:
338+
year: int
339+
Year when tobacco initiation stops completely.
340+
Starting from this year, no new tobacco uptake occurs
341+
(incidence rate becomes zero). Default is 2020.
342+
"""
277343
return {
278344
"tobacco_free_generation": {
279345
"year": 2020,
@@ -315,6 +381,17 @@ class TobaccoEradication(Component):
315381

316382
@property
317383
def configuration_defaults(self) -> dict[str, Any]:
384+
"""Provides default configuration values for this intervention.
385+
386+
Configuration structure::
387+
388+
tobacco_eradication:
389+
year: int
390+
Year when all tobacco use is eradicated. Starting from
391+
this year, incidence becomes zero (no new uptake) and
392+
remission becomes 100% (all users quit).
393+
Default is 2020.
394+
"""
318395
return {
319396
"tobacco_eradication": {
320397
"year": 2020,

src/vivarium_public_health/mslt/magic_wand_components.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ class ModifyAcuteDiseaseYLD(Component):
8080

8181
@property
8282
def configuration_defaults(self) -> dict[str, Any]:
83+
"""Provides default configuration values for this intervention.
84+
85+
Configuration structure::
86+
87+
intervention:
88+
{disease_name}:
89+
yld_scale: float
90+
Multiplicative factor applied to the years lived
91+
with disability (YLD) rate. Values < 1 reduce
92+
disability, values > 1 increase it. Must be >= 0.
93+
Default is 1.0 (no effect).
94+
"""
8395
return {
8496
"intervention": {
8597
self.disease: {
@@ -121,6 +133,17 @@ class ModifyAcuteDiseaseMortality(Component):
121133

122134
@property
123135
def configuration_defaults(self) -> dict[str, Any]:
136+
"""Provides default configuration values for this intervention.
137+
138+
Configuration structure::
139+
140+
intervention:
141+
{disease_name}:
142+
mortality_scale: float
143+
Multiplicative factor applied to the excess mortality
144+
rate. Values < 1 reduce mortality, values > 1
145+
increase it. Must be >= 0. Default is 1.0 (no effect).
146+
"""
124147
return {
125148
"intervention": {
126149
self.disease: {

0 commit comments

Comments
 (0)