vivarium-public-health 4.0.1__py3-none-any.whl → 4.1.0__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.0.1"
1
+ __version__ = "4.1.0"
@@ -14,14 +14,16 @@ from functools import partial
14
14
  from typing import Any
15
15
 
16
16
  import pandas as pd
17
+ from layered_config_tree import ConfigurationError
17
18
  from vivarium.framework.engine import Builder
19
+ from vivarium.framework.event import Event
18
20
  from vivarium.framework.population import SimulantData
19
21
  from vivarium.framework.state_machine import Machine
20
22
  from vivarium.types import DataInput, LookupTableData
21
23
 
22
24
  from vivarium_public_health.disease.exceptions import DiseaseModelError
23
25
  from vivarium_public_health.disease.state import BaseDiseaseState, SusceptibleState
24
- from vivarium_public_health.disease.transition import TransitionString
26
+ from vivarium_public_health.disease.transition import RateTransition, TransitionString
25
27
 
26
28
 
27
29
  class DiseaseModel(Machine):
@@ -118,6 +120,18 @@ class DiseaseModel(Machine):
118
120
  required_resources=["age", "sex"],
119
121
  )
120
122
 
123
+ def on_post_setup(self, event: Event) -> None:
124
+ conversion_types = set()
125
+ for state in self.states:
126
+ for transition in state.transition_set.transitions:
127
+ if isinstance(transition, RateTransition):
128
+ conversion_types.add(transition.rate_conversion_type)
129
+ if len(conversion_types) > 1:
130
+ raise ConfigurationError(
131
+ "All transitions in a disease model must have the same rate conversion type."
132
+ f" Found: {conversion_types}."
133
+ )
134
+
121
135
  def on_initialize_simulants(self, pop_data: SimulantData) -> None:
122
136
  """Initialize the simulants in the population.
123
137
 
@@ -48,6 +48,7 @@ class RateTransition(Transition):
48
48
  "data_sources": {
49
49
  "transition_rate": self._rate_source,
50
50
  },
51
+ "rate_conversion_type": "linear",
51
52
  },
52
53
  }
53
54
 
@@ -143,6 +144,7 @@ class RateTransition(Transition):
143
144
  component=self,
144
145
  required_resources=lookup_columns + ["alive", self.joint_paf],
145
146
  )
147
+ self.rate_conversion_type = self.configuration["rate_conversion_type"]
146
148
 
147
149
  #################
148
150
  # Setup methods #
@@ -184,7 +186,12 @@ class RateTransition(Transition):
184
186
  ##################
185
187
 
186
188
  def _probability(self, index: pd.Index) -> pd.Series:
187
- return pd.Series(rate_to_probability(self.transition_rate(index)))
189
+ return pd.Series(
190
+ rate_to_probability(
191
+ self.transition_rate(index),
192
+ rate_conversion_type=self.rate_conversion_type,
193
+ )
194
+ )
188
195
 
189
196
 
190
197
  class ProportionTransition(Transition):
@@ -561,22 +561,24 @@ def get_live_births_per_year(builder):
561
561
 
562
562
 
563
563
  def rescale_final_age_bin(builder, population_data):
564
- exit_age = builder.configuration.population.to_dict().get("exit_age", None)
565
- if exit_age:
566
- population_data = population_data.loc[population_data["age_start"] < exit_age].copy()
567
- cut_bin_idx = exit_age <= population_data["age_end"]
564
+ untracking_age = builder.configuration.population.to_dict().get("untracking_age", None)
565
+ if untracking_age:
566
+ population_data = population_data.loc[
567
+ population_data["age_start"] < untracking_age
568
+ ].copy()
569
+ cut_bin_idx = untracking_age <= population_data["age_end"]
568
570
  cut_age_start = population_data.loc[cut_bin_idx, "age_start"]
569
571
  cut_age_end = population_data.loc[cut_bin_idx, "age_end"]
570
- population_data.loc[cut_bin_idx, "value"] *= (exit_age - cut_age_start) / (
572
+ population_data.loc[cut_bin_idx, "value"] *= (untracking_age - cut_age_start) / (
571
573
  cut_age_end - cut_age_start
572
574
  )
573
- population_data.loc[cut_bin_idx, "age_end"] = exit_age
575
+ population_data.loc[cut_bin_idx, "age_end"] = untracking_age
574
576
  return population_data
575
577
 
576
578
 
577
579
  def validate_crude_birth_rate_data(builder, data_year_max):
578
- exit_age = builder.configuration.population.to_dict().get("exit_age", None)
579
- if exit_age and builder.configuration.population.age_end != exit_age:
580
+ untracking_age = builder.configuration.population.to_dict().get("untracking_age", None)
581
+ if untracking_age and builder.configuration.population.age_end != untracking_age:
580
582
  raise ValueError(
581
583
  "If you specify an exit age, the initial population age end must be the same "
582
584
  "for the crude birth rate calculation to work."
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vivarium_public_health
3
- Version: 4.0.1
3
+ Version: 4.1.0
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,7 +26,7 @@ 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>=3.2.3
29
+ Requires-Dist: vivarium>=3.4.0
30
30
  Requires-Dist: layered_config_tree>=1.0.1
31
31
  Requires-Dist: loguru
32
32
  Requires-Dist: numpy<2.0.0
@@ -1,14 +1,14 @@
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=v4mcX8QEz7plObRyvTdDblE04TUjya-nJkDSAikxv9Y,22
3
+ vivarium_public_health/_version.py,sha256=jegJMYuSW90VKiMotVdNAakBvYVPirm-A5oeyJVuhH8,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
7
- vivarium_public_health/disease/model.py,sha256=RyvQ2I4dF6IMUcCL7IEsGccc3qu9V6o30gcYrb38GoU,9205
7
+ vivarium_public_health/disease/model.py,sha256=hCJ3_AVzw1JSIYGGXJqQ2r5o-f3XrPcNQ4rwwm_7jO4,9862
8
8
  vivarium_public_health/disease/models.py,sha256=01UK7yB2zGPFzmlIpvhd-XnGe6vSCMDza3QTidgY7Nc,3479
9
9
  vivarium_public_health/disease/special_disease.py,sha256=4tGfnXSVuNYsA7izX9y81ByJe46c4h293szVt7AyPMA,14605
10
10
  vivarium_public_health/disease/state.py,sha256=ptcNETOo8a0NRXOdUhZMgCJa2h3Pt5ZElhMOKonkD4c,28560
11
- vivarium_public_health/disease/transition.py,sha256=jwtg0m03zoFiuwFE-WQFXR1F_E-ridsZ7Og_i-J2Q4E,8963
11
+ vivarium_public_health/disease/transition.py,sha256=HPvv1l322XiQcNXIgDTt3WvytxSbuz_2jyPj-spQE3Y,9209
12
12
  vivarium_public_health/mslt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  vivarium_public_health/mslt/delay.py,sha256=_neQ8oL2IhCqH0hiM4Od4Eb8NfYjyjSoniq02PFieTw,22872
14
14
  vivarium_public_health/mslt/disease.py,sha256=Kwy7cDqiE9yYCsLV_7pAP7ZOe7GWVHUBe39a-GOInVU,16867
@@ -21,7 +21,7 @@ vivarium_public_health/plugins/parser.py,sha256=WoUisq0d-PfJtSzKYZ6C-s-fYdQpNiRB
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
23
  vivarium_public_health/population/base_population.py,sha256=kBE0WVSV0aElTJNBmOBqowZlsjhDfnFn2IzNxb3X8CA,18909
24
- vivarium_public_health/population/data_transformations.py,sha256=yxuZuKZt-s8X6XPULbKWXn2w3kAmNLHYvGQ4sWBKlpc,22216
24
+ vivarium_public_health/population/data_transformations.py,sha256=CEID0uLIJc0xXijlHwnC9Kt8vJMKiIkJtUYcLQbbRRY,22304
25
25
  vivarium_public_health/population/mortality.py,sha256=Mtv45FENNY0GlPIoVd3d3pRq01aEh4cjzNXIgEe6hMo,10364
26
26
  vivarium_public_health/results/__init__.py,sha256=rKUZGlRXJgEyFY4a_WJeg3XnC0l34S5guYZ0N9JJS4E,319
27
27
  vivarium_public_health/results/columns.py,sha256=V-L3JgTcsk51Zx9PcUwSgaE1iZjuGyfZ8aShPjynadU,495
@@ -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.0.1.dist-info/licenses/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
47
- vivarium_public_health-4.0.1.dist-info/METADATA,sha256=ae5FCmlmfFavN9AVHCL8oZnd8ofEG1wf8puuHDvNUbc,4237
48
- vivarium_public_health-4.0.1.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
49
- vivarium_public_health-4.0.1.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
50
- vivarium_public_health-4.0.1.dist-info/RECORD,,
46
+ vivarium_public_health-4.1.0.dist-info/licenses/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
47
+ vivarium_public_health-4.1.0.dist-info/METADATA,sha256=PHv-B0x7CeotS3pLGNU-qNqqdMvKeO25QYLQG2xSUZ0,4237
48
+ vivarium_public_health-4.1.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
49
+ vivarium_public_health-4.1.0.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
50
+ vivarium_public_health-4.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (77.0.3)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5