vivarium-public-health 4.3.10__py3-none-any.whl → 4.3.11__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.10"
1
+ __version__ = "4.3.11"
@@ -9,6 +9,7 @@ implementation that has been used in several public health models.
9
9
  """
10
10
 
11
11
  import pickle
12
+ import re
12
13
  from collections.abc import Callable
13
14
  from typing import Any
14
15
 
@@ -119,13 +120,12 @@ class LBWSGDistribution(PolytomousDistribution):
119
120
  The intervals for each category.
120
121
  """
121
122
  categories: dict[str, str] = builder.data.load(f"{self.risk}.categories")
122
- category_intervals = {
123
- axis: {
124
- category: self._parse_description(axis, description)
125
- for category, description in categories.items()
126
- }
127
- for axis in [BIRTH_WEIGHT, GESTATIONAL_AGE]
128
- }
123
+ category_intervals = {GESTATIONAL_AGE: {}, BIRTH_WEIGHT: {}}
124
+
125
+ for category, description in categories.items():
126
+ gestation_interval, birth_weight_interval = self._parse_description(description)
127
+ category_intervals[GESTATIONAL_AGE][category] = gestation_interval
128
+ category_intervals[BIRTH_WEIGHT][category] = birth_weight_interval
129
129
  return category_intervals
130
130
 
131
131
  ##################
@@ -224,7 +224,7 @@ class LBWSGDistribution(PolytomousDistribution):
224
224
  ##################
225
225
 
226
226
  @staticmethod
227
- def _parse_description(axis: str, description: str) -> pd.Interval:
227
+ def _parse_description(description: str) -> tuple[pd.Interval, pd.Interval]:
228
228
  """Parses a string corresponding to a low birth weight and short gestation
229
229
  category to an Interval.
230
230
 
@@ -235,17 +235,15 @@ class LBWSGDistribution(PolytomousDistribution):
235
235
  An example of an edge case of birth weight:
236
236
  'Neonatal preterm and LBWSG (estimation years) - [36, 37) wks, [4000, 9999] g'
237
237
  """
238
- endpoints = {
239
- BIRTH_WEIGHT: [
240
- float(val)
241
- for val in description.split(", [")[1].split(")")[0].split("]")[0].split(", ")
242
- ],
243
- GESTATIONAL_AGE: [
244
- float(val)
245
- for val in description.split("- [")[1].split(")")[0].split("+")[0].split(", ")
246
- ],
247
- }[axis]
248
- return pd.Interval(*endpoints, closed="left") # noqa
238
+ lbwsg_values = [float(val) for val in re.findall(r"(\d+)", description)]
239
+ if len(list(lbwsg_values)) != 4:
240
+ raise ValueError(
241
+ f"Could not parse LBWSG description '{description}'. Expected 4 numeric values."
242
+ )
243
+ return (
244
+ pd.Interval(*lbwsg_values[:2], closed="left"), # Gestational Age
245
+ pd.Interval(*lbwsg_values[2:], closed="left"), # Birth Weight
246
+ )
249
247
 
250
248
 
251
249
  class LBWSGRisk(Risk):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vivarium_public_health
3
- Version: 4.3.10
3
+ Version: 4.3.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
@@ -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=aiMsUBqN_yAk_Md8MFAhfNSW7FpgntZQdvctxHDiyMs,23
3
+ vivarium_public_health/_version.py,sha256=FTMATci8OA-tNFnEujq_JNE-wHVYlo4B0glOFoqHJfs,23
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
@@ -38,13 +38,13 @@ vivarium_public_health/risks/data_transformations.py,sha256=SgdPKc95BBqgMNUdlAQM
38
38
  vivarium_public_health/risks/distributions.py,sha256=5gkurGTPqZczIKum5NgJ-DbJ2bxA1tRbLe7jKgCqkQg,18203
39
39
  vivarium_public_health/risks/effect.py,sha256=Cw-V1rMPaAPZsirbUElPzksvNuXLQc8TIIk0hgaFzvA,21259
40
40
  vivarium_public_health/risks/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py,sha256=wKVGHhdIas9WOrgA5wpwkSSDrZwBtaCqkZXfQH6jrkY,21159
41
+ vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py,sha256=0Fhx6vjDPxZeuO_gKVDuJI6Myjsf5e9M2Q9_shsYbzw,21302
42
42
  vivarium_public_health/treatment/__init__.py,sha256=wONElu9aJbBYwpYIovYPYaN_GYfVhPXtTeFWSdQMgA0,222
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.10.dist-info/licenses/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
47
- vivarium_public_health-4.3.10.dist-info/METADATA,sha256=YBpE-toiC10FL68QOeShZOICmQJ5QWPlAttRkqSjNuk,3885
48
- vivarium_public_health-4.3.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
- vivarium_public_health-4.3.10.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
50
- vivarium_public_health-4.3.10.dist-info/RECORD,,
46
+ vivarium_public_health-4.3.11.dist-info/licenses/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
47
+ vivarium_public_health-4.3.11.dist-info/METADATA,sha256=-QvvuE7m66YSkjnBa1GdUrK3bq9U3KlDlGvHxYQ0AvU,3885
48
+ vivarium_public_health-4.3.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ vivarium_public_health-4.3.11.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
50
+ vivarium_public_health-4.3.11.dist-info/RECORD,,