vivarium-public-health 4.3.6__py3-none-any.whl → 4.3.8__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.
- vivarium_public_health/_version.py +1 -1
- vivarium_public_health/population/base_population.py +38 -10
- {vivarium_public_health-4.3.6.dist-info → vivarium_public_health-4.3.8.dist-info}/METADATA +2 -2
- {vivarium_public_health-4.3.6.dist-info → vivarium_public_health-4.3.8.dist-info}/RECORD +7 -7
- {vivarium_public_health-4.3.6.dist-info → vivarium_public_health-4.3.8.dist-info}/WHEEL +0 -0
- {vivarium_public_health-4.3.6.dist-info → vivarium_public_health-4.3.8.dist-info}/licenses/LICENSE.txt +0 -0
- {vivarium_public_health-4.3.6.dist-info → vivarium_public_health-4.3.8.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
__version__ = "4.3.
|
1
|
+
__version__ = "4.3.8"
|
@@ -166,7 +166,7 @@ class BasePopulation(Component):
|
|
166
166
|
demographic_proportions, year: int
|
167
167
|
) -> pd.DataFrame:
|
168
168
|
reference_years = sorted(set(demographic_proportions.year_start))
|
169
|
-
ref_year_index =
|
169
|
+
ref_year_index = _find_bin_start_index(year, reference_years)
|
170
170
|
return demographic_proportions[
|
171
171
|
demographic_proportions.year_start == reference_years[ref_year_index]
|
172
172
|
]
|
@@ -257,22 +257,22 @@ class ScaledPopulation(BasePopulation):
|
|
257
257
|
if "year_start" not in scaling_factor.index.names:
|
258
258
|
return population_structure, scaling_factor
|
259
259
|
|
260
|
-
# Subset
|
260
|
+
# Subset the population structure and scaling factors to the simulation
|
261
|
+
# start year. If the data does not contain the exact simulation start
|
262
|
+
# year, subset to the closest year less than the simulation start year.
|
261
263
|
pop_reference_years = sorted(
|
262
264
|
set(population_structure.index.get_level_values("year_start"))
|
263
265
|
)
|
264
|
-
pop_year_index =
|
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.
|
266
|
+
pop_year_index = _find_bin_start_index(year, pop_reference_years)
|
272
267
|
population_structure = population_structure.loc[
|
273
268
|
population_structure.index.get_level_values("year_start")
|
274
269
|
== pop_reference_years[pop_year_index]
|
275
270
|
]
|
271
|
+
|
272
|
+
scale_reference_years = sorted(
|
273
|
+
set(scaling_factor.index.get_level_values("year_start"))
|
274
|
+
)
|
275
|
+
scale_year_index = _find_bin_start_index(year, scale_reference_years)
|
276
276
|
scaling_factor = scaling_factor.loc[
|
277
277
|
scaling_factor.index.get_level_values("year_start")
|
278
278
|
== scale_reference_years[scale_year_index]
|
@@ -527,3 +527,31 @@ def _assign_demography_with_age_bounds(
|
|
527
527
|
)
|
528
528
|
register_simulants(simulants[list(key_columns)])
|
529
529
|
return simulants
|
530
|
+
|
531
|
+
|
532
|
+
def _find_bin_start_index(value: int, sorted_reference_values: list[int]) -> int:
|
533
|
+
"""Finds the index of the closest reference value less than or equal to the provided value.
|
534
|
+
|
535
|
+
Parameters
|
536
|
+
----------
|
537
|
+
value
|
538
|
+
The value for which to find the closest reference value.
|
539
|
+
sorted_reference_values
|
540
|
+
A sorted list of reference values.
|
541
|
+
|
542
|
+
Returns
|
543
|
+
-------
|
544
|
+
The index of the closest reference value less than or equal to the provided value.
|
545
|
+
|
546
|
+
Raises
|
547
|
+
------
|
548
|
+
ValueError
|
549
|
+
If the provided value is less than the minimum reference value.
|
550
|
+
"""
|
551
|
+
ref_value_index = np.digitize(value, sorted_reference_values).item() - 1
|
552
|
+
if ref_value_index < 0:
|
553
|
+
raise ValueError(
|
554
|
+
f"The provided value {value} is less than the minimum reference value "
|
555
|
+
f"{min(sorted_reference_values)}."
|
556
|
+
)
|
557
|
+
return ref_value_index
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: vivarium_public_health
|
3
|
-
Version: 4.3.
|
3
|
+
Version: 4.3.8
|
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
|
@@ -28,7 +28,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
28
28
|
License-File: LICENSE.txt
|
29
29
|
Requires-Dist: vivarium_dependencies[loguru,numpy_lt_2,pandas,pyarrow,scipy,tables]
|
30
30
|
Requires-Dist: vivarium_build_utils<3.0.0,>=2.0.1
|
31
|
-
Requires-Dist: vivarium
|
31
|
+
Requires-Dist: vivarium<4.0.0,>=3.4.3
|
32
32
|
Requires-Dist: layered_config_tree
|
33
33
|
Requires-Dist: risk_distributions>=2.0.11
|
34
34
|
Provides-Extra: docs
|
@@ -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=
|
3
|
+
vivarium_public_health/_version.py,sha256=dLqyaaleWhnp4yrZn9zE22wdSuPXoW1FxtYtQhjJgqQ,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=
|
23
|
+
vivarium_public_health/population/base_population.py,sha256=IqQFVZiw-bSDX1MHjwn6pmQYoJksKNwi0OQo_uHZyDM,21399
|
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.
|
47
|
-
vivarium_public_health-4.3.
|
48
|
-
vivarium_public_health-4.3.
|
49
|
-
vivarium_public_health-4.3.
|
50
|
-
vivarium_public_health-4.3.
|
46
|
+
vivarium_public_health-4.3.8.dist-info/licenses/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
|
47
|
+
vivarium_public_health-4.3.8.dist-info/METADATA,sha256=LXpE6AlH6nSHMwBWydYAkSVZzNO8zjQ9DXU-PiVk0ls,3884
|
48
|
+
vivarium_public_health-4.3.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
49
|
+
vivarium_public_health-4.3.8.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
|
50
|
+
vivarium_public_health-4.3.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{vivarium_public_health-4.3.6.dist-info → vivarium_public_health-4.3.8.dist-info}/top_level.txt
RENAMED
File without changes
|