vivarium-public-health 3.0.10__tar.gz → 3.0.11__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.10 → vivarium_public_health-3.0.11}/.github/workflows/build.yml +8 -2
  2. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/CHANGELOG.rst +4 -0
  3. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/PKG-INFO +1 -1
  4. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/__init__.py +1 -0
  5. vivarium_public_health-3.0.11/src/vivarium_public_health/_version.py +1 -0
  6. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/population/__init__.py +1 -1
  7. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/population/base_population.py +47 -3
  8. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/population/data_transformations.py +3 -1
  9. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health.egg-info/PKG-INFO +1 -1
  10. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/population/test_add_new_birth_cohort.py +1 -1
  11. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/population/test_base_population.py +68 -2
  12. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/population/test_data_transformations.py +1 -1
  13. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/test_utilities.py +37 -1
  14. vivarium_public_health-3.0.10/src/vivarium_public_health/_version.py +0 -1
  15. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.bandit +0 -0
  16. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.flake8 +0 -0
  17. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.gitattributes +0 -0
  18. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.github/CODEOWNERS +0 -0
  19. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.github/pull_request_template.md +0 -0
  20. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.github/workflows/deploy.yml +0 -0
  21. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.gitignore +0 -0
  22. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.pylintrc +0 -0
  23. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.readthedocs.yml +0 -0
  24. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/.zenodo.json +0 -0
  25. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/CODE_OF_CONDUCT.rst +0 -0
  26. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/CONTRIBUTING.rst +0 -0
  27. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/Jenkinsfile +0 -0
  28. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/LICENSE.txt +0 -0
  29. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/MANIFEST.in +0 -0
  30. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/Makefile +0 -0
  31. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/README.rst +0 -0
  32. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/Makefile +0 -0
  33. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/nitpick-exceptions +0 -0
  34. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/_static/style.css +0 -0
  35. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/_templates/layout.html +0 -0
  36. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/disease/index.rst +0 -0
  37. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/disease/model.rst +0 -0
  38. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/disease/models.rst +0 -0
  39. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/disease/special_disease.rst +0 -0
  40. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/disease/state.rst +0 -0
  41. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/disease/transition.rst +0 -0
  42. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/index.rst +0 -0
  43. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/mslt/delay.rst +0 -0
  44. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/mslt/disease.rst +0 -0
  45. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/mslt/index.rst +0 -0
  46. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/mslt/intervention.rst +0 -0
  47. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/mslt/magic_wand_components.rst +0 -0
  48. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/mslt/observer.rst +0 -0
  49. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/mslt/population.rst +0 -0
  50. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/plugins/index.rst +0 -0
  51. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/plugins/parser.rst +0 -0
  52. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/population/add_new_birth_cohorts.rst +0 -0
  53. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/population/base_population.rst +0 -0
  54. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/population/data_transformations.rst +0 -0
  55. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/population/index.rst +0 -0
  56. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/population/mortality.rst +0 -0
  57. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/disability.rst +0 -0
  58. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/disease.rst +0 -0
  59. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/index.rst +0 -0
  60. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/mortality.rst +0 -0
  61. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/observer.rst +0 -0
  62. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/risk.rst +0 -0
  63. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/simple_cause.rst +0 -0
  64. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/results/stratification.rst +0 -0
  65. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/risks/base_risk.rst +0 -0
  66. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/risks/data_transformations.rst +0 -0
  67. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/risks/distributions.rst +0 -0
  68. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/risks/effect.rst +0 -0
  69. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/risks/implementations/index.rst +0 -0
  70. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/risks/implementations/low_birth_weight_and_short_gestation.rst +0 -0
  71. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/risks/index.rst +0 -0
  72. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/treatment/index.rst +0 -0
  73. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/treatment/magic_wand.rst +0 -0
  74. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/treatment/scale_up.rst +0 -0
  75. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/treatment/therapeutic_inertia.rst +0 -0
  76. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/api_reference/utilities.rst +0 -0
  77. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/conf.py +0 -0
  78. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/index.rst +0 -0
  79. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/tutorials/index.rst +0 -0
  80. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/docs/source/tutorials/risk_exposure.rst +0 -0
  81. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/pyproject.toml +0 -0
  82. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/setup.cfg +0 -0
  83. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/setup.py +0 -0
  84. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/__about__.py +0 -0
  85. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/disease/__init__.py +0 -0
  86. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/disease/model.py +0 -0
  87. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/disease/models.py +0 -0
  88. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/disease/special_disease.py +0 -0
  89. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/disease/state.py +0 -0
  90. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/disease/transition.py +0 -0
  91. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/mslt/__init__.py +0 -0
  92. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/mslt/delay.py +0 -0
  93. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/mslt/disease.py +0 -0
  94. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/mslt/intervention.py +0 -0
  95. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/mslt/magic_wand_components.py +0 -0
  96. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/mslt/observer.py +0 -0
  97. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/mslt/population.py +0 -0
  98. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/plugins/__init__.py +0 -0
  99. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/plugins/parser.py +0 -0
  100. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/population/add_new_birth_cohorts.py +0 -0
  101. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/population/mortality.py +0 -0
  102. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/__init__.py +0 -0
  103. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/columns.py +0 -0
  104. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/disability.py +0 -0
  105. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/disease.py +0 -0
  106. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/mortality.py +0 -0
  107. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/observer.py +0 -0
  108. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/risk.py +0 -0
  109. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/simple_cause.py +0 -0
  110. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/results/stratification.py +0 -0
  111. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/risks/__init__.py +0 -0
  112. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/risks/base_risk.py +0 -0
  113. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/risks/data_transformations.py +0 -0
  114. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/risks/distributions.py +0 -0
  115. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/risks/effect.py +0 -0
  116. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/risks/implementations/__init__.py +0 -0
  117. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py +0 -0
  118. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/treatment/__init__.py +0 -0
  119. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/treatment/magic_wand.py +0 -0
  120. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/treatment/scale_up.py +0 -0
  121. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/treatment/therapeutic_inertia.py +0 -0
  122. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health/utilities.py +0 -0
  123. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health.egg-info/SOURCES.txt +0 -0
  124. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health.egg-info/dependency_links.txt +0 -0
  125. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health.egg-info/not-zip-safe +0 -0
  126. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health.egg-info/requires.txt +0 -0
  127. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/src/vivarium_public_health.egg-info/top_level.txt +0 -0
  128. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/__init__.py +0 -0
  129. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/conftest.py +0 -0
  130. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/disease/__init__.py +0 -0
  131. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/disease/test_disease.py +0 -0
  132. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/disease/test_special_disease.py +0 -0
  133. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/mock_artifact.py +0 -0
  134. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/plugins/__init__.py +0 -0
  135. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/plugins/test_parser.py +0 -0
  136. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/population/__init__.py +0 -0
  137. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/population/conftest.py +0 -0
  138. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/population/test_mortality.py +0 -0
  139. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/results/__init__.py +0 -0
  140. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/results/test_categorical_risk_observer.py +0 -0
  141. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/results/test_disability.py +0 -0
  142. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/results/test_disability_observer.py +0 -0
  143. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/results/test_disease_observer.py +0 -0
  144. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/results/test_mortality_observer.py +0 -0
  145. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/results/test_stratification.py +0 -0
  146. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/risks/__init__.py +0 -0
  147. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/risks/conftest.py +0 -0
  148. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/risks/test_base_risk.py +0 -0
  149. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/risks/test_data_transformations.py +0 -0
  150. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/risks/test_distributions.py +0 -0
  151. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/risks/test_effect.py +0 -0
  152. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/risks/test_low_birth_weight_and_short_gestation.py +0 -0
  153. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/treatment/__init__.py +0 -0
  154. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tests/treatment/test_scale_up.py +0 -0
  155. {vivarium_public_health-3.0.10 → vivarium_public_health-3.0.11}/tox.ini +0 -0
@@ -11,9 +11,15 @@ on:
11
11
  - cron: "0 8 * * *"
12
12
 
13
13
  jobs:
14
- call_build:
14
+ build:
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.9", "3.10", "3.11"]
15
18
  uses:
16
19
  ihmeuw/vivarium_build_utils/.github/workflows/build.yml@main
17
20
  with:
18
21
  dependencies: "layered_config_tree,vivarium"
19
- use_mypy: false
22
+ skip_mypy: true
23
+ secrets:
24
+ NOTIFY_EMAIL: ${{ secrets.NOTIFY_EMAIL }}
25
+ NOTIFY_PASSWORD: ${{ secrets.NOTIFY_PASSWORD }}
@@ -1,3 +1,7 @@
1
+ **3.0.11 - 11/07/24**
2
+
3
+ - Add ScaledPopulation component to population package
4
+
1
5
  **3.0.10 - 10/29/24**
2
6
 
3
7
  - Import subpackage classes to top-level namespace
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium_public_health
3
- Version: 3.0.10
3
+ Version: 3.0.11
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
@@ -30,6 +30,7 @@ from vivarium_public_health.population import (
30
30
  FertilityCrudeBirthRate,
31
31
  FertilityDeterministic,
32
32
  Mortality,
33
+ ScaledPopulation,
33
34
  )
34
35
  from vivarium_public_health.results import (
35
36
  CategoricalRiskObserver,
@@ -0,0 +1 @@
1
+ __version__ = "3.0.11"
@@ -3,5 +3,5 @@ from .add_new_birth_cohorts import (
3
3
  FertilityCrudeBirthRate,
4
4
  FertilityDeterministic,
5
5
  )
6
- from .base_population import BasePopulation, generate_population
6
+ from .base_population import BasePopulation, ScaledPopulation, generate_population
7
7
  from .mortality import Mortality
@@ -8,6 +8,8 @@ characteristics to simulants.
8
8
 
9
9
  """
10
10
 
11
+ from __future__ import annotations
12
+
11
13
  from typing import Callable, Dict, Iterable, List
12
14
 
13
15
  import numpy as np
@@ -76,12 +78,11 @@ class BasePopulation(Component):
76
78
  # Validate configuration for deprecated keys
77
79
  self._validate_config_for_deprecated_keys()
78
80
 
79
- source_population_structure = load_population_structure(builder)
81
+ source_population_structure = self._load_population_structure(builder)
80
82
  self.demographic_proportions = assign_demographic_proportions(
81
83
  source_population_structure,
82
84
  include_sex=self.config.include_sex,
83
85
  )
84
-
85
86
  self.randomness = self.get_randomness_streams(builder)
86
87
  self.register_simulants = builder.randomness.register_simulants
87
88
 
@@ -138,7 +139,6 @@ class BasePopulation(Component):
138
139
  demographic_proportions = self.get_demographic_proportions_for_creation_time(
139
140
  self.demographic_proportions, pop_data.creation_time.year
140
141
  )
141
-
142
142
  self.population_view.update(
143
143
  generate_population(
144
144
  simulant_ids=pop_data.index,
@@ -202,6 +202,50 @@ class BasePopulation(Component):
202
202
  f"Public Health. Use the new key '{mapper[key]}' instead."
203
203
  )
204
204
 
205
+ def _load_population_structure(self, builder: Builder) -> pd.DataFrame:
206
+ return load_population_structure(builder)
207
+
208
+
209
+ class ScaledPopulation(BasePopulation):
210
+ """This component is to be used in place of BasePopulation when all simulants are
211
+ a subset of the total population and need to be rescaled. The base population
212
+ structure is multiplied by a provided scaling factor. This scaling factor
213
+ can be a dataframe passed in or a string that corresponds to an artifact key.
214
+ If providing an artifact key, users can specify that in the configuration file.
215
+ For example:
216
+
217
+ .. code-block:: yaml
218
+
219
+ components:
220
+ vivarium_public_health:
221
+ population:
222
+ - ScaledPopulation("some.artifact.key")
223
+
224
+
225
+ """
226
+
227
+ def __init__(self, scaling_factor: str | pd.DataFrame):
228
+ super().__init__()
229
+ self.scaling_factor = scaling_factor
230
+ """Set a multiplicative scaling factor for the population structure."""
231
+
232
+ def _load_population_structure(self, builder: Builder) -> pd.DataFrame:
233
+ scaling_factor = self.get_data(builder, self.scaling_factor)
234
+ population_structure = load_population_structure(builder)
235
+ if not isinstance(scaling_factor, pd.DataFrame):
236
+ raise ValueError(
237
+ f"Scaling factor must be a pandas DataFrame. Provided value: {scaling_factor}"
238
+ )
239
+ scaling_factor = scaling_factor.set_index(
240
+ [col for col in scaling_factor.columns if col != "value"]
241
+ )
242
+ population_structure = population_structure.set_index(
243
+ [col for col in population_structure.columns if col != "value"]
244
+ )
245
+ scaled_population_structure = (population_structure * scaling_factor).reset_index()
246
+
247
+ return scaled_population_structure
248
+
205
249
 
206
250
  class AgeOutSimulants(Component):
207
251
  """Component for handling aged-out simulants"""
@@ -13,6 +13,7 @@ from typing import Tuple, Union
13
13
 
14
14
  import numpy as np
15
15
  import pandas as pd
16
+ from vivarium.framework.engine import Builder
16
17
  from vivarium.framework.randomness import RandomnessStream
17
18
 
18
19
  _SORT_ORDER = ["location", "year_start", "sex", "age_start"]
@@ -493,11 +494,12 @@ def get_cause_deleted_mortality_rate(all_cause_mortality_rate, list_of_csmrs):
493
494
  )
494
495
 
495
496
 
496
- def load_population_structure(builder):
497
+ def load_population_structure(builder: Builder) -> pd.DataFrame:
497
498
  data = builder.data.load("population.structure")
498
499
  # create an age column which is the midpoint of the age group
499
500
  data["age"] = data.apply(lambda row: (row["age_start"] + row["age_end"]) / 2, axis=1)
500
501
  data["location"] = builder.data.load("population.location")
502
+
501
503
  return data
502
504
 
503
505
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium_public_health
3
- Version: 3.0.10
3
+ Version: 3.0.11
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
@@ -130,7 +130,7 @@ def test_FertilityCrudeBirthRate_extrapolate(base_config, base_plugins):
130
130
  }
131
131
  )
132
132
  pop_size = base_config.population.population_size
133
- true_pop_size = 50000 # What's available in the mock artifact
133
+ true_pop_size = 25000 # What's available in the mock artifact
134
134
  live_births_by_sex = 500
135
135
  components = [TestPopulation(), FertilityCrudeBirthRate()]
136
136
 
@@ -1,15 +1,16 @@
1
1
  import math
2
- from pathlib import Path
3
2
 
4
3
  import numpy as np
5
4
  import pandas as pd
6
5
  import pytest
7
6
  from vivarium import InteractiveContext
8
7
  from vivarium.testing_utilities import get_randomness
8
+ from vivarium_testing_utils import FuzzyChecker
9
9
 
10
10
  import vivarium_public_health.population.base_population as bp
11
11
  import vivarium_public_health.population.data_transformations as dt
12
- from tests.test_utilities import make_uniform_pop_data
12
+ from tests.mock_artifact import MockArtifact
13
+ from tests.test_utilities import make_uniform_pop_data, simple_pop_structure
13
14
  from vivarium_public_health import utilities
14
15
 
15
16
 
@@ -283,6 +284,71 @@ def test__assign_demography_with_age_bounds_error(base_simulants, include_sex):
283
284
  )
284
285
 
285
286
 
287
+ @pytest.mark.parametrize("constructor_type", ["string", "data"])
288
+ def test_scaled_population(
289
+ constructor_type, config, base_plugins, mocker, fuzzy_checker: FuzzyChecker
290
+ ):
291
+ config.update(
292
+ {
293
+ "population": {
294
+ "population_size": 1_000_000,
295
+ "include_sex": "Both",
296
+ },
297
+ "time": {"step_size": 1},
298
+ },
299
+ layer="override",
300
+ )
301
+
302
+ # Simple pop data
303
+ pop_structure = simple_pop_structure()
304
+ # Simple scalar data to pass to ScaledPopulation
305
+ scalar_data = simple_pop_structure().drop(columns=["location"])
306
+ scalar_values = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
307
+ scalar_data["value"] = scalar_values
308
+
309
+ # Add data to artifact and mock return for plugin
310
+ mock_art = MockArtifact()
311
+ mock_art.write("population.structure", pop_structure)
312
+ mocker.patch(
313
+ "tests.mock_artifact.MockArtifactManager._load_artifact",
314
+ ).return_value = mock_art
315
+
316
+ if constructor_type == "string":
317
+ mock_art.write("population.scalar", scalar_data)
318
+ scaling_factor = "population.scalar"
319
+ else:
320
+ scaling_factor = scalar_data
321
+ scaled_pop = bp.ScaledPopulation(scaling_factor)
322
+ sim = InteractiveContext(
323
+ components=[scaled_pop], configuration=config, plugin_configuration=base_plugins
324
+ )
325
+ pop = sim.get_population()
326
+ # Use FuzzyChecker to compare population structure to demographic proportion by
327
+ # iterating through each age_group/sex combination
328
+ scaled_structure = pop_structure.copy()
329
+ scaled_structure["value"] = scaled_structure["value"] * scalar_data["value"]
330
+
331
+ for row in range(len(scaled_structure)):
332
+ row_data = scaled_structure.iloc[row]
333
+ age_start = row_data["age_start"]
334
+ sex = row_data["sex"]
335
+ # Get proportion of each age group
336
+ target_proportion = row_data["value"] / scaled_structure["value"].sum()
337
+ number_of_sims = len(
338
+ pop.loc[
339
+ (pop["age"] >= age_start)
340
+ & (pop["age"] <= row_data["age_end"])
341
+ & (pop["sex"] == sex)
342
+ ]
343
+ )
344
+ fuzzy_checker.fuzzy_assert_proportion(
345
+ observed_numerator=number_of_sims,
346
+ observed_denominator=len(pop),
347
+ target_proportion=target_proportion,
348
+ name=f"scaled_pop_proportion_check_{sex}_{age_start}",
349
+ )
350
+
351
+
286
352
  def _check_population(simulants, initial_age, step_size, include_sex):
287
353
  assert len(simulants) == len(simulants.age.unique())
288
354
  assert simulants.age.min() > initial_age
@@ -127,7 +127,7 @@ def test_smooth_ages(pop_data, include_sex):
127
127
  "sex": (
128
128
  ["Male", "Female"] * 10000 if include_sex == "Both" else [include_sex] * 20000
129
129
  ),
130
- "location": [1, 2] * 10000,
130
+ "location": [1] * 20000,
131
131
  }
132
132
  )
133
133
  randomness = get_randomness()
@@ -64,7 +64,7 @@ def make_uniform_pop_data(age_bin_midpoint=False):
64
64
  age_bins = [(b.age_start, b.age_end) for b in make_age_bins().itertuples()]
65
65
  sexes = ("Male", "Female")
66
66
  years = zip(range(1990, 2018), range(1991, 2019))
67
- locations = (1, 2)
67
+ locations = list(range(1, 2))
68
68
 
69
69
  age_bins, sexes, years, locations = zip(*product(age_bins, sexes, years, locations))
70
70
  mins, maxes = zip(*age_bins)
@@ -116,3 +116,39 @@ def make_age_bins():
116
116
  names=["age_start", "age_end", "age_group_name"],
117
117
  )
118
118
  return pd.DataFrame(index=idx).reset_index()
119
+
120
+
121
+ def simple_pop_structure() -> pd.DataFrame:
122
+ # Create simple population structure
123
+ age_idx = pd.MultiIndex.from_tuples(
124
+ [
125
+ (0.0, 25.0, "Young People"),
126
+ (25.0, 50.0, "Old People"),
127
+ (50.0, 75.0, "Ancient People"),
128
+ (75.0, 100.0, "People Who Beat the Odds"),
129
+ ],
130
+ names=["age_start", "age_end", "age_group_name"],
131
+ )
132
+ age_df = pd.DataFrame(index=age_idx).reset_index()
133
+ age_bins = [(group.age_start, group.age_end) for group in age_df.itertuples()]
134
+ sexes = ("Male", "Female")
135
+ location = ["Kenya"]
136
+ years = zip(range(2021, 2022), range(2022, 2023))
137
+
138
+ age_bins, sexes, years, location = zip(*product(age_bins, sexes, years, location))
139
+ mins, maxes = zip(*age_bins)
140
+ year_starts, year_ends = zip(*years)
141
+
142
+ pop_structure = pd.DataFrame(
143
+ {
144
+ "age_start": mins,
145
+ "age_end": maxes,
146
+ "sex": sexes,
147
+ "year_start": year_starts,
148
+ "year_end": year_ends,
149
+ "location": location,
150
+ # We have 8 demographic groups (4 age groups * 2 sexes)
151
+ "value": [1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0],
152
+ }
153
+ )
154
+ return pop_structure
@@ -1 +0,0 @@
1
- __version__ = "3.0.10"