vivarium-public-health 3.0.4__tar.gz → 3.0.7__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.0.4 → vivarium_public_health-3.0.7}/CHANGELOG.rst +16 -0
  2. {vivarium_public_health-3.0.4/src/vivarium_public_health.egg-info → vivarium_public_health-3.0.7}/PKG-INFO +1 -1
  3. vivarium_public_health-3.0.7/src/vivarium_public_health/_version.py +1 -0
  4. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/disease/transition.py +5 -3
  5. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/disability.py +4 -4
  6. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/disease.py +3 -3
  7. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/mortality.py +4 -4
  8. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/observer.py +10 -0
  9. vivarium_public_health-3.0.7/src/vivarium_public_health/results/simple_cause.py +43 -0
  10. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/risks/base_risk.py +24 -11
  11. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/risks/effect.py +18 -9
  12. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py +6 -6
  13. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7/src/vivarium_public_health.egg-info}/PKG-INFO +1 -1
  14. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/mock_artifact.py +1 -0
  15. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/risks/test_effect.py +100 -35
  16. vivarium_public_health-3.0.4/src/vivarium_public_health/_version.py +0 -1
  17. vivarium_public_health-3.0.4/src/vivarium_public_health/results/simple_cause.py +0 -24
  18. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.bandit +0 -0
  19. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.flake8 +0 -0
  20. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.gitattributes +0 -0
  21. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.github/CODEOWNERS +0 -0
  22. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.github/pull_request_template.md +0 -0
  23. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.github/workflows/build.yml +0 -0
  24. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.github/workflows/deploy.yml +0 -0
  25. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.gitignore +0 -0
  26. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.pylintrc +0 -0
  27. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.readthedocs.yml +0 -0
  28. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/.zenodo.json +0 -0
  29. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/CODE_OF_CONDUCT.rst +0 -0
  30. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/CONTRIBUTING.rst +0 -0
  31. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/Jenkinsfile +0 -0
  32. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/LICENSE.txt +0 -0
  33. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/MANIFEST.in +0 -0
  34. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/Makefile +0 -0
  35. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/README.rst +0 -0
  36. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/Makefile +0 -0
  37. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/nitpick-exceptions +0 -0
  38. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/_static/style.css +0 -0
  39. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/_templates/layout.html +0 -0
  40. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/disease/index.rst +0 -0
  41. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/disease/model.rst +0 -0
  42. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/disease/models.rst +0 -0
  43. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/disease/special_disease.rst +0 -0
  44. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/disease/state.rst +0 -0
  45. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/disease/transition.rst +0 -0
  46. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/index.rst +0 -0
  47. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/mslt/delay.rst +0 -0
  48. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/mslt/disease.rst +0 -0
  49. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/mslt/index.rst +0 -0
  50. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/mslt/intervention.rst +0 -0
  51. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/mslt/magic_wand_components.rst +0 -0
  52. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/mslt/observer.rst +0 -0
  53. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/mslt/population.rst +0 -0
  54. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/plugins/index.rst +0 -0
  55. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/plugins/parser.rst +0 -0
  56. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/population/add_new_birth_cohorts.rst +0 -0
  57. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/population/base_population.rst +0 -0
  58. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/population/data_transformations.rst +0 -0
  59. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/population/index.rst +0 -0
  60. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/population/mortality.rst +0 -0
  61. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/disability.rst +0 -0
  62. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/disease.rst +0 -0
  63. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/index.rst +0 -0
  64. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/mortality.rst +0 -0
  65. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/observer.rst +0 -0
  66. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/risk.rst +0 -0
  67. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/simple_cause.rst +0 -0
  68. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/results/stratification.rst +0 -0
  69. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/risks/base_risk.rst +0 -0
  70. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/risks/data_transformations.rst +0 -0
  71. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/risks/distributions.rst +0 -0
  72. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/risks/effect.rst +0 -0
  73. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/risks/implementations/index.rst +0 -0
  74. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/risks/implementations/low_birth_weight_and_short_gestation.rst +0 -0
  75. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/risks/index.rst +0 -0
  76. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/treatment/index.rst +0 -0
  77. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/treatment/magic_wand.rst +0 -0
  78. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/treatment/scale_up.rst +0 -0
  79. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/treatment/therapeutic_inertia.rst +0 -0
  80. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/api_reference/utilities.rst +0 -0
  81. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/conf.py +0 -0
  82. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/index.rst +0 -0
  83. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/tutorials/index.rst +0 -0
  84. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/docs/source/tutorials/risk_exposure.rst +0 -0
  85. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/pyproject.toml +0 -0
  86. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/setup.cfg +0 -0
  87. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/setup.py +0 -0
  88. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/__about__.py +0 -0
  89. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/__init__.py +0 -0
  90. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/disease/__init__.py +0 -0
  91. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/disease/model.py +0 -0
  92. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/disease/models.py +0 -0
  93. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/disease/special_disease.py +0 -0
  94. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/disease/state.py +0 -0
  95. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/mslt/__init__.py +0 -0
  96. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/mslt/delay.py +0 -0
  97. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/mslt/disease.py +0 -0
  98. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/mslt/intervention.py +0 -0
  99. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/mslt/magic_wand_components.py +0 -0
  100. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/mslt/observer.py +0 -0
  101. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/mslt/population.py +0 -0
  102. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/plugins/__init__.py +0 -0
  103. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/plugins/parser.py +0 -0
  104. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/population/__init__.py +0 -0
  105. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/population/add_new_birth_cohorts.py +0 -0
  106. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/population/base_population.py +0 -0
  107. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/population/data_transformations.py +0 -0
  108. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/population/mortality.py +0 -0
  109. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/__init__.py +0 -0
  110. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/columns.py +0 -0
  111. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/risk.py +0 -0
  112. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/results/stratification.py +0 -0
  113. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/risks/__init__.py +0 -0
  114. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/risks/data_transformations.py +0 -0
  115. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/risks/distributions.py +0 -0
  116. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/risks/implementations/__init__.py +0 -0
  117. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/treatment/__init__.py +0 -0
  118. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/treatment/magic_wand.py +0 -0
  119. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/treatment/scale_up.py +0 -0
  120. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/treatment/therapeutic_inertia.py +0 -0
  121. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health/utilities.py +0 -0
  122. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health.egg-info/SOURCES.txt +0 -0
  123. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health.egg-info/dependency_links.txt +0 -0
  124. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health.egg-info/not-zip-safe +0 -0
  125. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health.egg-info/requires.txt +0 -0
  126. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/src/vivarium_public_health.egg-info/top_level.txt +0 -0
  127. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/__init__.py +0 -0
  128. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/conftest.py +0 -0
  129. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/disease/__init__.py +0 -0
  130. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/disease/test_disease.py +0 -0
  131. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/disease/test_special_disease.py +0 -0
  132. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/plugins/__init__.py +0 -0
  133. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/plugins/test_parser.py +0 -0
  134. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/population/__init__.py +0 -0
  135. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/population/conftest.py +0 -0
  136. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/population/test_add_new_birth_cohort.py +0 -0
  137. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/population/test_base_population.py +0 -0
  138. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/population/test_data_transformations.py +0 -0
  139. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/population/test_mortality.py +0 -0
  140. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/results/__init__.py +0 -0
  141. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/results/test_categorical_risk_observer.py +0 -0
  142. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/results/test_disability.py +0 -0
  143. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/results/test_disability_observer.py +0 -0
  144. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/results/test_disease_observer.py +0 -0
  145. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/results/test_mortality_observer.py +0 -0
  146. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/results/test_stratification.py +0 -0
  147. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/risks/__init__.py +0 -0
  148. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/risks/conftest.py +0 -0
  149. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/risks/test_base_risk.py +0 -0
  150. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/risks/test_data_transformations.py +0 -0
  151. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/risks/test_distributions.py +0 -0
  152. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/risks/test_low_birth_weight_and_short_gestation.py +0 -0
  153. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/test_utilities.py +0 -0
  154. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tests/treatment/__init__.py +0 -0
  155. {vivarium_public_health-3.0.4 → vivarium_public_health-3.0.7}/tox.ini +0 -0
@@ -1,3 +1,19 @@
1
+ **3.0.7 - 09/10/24**
2
+
3
+ - Properly create the population_view in RateTransition
4
+
5
+ **3.0.6 - 09/04/24**
6
+
7
+ - Fix bug that was occurring when RiskEffect's rr_source was a float or DataFrame
8
+ - Better handle exposure column creation in Risk component
9
+ - Rename LBWSRisk 'exposure_column_name()' staticmethod to not collide with Risk attr
10
+
11
+ **3.0.5 - 08/29/24**
12
+
13
+ - Add missing results module-level docstrings
14
+ - Strengthen the SimpleCause docstring
15
+ - Rename the SimpleCause class method
16
+
1
17
  **3.0.4 - 08/28/24**
2
18
 
3
19
  - Strengthen results docstrings and clean up others throughout
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium_public_health
3
- Version: 3.0.4
3
+ Version: 3.0.7
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.0.7"
@@ -7,7 +7,7 @@ This module contains tools to model transitions between disease states.
7
7
 
8
8
  """
9
9
 
10
- from typing import TYPE_CHECKING, Any, Callable, Dict, Union
10
+ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
11
11
 
12
12
  import pandas as pd
13
13
  from vivarium.framework.engine import Builder
@@ -48,6 +48,10 @@ class RateTransition(Transition):
48
48
  },
49
49
  }
50
50
 
51
+ @property
52
+ def columns_required(self) -> Optional[List[str]]:
53
+ return ["alive"]
54
+
51
55
  @property
52
56
  def transition_rate_pipeline_name(self) -> str:
53
57
  if "incidence_rate" in self._get_data_functions:
@@ -100,8 +104,6 @@ class RateTransition(Transition):
100
104
  preferred_post_processor=union_post_processor,
101
105
  )
102
106
 
103
- self.population_view = builder.population.get_view(["alive"])
104
-
105
107
  #################
106
108
  # Setup methods #
107
109
  #################
@@ -1,7 +1,7 @@
1
1
  """
2
- ===================
3
- Disability Observer
4
- ===================
2
+ ====================
3
+ Disability Observers
4
+ ====================
5
5
 
6
6
  This module contains tools for observing years lived with disability (YLDs)
7
7
  in the simulation.
@@ -102,7 +102,7 @@ class DisabilityObserver(PublicHealthObserver):
102
102
  )
103
103
  # Convert to SimpleCause instances and add on all_causes
104
104
  causes_of_disability = [
105
- SimpleCause.create_from_disease_state(cause) for cause in causes_of_disability
105
+ SimpleCause.create_from_specific_cause(cause) for cause in causes_of_disability
106
106
  ] + [SimpleCause("all_causes", "all_causes", "cause")]
107
107
 
108
108
  excluded_causes = (
@@ -1,7 +1,7 @@
1
1
  """
2
- ================
3
- Disease Observer
4
- ================
2
+ =================
3
+ Disease Observers
4
+ =================
5
5
 
6
6
  This module contains tools for observing disease incidence and prevalence
7
7
  in the simulation.
@@ -1,7 +1,7 @@
1
1
  """
2
- ==================
3
- Mortality Observer
4
- ==================
2
+ ===================
3
+ Mortality Observers
4
+ ===================
5
5
 
6
6
  This module contains tools for observing cause-specific and
7
7
  excess mortality in the simulation, including "other causes".
@@ -130,7 +130,7 @@ class MortalityObserver(PublicHealthObserver):
130
130
 
131
131
  # Convert to SimpleCauses and add on other_causes and not_dead
132
132
  self.causes_of_death = [
133
- SimpleCause.create_from_disease_state(cause) for cause in causes_of_death
133
+ SimpleCause.create_from_specific_cause(cause) for cause in causes_of_death
134
134
  ] + [
135
135
  SimpleCause("not_dead", "not_dead", "cause"),
136
136
  SimpleCause("other_causes", "other_causes", "cause"),
@@ -1,3 +1,13 @@
1
+ """
2
+ ===============
3
+ Basic Observers
4
+ ===============
5
+
6
+ This module contains convenience classes for building concrete observers in
7
+ public health models.
8
+
9
+ """
10
+
1
11
  from typing import Callable, List, Optional, Union
2
12
 
3
13
  import pandas as pd
@@ -0,0 +1,43 @@
1
+ """
2
+ ============
3
+ Simple Cause
4
+ ============
5
+
6
+ This module contains tools for creating a minimal representation of a cause
7
+ as required by observers.
8
+
9
+ """
10
+
11
+ from dataclasses import dataclass
12
+
13
+
14
+ @dataclass
15
+ class SimpleCause:
16
+ """A simple dataclass to represent the bare minimum information needed by observers.
17
+
18
+ It also includes a class method to convert a provided cause into a
19
+ ``SimpleCause`` instance.
20
+
21
+ """
22
+
23
+ state_id: str
24
+ """The state_id of the cause."""
25
+ model: str
26
+ """The model of the cause."""
27
+ cause_type: str
28
+ """The cause type of the cause."""
29
+
30
+ @classmethod
31
+ def create_from_specific_cause(cls, cause: type) -> "SimpleCause":
32
+ """Create a SimpleCause instance from a more specific cause.
33
+
34
+ Parameters
35
+ ----------
36
+ cause
37
+ The cause to be converted into a SimpleCause instance.
38
+
39
+ Returns
40
+ -------
41
+ A SimpleCause instance.
42
+ """
43
+ return cls(cause.state_id, cause.model, cause.cause_type)
@@ -123,7 +123,10 @@ class Risk(Component):
123
123
 
124
124
  @property
125
125
  def columns_created(self) -> List[str]:
126
- return [self.propensity_column_name, self.exposure_column_name]
126
+ columns_to_create = [self.propensity_column_name]
127
+ if self.create_exposure_column:
128
+ columns_to_create.append(self.exposure_column_name)
129
+ return columns_to_create
127
130
 
128
131
  @property
129
132
  def initialization_requirements(self) -> Dict[str, List[str]]:
@@ -172,6 +175,16 @@ class Risk(Component):
172
175
  self.propensity = self.get_propensity_pipeline(builder)
173
176
  self.exposure = self.get_exposure_pipeline(builder)
174
177
 
178
+ # We want to set this to True iff there is a non-loglinear risk effect
179
+ # on this risk instance
180
+ self.create_exposure_column = bool(
181
+ [
182
+ component
183
+ for component in builder.components.list_components()
184
+ if component.startswith(f"non_log_linear_risk_effect.{self.risk.name}_on_")
185
+ ]
186
+ )
187
+
175
188
  def get_distribution_type(self, builder: Builder) -> str:
176
189
  """Get the distribution type for the risk from the configuration.
177
190
 
@@ -270,19 +283,19 @@ class Risk(Component):
270
283
  ########################
271
284
 
272
285
  def on_initialize_simulants(self, pop_data: SimulantData) -> None:
273
- propensity_values = self.randomness.get_draw(pop_data.index)
274
- df = pd.DataFrame(
275
- {
276
- self.propensity_column_name: self.randomness.get_draw(pop_data.index),
277
- self.exposure_column_name: self.exposure_distribution.ppf(propensity_values),
278
- }
286
+ propensity = pd.Series(
287
+ self.randomness.get_draw(pop_data.index), name=self.propensity_column_name
279
288
  )
280
- self.population_view.update(df)
289
+ self.population_view.update(propensity)
290
+ self.update_exposure_column(pop_data.index)
281
291
 
282
292
  def on_time_step_prepare(self, event: Event) -> None:
283
- exposure_values = self.exposure(event.index)
284
- exposure_col = pd.Series(exposure_values, name=self.exposure_column_name)
285
- self.population_view.update(exposure_col)
293
+ self.update_exposure_column(event.index)
294
+
295
+ def update_exposure_column(self, index: pd.Index) -> None:
296
+ if self.create_exposure_column:
297
+ exposure = pd.Series(self.exposure(index), name=self.exposure_column_name)
298
+ self.population_view.update(exposure)
286
299
 
287
300
  ##################################
288
301
  # Pipeline sources and modifiers #
@@ -157,16 +157,19 @@ class RiskEffect(Component):
157
157
  rr_source = configuration.data_sources.relative_risk
158
158
  rr_dist_parameters = configuration.data_source_parameters.relative_risk.to_dict()
159
159
 
160
- try:
161
- distribution = getattr(import_module("scipy.stats"), rr_source)
162
- rng = np.random.default_rng(builder.randomness.get_seed(self.name))
163
- rr_data = distribution(**rr_dist_parameters).ppf(rng.random())
164
- except AttributeError:
160
+ if isinstance(rr_source, str):
161
+ try:
162
+ distribution = getattr(import_module("scipy.stats"), rr_source)
163
+ rng = np.random.default_rng(builder.randomness.get_seed(self.name))
164
+ rr_data = distribution(**rr_dist_parameters).ppf(rng.random())
165
+ except AttributeError:
166
+ rr_data = self.get_filtered_data(builder, rr_source)
167
+ except TypeError:
168
+ raise ConfigurationError(
169
+ f"Parameters {rr_dist_parameters} are not valid for distribution {rr_source}."
170
+ )
171
+ else:
165
172
  rr_data = self.get_filtered_data(builder, rr_source)
166
- except TypeError:
167
- raise ConfigurationError(
168
- f"Parameters {rr_dist_parameters} are not valid for distribution {rr_source}."
169
- )
170
173
  return rr_data
171
174
 
172
175
  def get_filtered_data(
@@ -198,6 +201,8 @@ class RiskEffect(Component):
198
201
  cat2["parameter"] = "cat2"
199
202
  cat2["value"] = 1
200
203
  rr_data = pd.concat([cat1, cat2], ignore_index=True)
204
+ if "parameter" in rr_data.index.names:
205
+ rr_data = rr_data.reset_index("parameter")
201
206
 
202
207
  rr_value_cols = list(rr_data["parameter"].unique())
203
208
  rr_data = pivot_categorical(builder, self.risk, rr_data, "parameter")
@@ -361,6 +366,10 @@ class NonLogLinearRiskEffect(RiskEffect):
361
366
  # Setup methods #
362
367
  #################
363
368
 
369
+ @staticmethod
370
+ def get_name(risk: EntityString, target: TargetString) -> str:
371
+ return f"non_log_linear_risk_effect.{risk.name}_on_{target}"
372
+
364
373
  def build_all_lookup_tables(self, builder: Builder) -> None:
365
374
  rr_data = self.get_relative_risk_data(builder)
366
375
  self.validate_rr_data(rr_data)
@@ -191,7 +191,7 @@ class LBWSGRisk(Risk):
191
191
  return f"{axis}.birth_exposure"
192
192
 
193
193
  @staticmethod
194
- def exposure_column_name(axis: str) -> str:
194
+ def get_exposure_column_name(axis: str) -> str:
195
195
  return f"{axis}_exposure"
196
196
 
197
197
  ##############
@@ -206,7 +206,7 @@ class LBWSGRisk(Risk):
206
206
 
207
207
  @property
208
208
  def columns_created(self) -> List[str]:
209
- return [self.exposure_column_name(axis) for axis in self.AXES]
209
+ return [self.get_exposure_column_name(axis) for axis in self.AXES]
210
210
 
211
211
  #####################
212
212
  # Lifecycle methods #
@@ -256,7 +256,7 @@ class LBWSGRisk(Risk):
256
256
 
257
257
  def on_initialize_simulants(self, pop_data: SimulantData) -> None:
258
258
  birth_exposures = {
259
- self.exposure_column_name(axis): self.birth_exposures[
259
+ self.get_exposure_column_name(axis): self.birth_exposures[
260
260
  self.birth_exposure_pipeline_name(axis)
261
261
  ](pop_data.index)
262
262
  for axis in self.AXES
@@ -318,7 +318,7 @@ class LBWSGRiskEffect(RiskEffect):
318
318
  super().__init__("risk_factor.low_birth_weight_and_short_gestation", target)
319
319
 
320
320
  self.lbwsg_exposure_column_names = [
321
- LBWSGRisk.exposure_column_name(axis) for axis in LBWSGRisk.AXES
321
+ LBWSGRisk.get_exposure_column_name(axis) for axis in LBWSGRisk.AXES
322
322
  ]
323
323
  self.relative_risk_pipeline_name = (
324
324
  f"effect_of_{self.risk.name}_on_{self.target.name}.relative_risk"
@@ -433,8 +433,8 @@ class LBWSGRiskEffect(RiskEffect):
433
433
  pop = self.population_view.subview(["sex"] + self.lbwsg_exposure_column_names).get(
434
434
  pop_data.index
435
435
  )
436
- birth_weight = pop[LBWSGRisk.exposure_column_name(BIRTH_WEIGHT)]
437
- gestational_age = pop[LBWSGRisk.exposure_column_name(GESTATIONAL_AGE)]
436
+ birth_weight = pop[LBWSGRisk.get_exposure_column_name(BIRTH_WEIGHT)]
437
+ gestational_age = pop[LBWSGRisk.get_exposure_column_name(GESTATIONAL_AGE)]
438
438
 
439
439
  is_male = pop["sex"] == "Male"
440
440
  is_tmrel = (self.TMREL_GESTATIONAL_AGE_INTERVAL.left <= gestational_age) & (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium_public_health
3
- Version: 3.0.4
3
+ Version: 3.0.7
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
@@ -77,6 +77,7 @@ MOCKERS = {
77
77
  "population": {
78
78
  "age_bins": make_age_bins(),
79
79
  "structure": make_uniform_pop_data(),
80
+ "demographic_dimensions": make_uniform_pop_data().drop(["location", "value"], axis=1),
80
81
  "theoretical_minimum_risk_life_expectancy": (
81
82
  build_table_with_age(
82
83
  98.0,
@@ -23,6 +23,7 @@ from vivarium_public_health.risks.base_risk import Risk
23
23
  from vivarium_public_health.risks.effect import NonLogLinearRiskEffect, RiskEffect
24
24
  from vivarium_public_health.utilities import EntityString
25
25
 
26
+
26
27
  #
27
28
  #
28
29
  # def test_incidence_rate_risk_effect(base_config, base_plugins, mocker):
@@ -413,6 +414,95 @@ from vivarium_public_health.utilities import EntityString
413
414
  # source=lambda index: pd.Series(0.1, index=index))
414
415
  #
415
416
  # assert np.allclose(from_yearly(0.1, time_step)*50, em(simulation.get_population().index))
417
+ def _setup_risk_effect_simulation(
418
+ config: LayeredConfigTree,
419
+ plugins: LayeredConfigTree,
420
+ risk: Union[str, Risk],
421
+ risk_effect: RiskEffect,
422
+ data: Dict[str, Any],
423
+ ) -> InteractiveContext:
424
+ components = [
425
+ TestPopulation(),
426
+ risk,
427
+ SI("test_cause"),
428
+ risk_effect,
429
+ ]
430
+
431
+ simulation = InteractiveContext(
432
+ components=components,
433
+ configuration=config,
434
+ plugin_configuration=plugins,
435
+ setup=False,
436
+ )
437
+
438
+ for key, value in data.items():
439
+ simulation._data.write(key, value)
440
+
441
+ simulation.setup()
442
+ return simulation
443
+
444
+
445
+ def build_dichotomous_risk_effect_data(rr_value: float) -> pd.DataFrame:
446
+ df = pd.DataFrame(
447
+ {
448
+ "affected_entity": "test_cause",
449
+ "affected_measure": "incidence_rate",
450
+ "year_start": 1990,
451
+ "year_end": 1991,
452
+ "value": [rr_value, 1.0],
453
+ },
454
+ index=pd.Index(["cat1", "cat2"], name="parameter"),
455
+ )
456
+ return df
457
+
458
+
459
+ @pytest.mark.parametrize(
460
+ "rr_source, rr_value",
461
+ [("str", 2.0), ("float", 0.9), ("DataFrame", 0.5)],
462
+ )
463
+ def test_rr_sources(rr_source, rr_value, dichotomous_risk, base_config, base_plugins):
464
+ risk = dichotomous_risk[0]
465
+ effect = RiskEffect(risk.name, "cause.test_cause.incidence_rate")
466
+ base_config.update({"risk_factor.test_risk": {"data_sources": {"exposure": 1.0}}})
467
+
468
+ # TMREL of 1
469
+ tmred = {"distribution": "uniform", "min": 1, "max": 1, "inverted": False}
470
+
471
+ data = {
472
+ f"{risk.name}.tmred": tmred,
473
+ f"{risk.name}.population_attributable_fraction": 0,
474
+ "cause.test_cause.incidence_rate": 1,
475
+ }
476
+
477
+ if rr_source == "DataFrame":
478
+ rr_data = build_dichotomous_risk_effect_data(rr_value)
479
+ base_config.update(
480
+ {
481
+ "risk_effect.test_risk_on_cause.test_cause.incidence_rate": {
482
+ "data_sources": {"relative_risk": rr_data}
483
+ }
484
+ }
485
+ )
486
+ elif rr_source == "float":
487
+ base_config.update(
488
+ {
489
+ "risk_effect.test_risk_on_cause.test_cause.incidence_rate": {
490
+ "data_sources": {"relative_risk": rr_value}
491
+ }
492
+ }
493
+ )
494
+ else: # rr_source is a string because it gets read from RiskEffect's configuration defaults
495
+ rr_data = build_dichotomous_risk_effect_data(rr_value)
496
+ data[f"{risk.name}.relative_risk"] = rr_data
497
+
498
+ base_config.update({"risk_factor.test_risk": {"distribution_type": "dichotomous"}})
499
+ simulation = _setup_risk_effect_simulation(base_config, base_plugins, risk, effect, data)
500
+
501
+ pop = simulation.get_population()
502
+ rate = simulation.get_value("test_cause.incidence_rate")(
503
+ pop.index, skip_post_processor=True
504
+ )
505
+ assert set(rate.unique()) == {rr_value}
416
506
 
417
507
 
418
508
  ##############################
@@ -458,33 +548,6 @@ class CustomExposureRisk(Component):
458
548
  return data
459
549
 
460
550
 
461
- def _setup_risk_simulation(
462
- config: LayeredConfigTree,
463
- plugins: LayeredConfigTree,
464
- risk: Union[str, Risk],
465
- data: Dict[str, Any],
466
- ) -> InteractiveContext:
467
- components = [
468
- TestPopulation(),
469
- risk,
470
- SI("some_disease"),
471
- NonLogLinearRiskEffect(risk.name, "cause.some_disease.incidence_rate"),
472
- ]
473
-
474
- simulation = InteractiveContext(
475
- components=components,
476
- configuration=config,
477
- plugin_configuration=plugins,
478
- setup=False,
479
- )
480
-
481
- for key, value in data.items():
482
- simulation._data.write(key, value)
483
-
484
- simulation.setup()
485
- return simulation
486
-
487
-
488
551
  @pytest.mark.parametrize(
489
552
  "rr_parameter_data, error_message",
490
553
  [
@@ -496,14 +559,12 @@ def _setup_risk_simulation(
496
559
  )
497
560
  def test_non_loglinear_effect(rr_parameter_data, error_message, base_config, base_plugins):
498
561
  risk = CustomExposureRisk("risk_factor.test_risk")
499
- effect = NonLogLinearRiskEffect(
500
- "risk_factor.test_risk", "cause.some_disease.incidence_rate"
501
- )
562
+ effect = NonLogLinearRiskEffect(risk.name, "cause.test_cause.incidence_rate")
502
563
 
503
564
  risk_effect_rrs = [2.0, 2.4, 4.0]
504
565
  rr_data = pd.DataFrame(
505
566
  {
506
- "affected_entity": "some_disease",
567
+ "affected_entity": "test_cause",
507
568
  "affected_measure": "incidence_rate",
508
569
  "year_start": 1990,
509
570
  "year_end": 1991,
@@ -518,20 +579,24 @@ def test_non_loglinear_effect(rr_parameter_data, error_message, base_config, bas
518
579
  f"{risk.name}.relative_risk": rr_data,
519
580
  f"{risk.name}.tmred": tmred,
520
581
  f"{risk.name}.population_attributable_fraction": 0,
521
- "cause.some_disease.incidence_rate": 1,
582
+ "cause.test_cause.incidence_rate": 1,
522
583
  }
523
584
 
524
585
  base_config.update({"population": {"population_size": 10}})
525
586
 
526
587
  if error_message:
527
588
  with pytest.raises(ValueError, match=error_message):
528
- simulation = _setup_risk_simulation(base_config, base_plugins, risk, data)
589
+ simulation = _setup_risk_effect_simulation(
590
+ base_config, base_plugins, risk, effect, data
591
+ )
529
592
  return
530
593
  else:
531
- simulation = _setup_risk_simulation(base_config, base_plugins, risk, data)
594
+ simulation = _setup_risk_effect_simulation(
595
+ base_config, base_plugins, risk, effect, data
596
+ )
532
597
 
533
598
  pop = simulation.get_population()
534
- rate = simulation.get_value("some_disease.incidence_rate")(
599
+ rate = simulation.get_value("test_cause.incidence_rate")(
535
600
  pop.index, skip_post_processor=True
536
601
  )
537
602
  expected_values = np.interp(
@@ -1 +0,0 @@
1
- __version__ = "3.0.4"
@@ -1,24 +0,0 @@
1
- from dataclasses import dataclass
2
-
3
-
4
- @dataclass
5
- class SimpleCause:
6
- """A simple dataclass to represent the bare minimum information needed
7
- for observers, e.g. 'all_causes' as a cause of disability.
8
-
9
- It also includes a class method to convert a provided disease state into a
10
- ``SimpleCause`` instance.
11
-
12
- """
13
-
14
- state_id: str
15
- """The state_id of the cause."""
16
- model: str
17
- """The model of the cause."""
18
- cause_type: str
19
- """The cause type of the cause."""
20
-
21
- @classmethod
22
- def create_from_disease_state(cls, disease_state: type) -> "SimpleCause":
23
- """Create a SimpleCause instance from a"""
24
- return cls(disease_state.state_id, disease_state.model, disease_state.cause_type)