vivarium-public-health 4.3.4__py3-none-any.whl → 4.3.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- __version__ = "4.3.4"
1
+ __version__ = "4.3.6"
@@ -235,15 +235,50 @@ class ScaledPopulation(BasePopulation):
235
235
  raise ValueError(
236
236
  f"Scaling factor must be a pandas DataFrame. Provided value: {scaling_factor}"
237
237
  )
238
- scaling_factor = scaling_factor.set_index(
239
- [col for col in scaling_factor.columns if col != "value"]
238
+ start_year = builder.configuration.time.start.year
239
+ population_structure, scaling_factor = self._format_data_inputs(
240
+ population_structure, scaling_factor, start_year
240
241
  )
241
- population_structure = population_structure.set_index(
242
- [col for col in population_structure.columns if col != "value"]
242
+
243
+ return (population_structure * scaling_factor).reset_index()
244
+
245
+ def _format_data_inputs(
246
+ self, pop_structure: pd.DataFrame, scalar_data: pd.DataFrame, year: int
247
+ ) -> tuple[pd.DataFrame, pd.DataFrame]:
248
+ """Data cleaning function to check whether scalar_data and population structure are compatible for scaling
249
+ the population structure of a simulation."""
250
+
251
+ scaling_factor = scalar_data.set_index(
252
+ [col for col in scalar_data.columns if col != "value"]
243
253
  )
244
- scaled_population_structure = (population_structure * scaling_factor).reset_index()
254
+ population_structure = pop_structure.set_index(
255
+ [col for col in pop_structure.columns if col != "value"]
256
+ )
257
+ if "year_start" not in scaling_factor.index.names:
258
+ return population_structure, scaling_factor
259
+
260
+ # Subset to start year of simulation or closest year
261
+ pop_reference_years = sorted(
262
+ set(population_structure.index.get_level_values("year_start"))
263
+ )
264
+ pop_year_index = np.digitize(year, pop_reference_years).item() - 1
265
+ scale_reference_years = sorted(
266
+ set(scaling_factor.index.get_level_values("year_start"))
267
+ )
268
+ scale_year_index = np.digitize(year, scale_reference_years).item() - 1
269
+ # Subset to start year of simulation or earliest year. E.g. if start year = 2021 and pop
270
+ # structure has 2021, we will subset to 2021. If pop structure minimum year is 2025, we
271
+ # will subset to 2025.
272
+ population_structure = population_structure.loc[
273
+ population_structure.index.get_level_values("year_start")
274
+ == pop_reference_years[pop_year_index]
275
+ ]
276
+ scaling_factor = scaling_factor.loc[
277
+ scaling_factor.index.get_level_values("year_start")
278
+ == scale_reference_years[scale_year_index]
279
+ ]
245
280
 
246
- return scaled_population_structure
281
+ return population_structure, scaling_factor
247
282
 
248
283
 
249
284
  class AgeOutSimulants(Component):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vivarium_public_health
3
- Version: 4.3.4
3
+ Version: 4.3.6
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
@@ -26,45 +26,28 @@ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
26
26
  Classifier: Topic :: Scientific/Engineering :: Physics
27
27
  Classifier: Topic :: Software Development :: Libraries
28
28
  License-File: LICENSE.txt
29
+ Requires-Dist: vivarium_dependencies[loguru,numpy_lt_2,pandas,pyarrow,scipy,tables]
29
30
  Requires-Dist: vivarium_build_utils<3.0.0,>=2.0.1
30
31
  Requires-Dist: vivarium>=3.4.3
31
- Requires-Dist: layered_config_tree>=3.2.0
32
- Requires-Dist: loguru
33
- Requires-Dist: numpy<2.0.0
34
- Requires-Dist: pandas
35
- Requires-Dist: scipy
36
- Requires-Dist: tables
32
+ Requires-Dist: layered_config_tree
37
33
  Requires-Dist: risk_distributions>=2.0.11
38
- Requires-Dist: pyarrow
39
34
  Provides-Extra: docs
40
- Requires-Dist: sphinx<7.0; extra == "docs"
41
- Requires-Dist: sphinx-rtd-theme; extra == "docs"
42
- Requires-Dist: sphinx-click; extra == "docs"
43
- Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
44
- Requires-Dist: IPython; extra == "docs"
45
- Requires-Dist: matplotlib; extra == "docs"
35
+ Requires-Dist: vivarium_dependencies[ipython,matplotlib,sphinx,sphinx-click]; extra == "docs"
36
+ Provides-Extra: interactive
37
+ Requires-Dist: vivarium_dependencies[interactive]; extra == "interactive"
46
38
  Provides-Extra: test
39
+ Requires-Dist: vivarium_dependencies[pytest]; extra == "test"
47
40
  Requires-Dist: vivarium_testing_utils; extra == "test"
48
- Requires-Dist: pytest; extra == "test"
49
- Requires-Dist: pytest-cov; extra == "test"
50
- Requires-Dist: pytest-mock; extra == "test"
51
41
  Requires-Dist: hypothesis; extra == "test"
52
42
  Requires-Dist: pyyaml; extra == "test"
53
43
  Provides-Extra: dev
54
- Requires-Dist: sphinx<7.0; extra == "dev"
55
- Requires-Dist: sphinx-rtd-theme; extra == "dev"
56
- Requires-Dist: sphinx-click; extra == "dev"
57
- Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
58
- Requires-Dist: IPython; extra == "dev"
59
- Requires-Dist: matplotlib; extra == "dev"
44
+ Requires-Dist: vivarium_dependencies[ipython,matplotlib,sphinx,sphinx-click]; extra == "dev"
45
+ Requires-Dist: vivarium_dependencies[interactive]; extra == "dev"
46
+ Requires-Dist: vivarium_dependencies[pytest]; extra == "dev"
60
47
  Requires-Dist: vivarium_testing_utils; extra == "dev"
61
- Requires-Dist: pytest; extra == "dev"
62
- Requires-Dist: pytest-cov; extra == "dev"
63
- Requires-Dist: pytest-mock; extra == "dev"
64
48
  Requires-Dist: hypothesis; extra == "dev"
65
49
  Requires-Dist: pyyaml; extra == "dev"
66
- Requires-Dist: black==22.3.0; extra == "dev"
67
- Requires-Dist: isort==5.13.2; extra == "dev"
50
+ Requires-Dist: vivarium_dependencies[lint]; extra == "dev"
68
51
  Dynamic: author
69
52
  Dynamic: author-email
70
53
  Dynamic: classifier
@@ -1,6 +1,6 @@
1
1
  vivarium_public_health/__about__.py,sha256=RgWycPypKZS80TpSX7o41cREnG8PfguNHDHLuLyl820,487
2
2
  vivarium_public_health/__init__.py,sha256=GDeeP-7OlCBwPuv_xQoB1wNmvCaFsqfTB7qnnYApm0w,1343
3
- vivarium_public_health/_version.py,sha256=215K0AQu12pX2_elDj3eHwDGWbBrLpNequvlrMryST8,22
3
+ vivarium_public_health/_version.py,sha256=bXuOm7EMaj1zGwMTlGgJNLOisp5gk6scG4bpGO0RNd8,22
4
4
  vivarium_public_health/utilities.py,sha256=QNXQ6fhAr1HcV-GwKw7wQLz6QyuNxqNvMA-XujKjTgs,3035
5
5
  vivarium_public_health/disease/__init__.py,sha256=VUJHDLlE6ngo2qHNQUtZ8OWH5H_T7_ao-xsYKDkRmHw,443
6
6
  vivarium_public_health/disease/exceptions.py,sha256=vb30IIV82OiDf2cNZCs_E2rF6mdDDHbnZSND60no5CU,97
@@ -20,7 +20,7 @@ vivarium_public_health/plugins/__init__.py,sha256=oBW_zfgG_LbwfgTDjUe0btfy9FaDvA
20
20
  vivarium_public_health/plugins/parser.py,sha256=WoUisq0d-PfJtSzKYZ6C-s-fYdQpNiRBE14vKaYE27Y,32921
21
21
  vivarium_public_health/population/__init__.py,sha256=x_9rB93q64Krw-kbBDI1-_U_JsPO1_QrL03AwiFlwXI,243
22
22
  vivarium_public_health/population/add_new_birth_cohorts.py,sha256=x6A60GE_F3I8AgLABNJ-2ziiUj52lAd66uX5yc2vIDI,9038
23
- vivarium_public_health/population/base_population.py,sha256=Wu797AL13KRLhXkYni_XocJBLfhfvCVgGeas08U3tCM,18898
23
+ vivarium_public_health/population/base_population.py,sha256=XwfIfJRIcJsxphK62nVPZbrcAw0_7dhxGVuPEnGw3R0,20550
24
24
  vivarium_public_health/population/data_transformations.py,sha256=YHbwfb40EPbXsPW-Rk1s5d61rP8fqgDtMELB7OJG3mo,22662
25
25
  vivarium_public_health/population/mortality.py,sha256=Mtv45FENNY0GlPIoVd3d3pRq01aEh4cjzNXIgEe6hMo,10364
26
26
  vivarium_public_health/results/__init__.py,sha256=rKUZGlRXJgEyFY4a_WJeg3XnC0l34S5guYZ0N9JJS4E,319
@@ -43,8 +43,8 @@ vivarium_public_health/treatment/__init__.py,sha256=wONElu9aJbBYwpYIovYPYaN_GYfV
43
43
  vivarium_public_health/treatment/magic_wand.py,sha256=zg4I48G-l9fC6-qjvApbM1zNACJimZlX9ZZ9fdHKwvc,1985
44
44
  vivarium_public_health/treatment/scale_up.py,sha256=_bsf9c_yVc7-q_-yBcXimISTUfYzPps1auH0uEf7sfQ,7048
45
45
  vivarium_public_health/treatment/therapeutic_inertia.py,sha256=ZIHnpuszZwA_BkS53JbSLvpcnX_bqG2knwCUyUgkA9M,2362
46
- vivarium_public_health-4.3.4.dist-info/licenses/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
47
- vivarium_public_health-4.3.4.dist-info/METADATA,sha256=nNlKCkVxNAu6ftFCGJ_-6o_4TRXBCeQ7nbGfEWgUd1E,4287
48
- vivarium_public_health-4.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
- vivarium_public_health-4.3.4.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
50
- vivarium_public_health-4.3.4.dist-info/RECORD,,
46
+ vivarium_public_health-4.3.6.dist-info/licenses/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
47
+ vivarium_public_health-4.3.6.dist-info/METADATA,sha256=YdB1JSLxInm6y2_uIOnjiG8tqavEJQiOBsQaxn9tqgA,3877
48
+ vivarium_public_health-4.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ vivarium_public_health-4.3.6.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
50
+ vivarium_public_health-4.3.6.dist-info/RECORD,,