vivarium-public-health 4.1.1__tar.gz → 4.2.0__tar.gz
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-4.1.1 → vivarium_public_health-4.2.0}/CHANGELOG.rst +4 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/PKG-INFO +1 -1
- vivarium_public_health-4.2.0/src/vivarium_public_health/_version.py +1 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py +88 -10
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health.egg-info/PKG-INFO +1 -1
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/conftest.py +10 -1
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/test_low_birth_weight_and_short_gestation.py +115 -9
- vivarium_public_health-4.1.1/src/vivarium_public_health/_version.py +0 -1
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.bandit +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.flake8 +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.gitattributes +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.github/CODEOWNERS +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.github/pull_request_template.md +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.github/workflows/deploy.yml +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.gitignore +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.pylintrc +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.readthedocs.yml +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.zenodo.json +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/CODE_OF_CONDUCT.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/CONTRIBUTING.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/Jenkinsfile +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/LICENSE.txt +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/MANIFEST.in +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/Makefile +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/README.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/Makefile +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/nitpick-exceptions +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/_static/style.css +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/_templates/layout.html +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/disease/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/disease/model.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/disease/models.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/disease/special_disease.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/disease/state.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/disease/transition.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/mslt/delay.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/mslt/disease.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/mslt/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/mslt/intervention.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/mslt/magic_wand_components.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/mslt/observer.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/mslt/population.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/plugins/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/plugins/parser.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/population/add_new_birth_cohorts.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/population/base_population.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/population/data_transformations.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/population/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/population/mortality.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/disability.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/disease.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/mortality.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/observer.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/risk.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/simple_cause.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/results/stratification.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/risks/base_risk.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/risks/data_transformations.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/risks/distributions.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/risks/effect.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/risks/implementations/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/risks/implementations/low_birth_weight_and_short_gestation.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/risks/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/treatment/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/treatment/magic_wand.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/treatment/scale_up.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/treatment/therapeutic_inertia.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/api_reference/utilities.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/conf.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/tutorials/index.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/docs/source/tutorials/risk_exposure.rst +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/pyproject.toml +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/python_versions.json +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/setup.cfg +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/setup.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/__about__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/disease/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/disease/exceptions.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/disease/model.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/disease/models.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/disease/special_disease.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/disease/state.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/disease/transition.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/mslt/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/mslt/delay.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/mslt/disease.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/mslt/intervention.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/mslt/magic_wand_components.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/mslt/observer.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/mslt/population.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/plugins/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/plugins/parser.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/population/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/population/add_new_birth_cohorts.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/population/base_population.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/population/data_transformations.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/population/mortality.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/columns.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/disability.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/disease.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/mortality.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/observer.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/risk.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/simple_cause.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/results/stratification.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/risks/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/risks/base_risk.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/risks/data_transformations.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/risks/distributions.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/risks/effect.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/risks/implementations/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/treatment/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/treatment/magic_wand.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/treatment/scale_up.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/treatment/therapeutic_inertia.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health/utilities.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health.egg-info/SOURCES.txt +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health.egg-info/dependency_links.txt +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health.egg-info/not-zip-safe +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health.egg-info/requires.txt +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/src/vivarium_public_health.egg-info/top_level.txt +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/data/rr_interpolator.csv +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/disease/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/disease/test_disease.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/disease/test_special_disease.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/mock_artifact.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/plugins/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/plugins/test_parser.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/population/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/population/conftest.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/population/test_add_new_birth_cohort.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/population/test_base_population.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/population/test_data_transformations.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/population/test_mortality.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_categorical_risk_observer.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_disability.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_disability_observer.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_disease_observer.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_mortality_observer.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_stratification.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/conftest.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/test_base_risk.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/test_data_transformations.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/test_distributions.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/test_effect.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/test_utilities.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/treatment/__init__.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/treatment/test_scale_up.py +0 -0
- {vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tox.ini +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: vivarium_public_health
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.2.0
|
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__ = "4.2.0"
|
@@ -14,6 +14,8 @@ from typing import Any
|
|
14
14
|
|
15
15
|
import numpy as np
|
16
16
|
import pandas as pd
|
17
|
+
from layered_config_tree import ConfigurationError
|
18
|
+
from loguru import logger
|
17
19
|
from vivarium.framework.engine import Builder
|
18
20
|
from vivarium.framework.lifecycle import LifeCycleError
|
19
21
|
from vivarium.framework.population import SimulantData
|
@@ -21,9 +23,12 @@ from vivarium.framework.resource import Resource
|
|
21
23
|
from vivarium.framework.values import Pipeline
|
22
24
|
|
23
25
|
from vivarium_public_health.risks import Risk, RiskEffect
|
24
|
-
from vivarium_public_health.risks.data_transformations import
|
26
|
+
from vivarium_public_health.risks.data_transformations import (
|
27
|
+
get_exposure_post_processor,
|
28
|
+
pivot_categorical,
|
29
|
+
)
|
25
30
|
from vivarium_public_health.risks.distributions import PolytomousDistribution
|
26
|
-
from vivarium_public_health.utilities import get_lookup_columns, to_snake_case
|
31
|
+
from vivarium_public_health.utilities import EntityString, get_lookup_columns, to_snake_case
|
27
32
|
|
28
33
|
CATEGORICAL = "categorical"
|
29
34
|
BIRTH_WEIGHT = "birth_weight"
|
@@ -31,16 +36,76 @@ GESTATIONAL_AGE = "gestational_age"
|
|
31
36
|
|
32
37
|
|
33
38
|
class LBWSGDistribution(PolytomousDistribution):
|
39
|
+
@property
|
40
|
+
def categories(self) -> list[str]:
|
41
|
+
# These need to be sorted so the cumulative sum is in the correct order of categories
|
42
|
+
# and results are therefore reproducible and correct
|
43
|
+
return sorted(self.lookup_tables[self.exposure_key].value_columns)
|
34
44
|
|
35
45
|
#################
|
36
46
|
# Setup methods #
|
37
47
|
#################
|
38
48
|
|
49
|
+
def __init__(
|
50
|
+
self,
|
51
|
+
risk: EntityString,
|
52
|
+
distribution_type: str,
|
53
|
+
exposure_data: int | float | pd.DataFrame | None = None,
|
54
|
+
) -> None:
|
55
|
+
super().__init__(risk, distribution_type, exposure_data)
|
56
|
+
self.exposure_key = "birth_exposure"
|
57
|
+
|
39
58
|
# noinspection PyAttributeOutsideInit
|
40
59
|
def setup(self, builder: Builder) -> None:
|
41
60
|
super().setup(builder)
|
42
61
|
self.category_intervals = self.get_category_intervals(builder)
|
43
62
|
|
63
|
+
def build_all_lookup_tables(self, builder: Builder) -> None:
|
64
|
+
try:
|
65
|
+
birth_exposure_data = self.get_data(
|
66
|
+
builder, self.configuration["data_sources"]["birth_exposure"]
|
67
|
+
)
|
68
|
+
birth_exposure_value_columns = self.get_exposure_value_columns(
|
69
|
+
birth_exposure_data
|
70
|
+
)
|
71
|
+
|
72
|
+
if isinstance(birth_exposure_data, pd.DataFrame):
|
73
|
+
birth_exposure_data = pivot_categorical(
|
74
|
+
builder, self.risk, birth_exposure_data, "parameter"
|
75
|
+
)
|
76
|
+
|
77
|
+
self.lookup_tables["birth_exposure"] = self.build_lookup_table(
|
78
|
+
builder, birth_exposure_data, birth_exposure_value_columns
|
79
|
+
)
|
80
|
+
except ConfigurationError:
|
81
|
+
logger.warning("Birth exposure data for LBWSG is missing from the simulation")
|
82
|
+
try:
|
83
|
+
super().build_all_lookup_tables(builder)
|
84
|
+
except ConfigurationError:
|
85
|
+
logger.warning("The data for LBWSG exposure is missing from the simulation.")
|
86
|
+
|
87
|
+
if (
|
88
|
+
"birth_exposure" not in self.lookup_tables
|
89
|
+
and "exposure" not in self.lookup_tables
|
90
|
+
):
|
91
|
+
raise ConfigurationError(
|
92
|
+
"The LBWSG distribution requires either 'birth_exposure' or 'exposure' data to be "
|
93
|
+
"available in the simulation."
|
94
|
+
)
|
95
|
+
|
96
|
+
def get_exposure_parameter_pipeline(self, builder: Builder) -> Pipeline:
|
97
|
+
lookup_columns = []
|
98
|
+
if "exposure" in self.lookup_tables:
|
99
|
+
lookup_columns.extend(get_lookup_columns([self.lookup_tables["exposure"]]))
|
100
|
+
if "birth_exposure" in self.lookup_tables:
|
101
|
+
lookup_columns.extend(get_lookup_columns([self.lookup_tables["birth_exposure"]]))
|
102
|
+
return builder.value.register_value_producer(
|
103
|
+
self.parameters_pipeline_name,
|
104
|
+
source=lambda index: self.lookup_tables[self.exposure_key](index),
|
105
|
+
component=self,
|
106
|
+
required_resources=list(set(lookup_columns)),
|
107
|
+
)
|
108
|
+
|
44
109
|
def get_category_intervals(self, builder: Builder) -> dict[str, dict[str, pd.Interval]]:
|
45
110
|
"""Gets the intervals for each category.
|
46
111
|
|
@@ -203,8 +268,9 @@ class LBWSGRisk(Risk):
|
|
203
268
|
@property
|
204
269
|
def configuration_defaults(self) -> dict[str, Any]:
|
205
270
|
configuration_defaults = super().configuration_defaults
|
271
|
+
# Add birth exposure data source
|
206
272
|
configuration_defaults[self.name]["data_sources"][
|
207
|
-
"
|
273
|
+
"birth_exposure"
|
208
274
|
] = f"{self.risk}.birth_exposure"
|
209
275
|
configuration_defaults[self.name]["distribution_type"] = "lbwsg"
|
210
276
|
return configuration_defaults
|
@@ -224,6 +290,7 @@ class LBWSGRisk(Risk):
|
|
224
290
|
def setup(self, builder: Builder) -> None:
|
225
291
|
super().setup(builder)
|
226
292
|
self.birth_exposures = self.get_birth_exposure_pipelines(builder)
|
293
|
+
self.configuration_age_end = builder.configuration.population.initialization_age_max
|
227
294
|
|
228
295
|
#################
|
229
296
|
# Setup methods #
|
@@ -242,7 +309,7 @@ class LBWSGRisk(Risk):
|
|
242
309
|
self.exposure_distribution.lookup_tables.values()
|
243
310
|
)
|
244
311
|
|
245
|
-
def get_pipeline(axis_: str):
|
312
|
+
def get_pipeline(axis_: str) -> Pipeline:
|
246
313
|
return builder.value.register_value_producer(
|
247
314
|
self.birth_exposure_pipeline_name(axis_),
|
248
315
|
source=lambda index: self.get_birth_exposure(axis_, index),
|
@@ -260,12 +327,23 @@ class LBWSGRisk(Risk):
|
|
260
327
|
########################
|
261
328
|
|
262
329
|
def on_initialize_simulants(self, pop_data: SimulantData) -> None:
|
263
|
-
|
264
|
-
self.
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
330
|
+
if pop_data.user_data.get("age_end", self.configuration_age_end) == 0:
|
331
|
+
self.exposure_distribution.exposure_key = "birth_exposure"
|
332
|
+
else:
|
333
|
+
self.exposure_distribution.exposure_key = "exposure"
|
334
|
+
|
335
|
+
try:
|
336
|
+
birth_exposures = {
|
337
|
+
self.get_exposure_column_name(axis): self.birth_exposures[
|
338
|
+
self.birth_exposure_pipeline_name(axis)
|
339
|
+
](pop_data.index)
|
340
|
+
for axis in self.AXES
|
341
|
+
}
|
342
|
+
except KeyError:
|
343
|
+
raise ConfigurationError(
|
344
|
+
f"{self.exposure_distribution.exposure_key} data for {self.name} is missing from the "
|
345
|
+
"simulation. Simulants cannot be initialized."
|
346
|
+
)
|
269
347
|
self.population_view.update(pd.DataFrame(birth_exposures))
|
270
348
|
|
271
349
|
##################################
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: vivarium_public_health
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.2.0
|
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,10 @@
|
|
1
|
-
from collections.abc import Callable
|
1
|
+
from collections.abc import Callable, Generator
|
2
2
|
from pathlib import Path
|
3
3
|
|
4
4
|
import pytest
|
5
|
+
from _pytest.logging import LogCaptureFixture
|
5
6
|
from layered_config_tree import LayeredConfigTree
|
7
|
+
from loguru import logger
|
6
8
|
from vivarium.framework.configuration import build_simulation_configuration
|
7
9
|
from vivarium_testing_utils import FuzzyChecker
|
8
10
|
|
@@ -69,3 +71,10 @@ def fuzzy_checker() -> FuzzyChecker:
|
|
69
71
|
yield checker
|
70
72
|
test_dir = Path(__file__).resolve().parent
|
71
73
|
checker.save_diagnostic_output(test_dir)
|
74
|
+
|
75
|
+
|
76
|
+
@pytest.fixture
|
77
|
+
def caplog(caplog: LogCaptureFixture) -> Generator[LogCaptureFixture, None, None]:
|
78
|
+
handler_id = logger.add(caplog.handler, format="{message}")
|
79
|
+
yield caplog
|
80
|
+
logger.remove(handler_id)
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import numpy as np
|
2
2
|
import pandas as pd
|
3
3
|
import pytest
|
4
|
+
from layered_config_tree import ConfigurationError
|
5
|
+
from vivarium import InteractiveContext
|
6
|
+
from vivarium.testing_utilities import TestPopulation
|
4
7
|
|
5
8
|
from tests.risks.test_effect import _setup_risk_effect_simulation
|
6
9
|
from tests.test_utilities import make_age_bins
|
@@ -57,11 +60,15 @@ def test_lbwsg_risk_effect_rr_pipeline(base_config, base_plugins, mock_rr_interp
|
|
57
60
|
# Have to match age bins and rr data to make age intervals
|
58
61
|
rr_data = make_categorical_data(agees)
|
59
62
|
# Exposure data used for risk component
|
60
|
-
|
63
|
+
birth_exposure = make_categorical_data(agees)
|
64
|
+
exposure = birth_exposure.copy()
|
65
|
+
exposure.loc[exposure["value"] == 0.75, "value"] = 0.65
|
66
|
+
exposure.loc[exposure["value"] == 0.25, "value"] = 0.35
|
61
67
|
|
62
68
|
# Add data dict to add to artifact
|
63
69
|
data = {
|
64
|
-
f"{risk.name}.birth_exposure":
|
70
|
+
f"{risk.name}.birth_exposure": birth_exposure,
|
71
|
+
f"{risk.name}.exposure": exposure,
|
65
72
|
f"{risk.name}.relative_risk": rr_data,
|
66
73
|
f"{risk.name}.population_attributable_fraction": 0,
|
67
74
|
f"{risk.name}.categories": categories,
|
@@ -81,6 +88,16 @@ def test_lbwsg_risk_effect_rr_pipeline(base_config, base_plugins, mock_rr_interp
|
|
81
88
|
)
|
82
89
|
sim = _setup_risk_effect_simulation(base_config, base_plugins, risk, lbwsg_effect, data)
|
83
90
|
pop = sim.get_population()
|
91
|
+
# Verify exposure is used instead of birth_exposure since age end is 1.0
|
92
|
+
# Check values of pipeline match birth exposure data since age_end is 0.0
|
93
|
+
exposure_pipeline_values = sim.get_value(
|
94
|
+
"risk_factor.low_birth_weight_and_short_gestation.exposure_parameters"
|
95
|
+
)(pop.index)
|
96
|
+
assert isinstance(exposure_pipeline_values, pd.DataFrame)
|
97
|
+
assert "cat81" in exposure_pipeline_values.columns
|
98
|
+
assert "cat82" in exposure_pipeline_values.columns
|
99
|
+
assert (exposure_pipeline_values["cat81"] == 0.65).all()
|
100
|
+
assert (exposure_pipeline_values["cat82"] == 0.35).all()
|
84
101
|
|
85
102
|
expected_pipeline_name = (
|
86
103
|
f"effect_of_{lbwsg_effect.risk.name}_on_{lbwsg_effect.target.name}.relative_risk"
|
@@ -120,7 +137,8 @@ def test_lbwsg_risk_effect_rr_pipeline(base_config, base_plugins, mock_rr_interp
|
|
120
137
|
assert (actual_rr == 1.0).all()
|
121
138
|
|
122
139
|
|
123
|
-
|
140
|
+
@pytest.mark.parametrize("age_end", [0.0, 1.0])
|
141
|
+
def test_use_exposure(base_config, base_plugins, mock_rr_interpolators, age_end):
|
124
142
|
risk = LBWSGRisk()
|
125
143
|
lbwsg_effect = LBWSGRiskEffect("cause.test_cause.cause_specific_mortality_rate")
|
126
144
|
|
@@ -135,7 +153,7 @@ def test_use_birth_exposure(base_config, base_plugins, mock_rr_interpolators):
|
|
135
153
|
# Have to match age bins and rr data to make age intervals
|
136
154
|
rr_data = make_categorical_data(ages)
|
137
155
|
# Format birth exposure data
|
138
|
-
|
156
|
+
birth_exposure = pd.DataFrame(
|
139
157
|
{
|
140
158
|
"sex": ["Male", "Female", "Male", "Female"],
|
141
159
|
"year_start": [2021, 2021, 2021, 2021],
|
@@ -144,10 +162,13 @@ def test_use_birth_exposure(base_config, base_plugins, mock_rr_interpolators):
|
|
144
162
|
"value": [0.75, 0.75, 0.25, 0.25],
|
145
163
|
}
|
146
164
|
)
|
165
|
+
exposure = birth_exposure.copy()
|
166
|
+
exposure["value"] = [0.65, 0.65, 0.35, 0.35]
|
147
167
|
|
148
168
|
# Add data dict to add to artifact
|
149
169
|
data = {
|
150
|
-
f"{risk.name}.birth_exposure":
|
170
|
+
f"{risk.name}.birth_exposure": birth_exposure,
|
171
|
+
f"{risk.name}.exposure": exposure,
|
151
172
|
f"{risk.name}.relative_risk": rr_data,
|
152
173
|
f"{risk.name}.population_attributable_fraction": 0,
|
153
174
|
f"{risk.name}.categories": categories,
|
@@ -155,24 +176,109 @@ def test_use_birth_exposure(base_config, base_plugins, mock_rr_interpolators):
|
|
155
176
|
}
|
156
177
|
|
157
178
|
# Only have neontal age groups
|
158
|
-
|
159
|
-
age_end = 1.0
|
179
|
+
age_end = 0.0
|
160
180
|
base_config.update(
|
161
181
|
{
|
162
182
|
"population": {
|
163
|
-
"initialization_age_start":
|
183
|
+
"initialization_age_start": 0.0,
|
164
184
|
"initialization_age_max": age_end,
|
165
|
-
}
|
185
|
+
},
|
166
186
|
}
|
167
187
|
)
|
168
188
|
sim = _setup_risk_effect_simulation(base_config, base_plugins, risk, lbwsg_effect, data)
|
169
189
|
pop = sim.get_population()
|
190
|
+
# Check values of pipeline match birth exposure data since age_end is 0.0
|
191
|
+
exposure_pipeline_values = sim.get_value(
|
192
|
+
"risk_factor.low_birth_weight_and_short_gestation.exposure_parameters"
|
193
|
+
)(pop.index)
|
194
|
+
assert isinstance(exposure_pipeline_values, pd.DataFrame)
|
195
|
+
assert "cat81" in exposure_pipeline_values.columns
|
196
|
+
assert "cat82" in exposure_pipeline_values.columns
|
197
|
+
exposure_values = {
|
198
|
+
0.0: {"cat81": 0.75, "cat82": 0.25},
|
199
|
+
1.0: {"cat81": 0.65, "cat82": 0.35},
|
200
|
+
}
|
201
|
+
assert (exposure_pipeline_values["cat81"] == exposure_values[age_end]["cat81"]).all()
|
202
|
+
assert (exposure_pipeline_values["cat82"] == exposure_values[age_end]["cat82"]).all()
|
170
203
|
|
171
204
|
# Assert LBWSG birth exposure columns were created
|
172
205
|
assert "birth_weight_exposure" in pop.columns
|
173
206
|
assert "gestational_age_exposure" in pop.columns
|
174
207
|
|
175
208
|
|
209
|
+
@pytest.mark.parametrize("exposure_key", ["birth_exposure", "exposure", "missing"])
|
210
|
+
def test_lbwsg_exposure_data_logging(exposure_key, base_config, mocker, caplog) -> None:
|
211
|
+
risk = LBWSGRisk()
|
212
|
+
|
213
|
+
# Add mock data to artifact
|
214
|
+
# Format birth exposure data
|
215
|
+
exposure_data = pd.DataFrame(
|
216
|
+
{
|
217
|
+
"sex": ["Male", "Female", "Male", "Female"],
|
218
|
+
"year_start": [2021, 2021, 2021, 2021],
|
219
|
+
"year_end": [2022, 2022, 2022, 2022],
|
220
|
+
"parameter": ["cat81", "cat81", "cat82", "cat82"],
|
221
|
+
"value": [0.75, 0.75, 0.25, 0.25],
|
222
|
+
}
|
223
|
+
)
|
224
|
+
|
225
|
+
# Only have neontal age groups
|
226
|
+
if exposure_key == "birth_exposure":
|
227
|
+
age_end = 0.0
|
228
|
+
else:
|
229
|
+
age_end = 1.0
|
230
|
+
|
231
|
+
if exposure_key != "missing":
|
232
|
+
no_data_dict = {
|
233
|
+
"birth_exposure": "exposure",
|
234
|
+
"exposure": "birth_exposure",
|
235
|
+
}
|
236
|
+
no_data_key = no_data_dict[exposure_key]
|
237
|
+
override_config = {
|
238
|
+
"population": {
|
239
|
+
"initialization_age_start": 0.0,
|
240
|
+
"initialization_age_max": age_end,
|
241
|
+
},
|
242
|
+
risk.name: {
|
243
|
+
"data_sources": {
|
244
|
+
exposure_key: exposure_data,
|
245
|
+
}
|
246
|
+
},
|
247
|
+
}
|
248
|
+
else:
|
249
|
+
override_config = {
|
250
|
+
"population": {
|
251
|
+
"initialization_age_start": 0.0,
|
252
|
+
"initialization_age_max": age_end,
|
253
|
+
},
|
254
|
+
}
|
255
|
+
|
256
|
+
# Patch get_category intervals so we do not need the mock artifact
|
257
|
+
mocker.patch(
|
258
|
+
"vivarium_public_health.risks.implementations.low_birth_weight_and_short_gestation.LBWSGDistribution.get_category_intervals"
|
259
|
+
)
|
260
|
+
assert not caplog.records
|
261
|
+
if exposure_key != "missing":
|
262
|
+
missing_key = "exposure" if exposure_key == "birth_exposure" else "birth_exposure"
|
263
|
+
sim = InteractiveContext(
|
264
|
+
base_config,
|
265
|
+
components=[TestPopulation(), risk],
|
266
|
+
configuration=override_config,
|
267
|
+
)
|
268
|
+
assert f"The data for LBWSG {missing_key} is missing from the simulation"
|
269
|
+
else:
|
270
|
+
with pytest.raises(
|
271
|
+
ConfigurationError,
|
272
|
+
match="The LBWSG distribution requires either 'birth_exposure' or 'exposure' data to be "
|
273
|
+
"available in the simulation.",
|
274
|
+
):
|
275
|
+
InteractiveContext(
|
276
|
+
base_config,
|
277
|
+
components=[TestPopulation(), risk],
|
278
|
+
configuration=override_config,
|
279
|
+
)
|
280
|
+
|
281
|
+
|
176
282
|
def make_categorical_data(data: pd.DataFrame) -> pd.DataFrame:
|
177
283
|
# Takes age gropus and adds sex, years, categories, and values
|
178
284
|
dfs = []
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "4.1.1"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/.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
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/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-4.1.1 → vivarium_public_health-4.2.0}/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-4.1.1 → vivarium_public_health-4.2.0}/docs/source/tutorials/index.rst
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-4.1.1 → vivarium_public_health-4.2.0}/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
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/data/rr_interpolator.csv
RENAMED
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/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-4.1.1 → vivarium_public_health-4.2.0}/tests/population/test_mortality.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_disability.py
RENAMED
File without changes
|
File without changes
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_disease_observer.py
RENAMED
File without changes
|
File without changes
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/results/test_stratification.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/risks/test_distributions.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vivarium_public_health-4.1.1 → vivarium_public_health-4.2.0}/tests/treatment/test_scale_up.py
RENAMED
File without changes
|
File without changes
|