vivarium-public-health 3.1.2__tar.gz → 3.1.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/CHANGELOG.rst +4 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/PKG-INFO +1 -1
- vivarium_public_health-3.1.3/src/vivarium_public_health/_version.py +1 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/effect.py +35 -23
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py +3 -4
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/PKG-INFO +1 -1
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_effect.py +40 -0
- vivarium_public_health-3.1.2/src/vivarium_public_health/_version.py +0 -1
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.bandit +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.flake8 +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.gitattributes +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/CODEOWNERS +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/pull_request_template.md +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/workflows/build.yml +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/workflows/deploy.yml +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.gitignore +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.pylintrc +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.readthedocs.yml +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.zenodo.json +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/CODE_OF_CONDUCT.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/CONTRIBUTING.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/Jenkinsfile +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/LICENSE.txt +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/MANIFEST.in +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/Makefile +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/README.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/Makefile +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/nitpick-exceptions +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/_static/style.css +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/_templates/layout.html +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/model.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/models.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/special_disease.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/state.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/transition.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/delay.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/disease.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/intervention.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/magic_wand_components.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/observer.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/population.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/plugins/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/plugins/parser.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/add_new_birth_cohorts.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/base_population.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/data_transformations.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/mortality.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/disability.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/disease.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/mortality.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/observer.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/risk.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/simple_cause.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/stratification.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/base_risk.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/data_transformations.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/distributions.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/effect.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/implementations/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/implementations/low_birth_weight_and_short_gestation.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/magic_wand.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/scale_up.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/therapeutic_inertia.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/utilities.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/conf.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/tutorials/index.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/tutorials/risk_exposure.rst +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/pyproject.toml +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/setup.cfg +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/setup.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/__about__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/model.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/models.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/special_disease.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/state.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/transition.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/delay.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/disease.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/intervention.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/magic_wand_components.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/observer.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/population.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/plugins/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/plugins/parser.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/add_new_birth_cohorts.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/base_population.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/data_transformations.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/mortality.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/columns.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/disability.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/disease.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/mortality.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/observer.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/risk.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/simple_cause.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/stratification.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/base_risk.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/data_transformations.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/distributions.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/implementations/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/magic_wand.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/scale_up.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/therapeutic_inertia.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/utilities.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/SOURCES.txt +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/dependency_links.txt +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/not-zip-safe +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/requires.txt +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/top_level.txt +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/conftest.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/disease/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/disease/test_disease.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/disease/test_special_disease.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/mock_artifact.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/plugins/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/plugins/test_parser.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/conftest.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_add_new_birth_cohort.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_base_population.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_data_transformations.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_mortality.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_categorical_risk_observer.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disability.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disability_observer.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disease_observer.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_mortality_observer.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_stratification.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/conftest.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_base_risk.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_data_transformations.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_distributions.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_low_birth_weight_and_short_gestation.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/test_utilities.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/treatment/__init__.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/treatment/test_scale_up.py +0 -0
- {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tox.ini +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: vivarium_public_health
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.3
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "3.1.3"
|
@@ -17,6 +17,7 @@ import scipy
|
|
17
17
|
from layered_config_tree import ConfigurationError
|
18
18
|
from vivarium import Component
|
19
19
|
from vivarium.framework.engine import Builder
|
20
|
+
from vivarium.framework.values import Pipeline
|
20
21
|
|
21
22
|
from vivarium_public_health.risks import Risk
|
22
23
|
from vivarium_public_health.risks.data_transformations import (
|
@@ -112,7 +113,8 @@ class RiskEffect(Component):
|
|
112
113
|
def setup(self, builder: Builder) -> None:
|
113
114
|
self.exposure = self.get_risk_exposure(builder)
|
114
115
|
|
115
|
-
self.
|
116
|
+
self._relative_risk_source = self.get_relative_risk_source(builder)
|
117
|
+
self.relative_risk = self.get_relative_risk(builder)
|
116
118
|
|
117
119
|
self.register_target_modifier(builder)
|
118
120
|
self.register_paf_modifier(builder)
|
@@ -124,7 +126,7 @@ class RiskEffect(Component):
|
|
124
126
|
def build_all_lookup_tables(self, builder: Builder) -> None:
|
125
127
|
self._exposure_distribution_type = self.get_distribution_type(builder)
|
126
128
|
|
127
|
-
rr_data = self.
|
129
|
+
rr_data = self.load_relative_risk(builder)
|
128
130
|
rr_value_cols = None
|
129
131
|
if self.is_exposure_categorical:
|
130
132
|
rr_data, rr_value_cols = self.process_categorical_data(builder, rr_data)
|
@@ -146,7 +148,7 @@ class RiskEffect(Component):
|
|
146
148
|
return risk_exposure_component.distribution_type
|
147
149
|
return risk_exposure_component.get_distribution_type(builder)
|
148
150
|
|
149
|
-
def
|
151
|
+
def load_relative_risk(
|
150
152
|
self,
|
151
153
|
builder: Builder,
|
152
154
|
configuration=None,
|
@@ -260,24 +262,27 @@ class RiskEffect(Component):
|
|
260
262
|
def get_risk_exposure(self, builder: Builder) -> Callable[[pd.Index], pd.Series]:
|
261
263
|
return builder.value.get_value(self.exposure_pipeline_name)
|
262
264
|
|
263
|
-
def
|
264
|
-
|
265
|
-
|
265
|
+
def adjust_target(self, index: pd.Index, target: pd.Series) -> pd.Series:
|
266
|
+
relative_risk = self.relative_risk(index)
|
267
|
+
return target * relative_risk
|
268
|
+
|
269
|
+
def get_relative_risk_source(self, builder: Builder) -> Callable[[pd.Index], pd.Series]:
|
270
|
+
|
266
271
|
if not self.is_exposure_categorical:
|
267
272
|
tmred = builder.data.load(f"{self.risk}.tmred")
|
268
273
|
tmrel = 0.5 * (tmred["min"] + tmred["max"])
|
269
274
|
scale = builder.data.load(f"{self.risk}.relative_risk_scalar")
|
270
275
|
|
271
|
-
def
|
276
|
+
def generate_relative_risk(index: pd.Index) -> pd.Series:
|
272
277
|
rr = self.lookup_tables["relative_risk"](index)
|
273
278
|
exposure = self.exposure(index)
|
274
279
|
relative_risk = np.maximum(rr.values ** ((exposure - tmrel) / scale), 1)
|
275
|
-
return
|
280
|
+
return relative_risk
|
276
281
|
|
277
282
|
else:
|
278
283
|
index_columns = ["index", self.risk.name]
|
279
284
|
|
280
|
-
def
|
285
|
+
def generate_relative_risk(index: pd.Index) -> pd.Series:
|
281
286
|
rr = self.lookup_tables["relative_risk"](index)
|
282
287
|
exposure = self.exposure(index).reset_index()
|
283
288
|
exposure.columns = index_columns
|
@@ -288,16 +293,24 @@ class RiskEffect(Component):
|
|
288
293
|
relative_risk = relative_risk.set_index(index_columns)
|
289
294
|
|
290
295
|
effect = relative_risk.loc[exposure.index, "value"].droplevel(self.risk.name)
|
291
|
-
|
292
|
-
return affected_rates
|
296
|
+
return effect
|
293
297
|
|
294
|
-
return
|
298
|
+
return generate_relative_risk
|
299
|
+
|
300
|
+
def get_relative_risk(self, builder: Builder) -> Pipeline:
|
301
|
+
return builder.value.register_value_producer(
|
302
|
+
f"{self.risk.name}_on_{self.target.name}.relative_risk",
|
303
|
+
self._relative_risk_source,
|
304
|
+
component=self,
|
305
|
+
required_resources=[self.exposure],
|
306
|
+
)
|
295
307
|
|
296
308
|
def register_target_modifier(self, builder: Builder) -> None:
|
297
309
|
builder.value.register_value_modifier(
|
298
310
|
self.target_pipeline_name,
|
299
|
-
modifier=self.
|
300
|
-
|
311
|
+
modifier=self.adjust_target,
|
312
|
+
component=self,
|
313
|
+
required_resources=[self.relative_risk],
|
301
314
|
)
|
302
315
|
|
303
316
|
def register_paf_modifier(self, builder: Builder) -> None:
|
@@ -307,7 +320,8 @@ class RiskEffect(Component):
|
|
307
320
|
builder.value.register_value_modifier(
|
308
321
|
self.target_paf_pipeline_name,
|
309
322
|
modifier=self.lookup_tables["population_attributable_fraction"],
|
310
|
-
|
323
|
+
component=self,
|
324
|
+
required_resources=required_columns,
|
311
325
|
)
|
312
326
|
|
313
327
|
##################
|
@@ -371,7 +385,7 @@ class NonLogLinearRiskEffect(RiskEffect):
|
|
371
385
|
return f"non_log_linear_risk_effect.{risk.name}_on_{target}"
|
372
386
|
|
373
387
|
def build_all_lookup_tables(self, builder: Builder) -> None:
|
374
|
-
rr_data = self.
|
388
|
+
rr_data = self.load_relative_risk(builder)
|
375
389
|
self.validate_rr_data(rr_data)
|
376
390
|
|
377
391
|
def define_rr_intervals(df: pd.DataFrame) -> pd.DataFrame:
|
@@ -415,7 +429,7 @@ class NonLogLinearRiskEffect(RiskEffect):
|
|
415
429
|
builder, paf_data
|
416
430
|
)
|
417
431
|
|
418
|
-
def
|
432
|
+
def load_relative_risk(
|
419
433
|
self,
|
420
434
|
builder: Builder,
|
421
435
|
configuration=None,
|
@@ -472,10 +486,8 @@ class NonLogLinearRiskEffect(RiskEffect):
|
|
472
486
|
|
473
487
|
return rr_data
|
474
488
|
|
475
|
-
def
|
476
|
-
|
477
|
-
) -> Callable[[pd.Index, pd.Series], pd.Series]:
|
478
|
-
def adjust_target(index: pd.Index, target: pd.Series) -> pd.Series:
|
489
|
+
def get_relative_risk_source(self, builder: Builder) -> Callable[[pd.Index], pd.Series]:
|
490
|
+
def generate_relative_risk(index: pd.Index) -> pd.Series:
|
479
491
|
rr_intervals = self.lookup_tables["relative_risk"](index)
|
480
492
|
exposure = self.population_view.get(index)[f"{self.risk.name}_exposure"]
|
481
493
|
x1, x2 = (
|
@@ -486,9 +498,9 @@ class NonLogLinearRiskEffect(RiskEffect):
|
|
486
498
|
m = (y2 - y1) / (x2 - x1)
|
487
499
|
b = y1 - m * x1
|
488
500
|
relative_risk = b + m * exposure
|
489
|
-
return
|
501
|
+
return relative_risk
|
490
502
|
|
491
|
-
return
|
503
|
+
return generate_relative_risk
|
492
504
|
|
493
505
|
##############
|
494
506
|
# Validators #
|
@@ -336,7 +336,6 @@ class LBWSGRiskEffect(RiskEffect):
|
|
336
336
|
|
337
337
|
super().setup(builder)
|
338
338
|
self.interpolator = self.get_interpolator(builder)
|
339
|
-
self.relative_risk = self.get_relative_risk_pipeline(builder)
|
340
339
|
|
341
340
|
#################
|
342
341
|
# Setup methods #
|
@@ -393,10 +392,10 @@ class LBWSGRiskEffect(RiskEffect):
|
|
393
392
|
for age_start in exposed_age_group_starts
|
394
393
|
}
|
395
394
|
|
396
|
-
def
|
395
|
+
def get_relative_risk(self, builder: Builder) -> Pipeline:
|
397
396
|
return builder.value.register_value_producer(
|
398
397
|
self.relative_risk_pipeline_name,
|
399
|
-
source=self.
|
398
|
+
source=self.get_relative_risk_source,
|
400
399
|
requires_columns=["age"] + self.rr_column_names,
|
401
400
|
)
|
402
401
|
|
@@ -470,7 +469,7 @@ class LBWSGRiskEffect(RiskEffect):
|
|
470
469
|
# Pipeline sources and modifiers #
|
471
470
|
##################################
|
472
471
|
|
473
|
-
def
|
472
|
+
def get_relative_risk_source(self, index: pd.Index) -> pd.Series:
|
474
473
|
pop = self.population_view.get(index)
|
475
474
|
relative_risk = pd.Series(1.0, index=index, name=self.relative_risk_pipeline_name)
|
476
475
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: vivarium_public_health
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.3
|
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
|
@@ -606,3 +606,43 @@ def test_non_loglinear_effect(rr_parameter_data, error_message, base_config, bas
|
|
606
606
|
)
|
607
607
|
|
608
608
|
assert np.isclose(rate.values, expected_values, rtol=0.0000001).all()
|
609
|
+
|
610
|
+
|
611
|
+
def test_relative_risk_pipeline(dichotomous_risk, base_config, base_plugins):
|
612
|
+
risk = dichotomous_risk[0]
|
613
|
+
effect = RiskEffect(risk.name, "cause.test_cause.incidence_rate")
|
614
|
+
base_config.update({"risk_factor.test_risk": {"data_sources": {"exposure": 0.75}}})
|
615
|
+
|
616
|
+
# TMREL of 1
|
617
|
+
tmred = {"distribution": "uniform", "min": 1, "max": 1, "inverted": False}
|
618
|
+
|
619
|
+
data = {
|
620
|
+
f"{risk.name}.tmred": tmred,
|
621
|
+
f"{risk.name}.population_attributable_fraction": 0,
|
622
|
+
"cause.test_cause.incidence_rate": 1,
|
623
|
+
}
|
624
|
+
rr_value = 1.4
|
625
|
+
base_config.update(
|
626
|
+
{
|
627
|
+
"risk_effect.test_risk_on_cause.test_cause.incidence_rate": {
|
628
|
+
"data_sources": {"relative_risk": rr_value}
|
629
|
+
}
|
630
|
+
}
|
631
|
+
)
|
632
|
+
|
633
|
+
base_config.update({"risk_factor.test_risk": {"distribution_type": "dichotomous"}})
|
634
|
+
sim = _setup_risk_effect_simulation(base_config, base_plugins, risk, effect, data)
|
635
|
+
pop = sim.get_population()
|
636
|
+
|
637
|
+
expected_pipeline_name = f"{effect.risk.name}_on_{effect.target.name}.relative_risk"
|
638
|
+
assert expected_pipeline_name in sim.list_values()
|
639
|
+
|
640
|
+
rr_mapper = {
|
641
|
+
"cat1": 1.4,
|
642
|
+
"cat2": 1.0,
|
643
|
+
}
|
644
|
+
for exposure in rr_mapper:
|
645
|
+
exposure_pipeline = sim.get_value(f"{effect.risk.name}.exposure")(pop.index)
|
646
|
+
exposure_idx = exposure_pipeline.loc[exposure_pipeline == exposure].index
|
647
|
+
relative_risk = sim.get_value(expected_pipeline_name)(exposure_idx)
|
648
|
+
assert (relative_risk == rr_mapper[exposure]).all()
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "3.1.2"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/pull_request_template.md
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/_templates/layout.html
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/index.rst
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/tutorials/index.rst
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/disease/test_special_disease.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_mortality.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disability.py
RENAMED
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disease_observer.py
RENAMED
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_stratification.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_distributions.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/treatment/test_scale_up.py
RENAMED
File without changes
|
File without changes
|