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.
Files changed (155) hide show
  1. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/CHANGELOG.rst +4 -0
  2. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/PKG-INFO +1 -1
  3. vivarium_public_health-3.1.3/src/vivarium_public_health/_version.py +1 -0
  4. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/effect.py +35 -23
  5. {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
  6. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/PKG-INFO +1 -1
  7. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_effect.py +40 -0
  8. vivarium_public_health-3.1.2/src/vivarium_public_health/_version.py +0 -1
  9. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.bandit +0 -0
  10. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.flake8 +0 -0
  11. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.gitattributes +0 -0
  12. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/CODEOWNERS +0 -0
  13. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/pull_request_template.md +0 -0
  14. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/workflows/build.yml +0 -0
  15. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.github/workflows/deploy.yml +0 -0
  16. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.gitignore +0 -0
  17. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.pylintrc +0 -0
  18. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.readthedocs.yml +0 -0
  19. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/.zenodo.json +0 -0
  20. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/CODE_OF_CONDUCT.rst +0 -0
  21. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/CONTRIBUTING.rst +0 -0
  22. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/Jenkinsfile +0 -0
  23. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/LICENSE.txt +0 -0
  24. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/MANIFEST.in +0 -0
  25. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/Makefile +0 -0
  26. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/README.rst +0 -0
  27. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/Makefile +0 -0
  28. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/nitpick-exceptions +0 -0
  29. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/_static/style.css +0 -0
  30. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/_templates/layout.html +0 -0
  31. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/index.rst +0 -0
  32. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/model.rst +0 -0
  33. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/models.rst +0 -0
  34. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/special_disease.rst +0 -0
  35. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/state.rst +0 -0
  36. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/disease/transition.rst +0 -0
  37. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/index.rst +0 -0
  38. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/delay.rst +0 -0
  39. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/disease.rst +0 -0
  40. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/index.rst +0 -0
  41. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/intervention.rst +0 -0
  42. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/magic_wand_components.rst +0 -0
  43. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/observer.rst +0 -0
  44. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/mslt/population.rst +0 -0
  45. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/plugins/index.rst +0 -0
  46. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/plugins/parser.rst +0 -0
  47. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/add_new_birth_cohorts.rst +0 -0
  48. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/base_population.rst +0 -0
  49. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/data_transformations.rst +0 -0
  50. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/index.rst +0 -0
  51. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/population/mortality.rst +0 -0
  52. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/disability.rst +0 -0
  53. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/disease.rst +0 -0
  54. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/index.rst +0 -0
  55. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/mortality.rst +0 -0
  56. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/observer.rst +0 -0
  57. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/risk.rst +0 -0
  58. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/simple_cause.rst +0 -0
  59. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/results/stratification.rst +0 -0
  60. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/base_risk.rst +0 -0
  61. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/data_transformations.rst +0 -0
  62. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/distributions.rst +0 -0
  63. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/effect.rst +0 -0
  64. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/implementations/index.rst +0 -0
  65. {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
  66. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/risks/index.rst +0 -0
  67. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/index.rst +0 -0
  68. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/magic_wand.rst +0 -0
  69. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/scale_up.rst +0 -0
  70. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/treatment/therapeutic_inertia.rst +0 -0
  71. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/api_reference/utilities.rst +0 -0
  72. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/conf.py +0 -0
  73. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/index.rst +0 -0
  74. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/tutorials/index.rst +0 -0
  75. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/docs/source/tutorials/risk_exposure.rst +0 -0
  76. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/pyproject.toml +0 -0
  77. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/setup.cfg +0 -0
  78. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/setup.py +0 -0
  79. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/__about__.py +0 -0
  80. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/__init__.py +0 -0
  81. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/__init__.py +0 -0
  82. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/model.py +0 -0
  83. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/models.py +0 -0
  84. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/special_disease.py +0 -0
  85. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/state.py +0 -0
  86. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/disease/transition.py +0 -0
  87. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/__init__.py +0 -0
  88. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/delay.py +0 -0
  89. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/disease.py +0 -0
  90. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/intervention.py +0 -0
  91. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/magic_wand_components.py +0 -0
  92. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/observer.py +0 -0
  93. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/mslt/population.py +0 -0
  94. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/plugins/__init__.py +0 -0
  95. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/plugins/parser.py +0 -0
  96. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/__init__.py +0 -0
  97. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/add_new_birth_cohorts.py +0 -0
  98. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/base_population.py +0 -0
  99. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/data_transformations.py +0 -0
  100. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/population/mortality.py +0 -0
  101. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/__init__.py +0 -0
  102. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/columns.py +0 -0
  103. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/disability.py +0 -0
  104. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/disease.py +0 -0
  105. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/mortality.py +0 -0
  106. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/observer.py +0 -0
  107. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/risk.py +0 -0
  108. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/simple_cause.py +0 -0
  109. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/results/stratification.py +0 -0
  110. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/__init__.py +0 -0
  111. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/base_risk.py +0 -0
  112. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/data_transformations.py +0 -0
  113. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/distributions.py +0 -0
  114. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/risks/implementations/__init__.py +0 -0
  115. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/__init__.py +0 -0
  116. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/magic_wand.py +0 -0
  117. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/scale_up.py +0 -0
  118. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/treatment/therapeutic_inertia.py +0 -0
  119. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health/utilities.py +0 -0
  120. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/SOURCES.txt +0 -0
  121. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/dependency_links.txt +0 -0
  122. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/not-zip-safe +0 -0
  123. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/requires.txt +0 -0
  124. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/src/vivarium_public_health.egg-info/top_level.txt +0 -0
  125. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/__init__.py +0 -0
  126. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/conftest.py +0 -0
  127. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/disease/__init__.py +0 -0
  128. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/disease/test_disease.py +0 -0
  129. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/disease/test_special_disease.py +0 -0
  130. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/mock_artifact.py +0 -0
  131. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/plugins/__init__.py +0 -0
  132. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/plugins/test_parser.py +0 -0
  133. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/__init__.py +0 -0
  134. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/conftest.py +0 -0
  135. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_add_new_birth_cohort.py +0 -0
  136. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_base_population.py +0 -0
  137. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_data_transformations.py +0 -0
  138. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/population/test_mortality.py +0 -0
  139. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/__init__.py +0 -0
  140. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_categorical_risk_observer.py +0 -0
  141. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disability.py +0 -0
  142. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disability_observer.py +0 -0
  143. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_disease_observer.py +0 -0
  144. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_mortality_observer.py +0 -0
  145. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/results/test_stratification.py +0 -0
  146. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/__init__.py +0 -0
  147. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/conftest.py +0 -0
  148. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_base_risk.py +0 -0
  149. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_data_transformations.py +0 -0
  150. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_distributions.py +0 -0
  151. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/risks/test_low_birth_weight_and_short_gestation.py +0 -0
  152. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/test_utilities.py +0 -0
  153. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/treatment/__init__.py +0 -0
  154. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tests/treatment/test_scale_up.py +0 -0
  155. {vivarium_public_health-3.1.2 → vivarium_public_health-3.1.3}/tox.ini +0 -0
@@ -1,3 +1,7 @@
1
+ **3.1.3 - 12/03/24**
2
+
3
+ - Feature: Create relative risk pipeline
4
+
1
5
  **3.1.2 - 11/13/24**
2
6
 
3
7
  - Modernize type hinting
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium_public_health
3
- Version: 3.1.2
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.target_modifier = self.get_target_modifier(builder)
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.get_relative_risk_data(builder)
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 get_relative_risk_data(
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 get_target_modifier(
264
- self, builder: Builder
265
- ) -> Callable[[pd.Index, pd.Series], pd.Series]:
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 adjust_target(index: pd.Index, target: pd.Series) -> pd.Series:
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 target * relative_risk
280
+ return relative_risk
276
281
 
277
282
  else:
278
283
  index_columns = ["index", self.risk.name]
279
284
 
280
- def adjust_target(index: pd.Index, target: pd.Series) -> pd.Series:
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
- affected_rates = target * effect
292
- return affected_rates
296
+ return effect
293
297
 
294
- return adjust_target
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.target_modifier,
300
- requires_values=[f"{self.risk.name}.exposure"],
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
- requires_columns=required_columns,
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.get_relative_risk_data(builder)
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 get_relative_risk_data(
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 get_target_modifier(
476
- self, builder: Builder
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 target * relative_risk
501
+ return relative_risk
490
502
 
491
- return adjust_target
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 get_relative_risk_pipeline(self, builder: Builder) -> Pipeline:
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.get_relative_risk,
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 get_relative_risk(self, index: pd.Index) -> pd.Series:
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.2
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"