vivarium-public-health 2.0.2__py3-none-any.whl → 2.1.1__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__ = "2.0.2"
1
+ __version__ = "2.1.1"
@@ -11,10 +11,11 @@ from typing import Callable, Dict, List, Optional
11
11
  import numpy as np
12
12
  import pandas as pd
13
13
  from vivarium.framework.engine import Builder
14
- from vivarium.framework.lookup import LookupTableData
14
+ from vivarium.framework.lookup import LookupTable, LookupTableData
15
15
  from vivarium.framework.population import PopulationView, SimulantData
16
+ from vivarium.framework.randomness import RandomnessStream
16
17
  from vivarium.framework.state_machine import State, Transient, Transition, Trigger
17
- from vivarium.framework.values import list_combiner, union_post_processor
18
+ from vivarium.framework.values import Pipeline, list_combiner, union_post_processor
18
19
 
19
20
  from vivarium_public_health.disease.transition import (
20
21
  ProportionTransition,
@@ -323,65 +324,41 @@ class DiseaseState(BaseDiseaseState):
323
324
  self.clock = builder.time.clock()
324
325
 
325
326
  prevalence_data = self.load_prevalence_data(builder)
326
- self.prevalence = builder.lookup.build_table(
327
- prevalence_data, key_columns=["sex"], parameter_columns=["age", "year"]
328
- )
327
+ self.prevalence = self.get_prevalence(builder, prevalence_data)
329
328
 
330
329
  birth_prevalence_data = self.load_birth_prevalence_data(builder)
331
- self.birth_prevalence = builder.lookup.build_table(
332
- birth_prevalence_data, key_columns=["sex"], parameter_columns=["year"]
333
- )
330
+ self.birth_prevalence = self.get_birth_prevalence(builder, birth_prevalence_data)
334
331
 
335
332
  dwell_time_data = self.load_dwell_time_data(builder)
336
- self.dwell_time = builder.value.register_value_producer(
337
- f"{self.state_id}.dwell_time",
338
- source=builder.lookup.build_table(
339
- dwell_time_data, key_columns=["sex"], parameter_columns=["age", "year"]
340
- ),
341
- requires_columns=["age", "sex"],
342
- )
333
+ self.dwell_time = self.get_dwell_time_pipeline(builder, dwell_time_data)
343
334
 
344
335
  disability_weight_data = self.load_disability_weight_data(builder)
345
336
  self.has_disability = is_non_zero(disability_weight_data)
346
- self.base_disability_weight = builder.lookup.build_table(
347
- disability_weight_data, key_columns=["sex"], parameter_columns=["age", "year"]
348
- )
349
- self.disability_weight = builder.value.register_value_producer(
350
- f"{self.state_id}.disability_weight",
351
- source=self.compute_disability_weight,
352
- requires_columns=["age", "sex", "alive", self.model],
337
+ self.base_disability_weight = self.get_base_disability_weight(
338
+ builder, disability_weight_data
353
339
  )
340
+
341
+ self.disability_weight = self.get_disability_weight_pipeline(builder)
342
+
354
343
  builder.value.register_value_modifier(
355
344
  "disability_weight", modifier=self.disability_weight
356
345
  )
357
346
 
358
347
  excess_mortality_data = self.load_excess_mortality_rate_data(builder)
359
348
  self.has_excess_mortality = is_non_zero(excess_mortality_data)
360
- self.base_excess_mortality_rate = builder.lookup.build_table(
361
- excess_mortality_data, key_columns=["sex"], parameter_columns=["age", "year"]
362
- )
363
- self.excess_mortality_rate = builder.value.register_rate_producer(
364
- self.excess_mortality_rate_pipeline_name,
365
- source=self.compute_excess_mortality_rate,
366
- requires_columns=["age", "sex", "alive", self.model],
367
- requires_values=[self.excess_mortality_rate_paf_pipeline_name],
368
- )
369
- paf = builder.lookup.build_table(0)
370
- self.joint_paf = builder.value.register_value_producer(
371
- self.excess_mortality_rate_paf_pipeline_name,
372
- source=lambda idx: [paf(idx)],
373
- preferred_combiner=list_combiner,
374
- preferred_post_processor=union_post_processor,
349
+ self.base_excess_mortality_rate = self.get_base_excess_mortality_rate(
350
+ builder, excess_mortality_data
375
351
  )
352
+ self.excess_mortality_rate = self.get_excess_mortality_rate_pipeline(builder)
353
+ self.joint_paf = self.get_joint_paf(builder)
354
+
376
355
  builder.value.register_value_modifier(
377
356
  "mortality_rate",
378
357
  modifier=self.adjust_mortality_rate,
379
358
  requires_values=[self.excess_mortality_rate_pipeline_name],
380
359
  )
381
360
 
382
- self.randomness_prevalence = builder.randomness.get_stream(
383
- f"{self.state_id}_prevalent_cases"
384
- )
361
+ self.randomness_prevalence = self.get_randomness_prevalence(builder)
385
362
 
386
363
  #################
387
364
  # Setup methods #
@@ -393,12 +370,26 @@ class DiseaseState(BaseDiseaseState):
393
370
  else:
394
371
  return builder.data.load(f"{self.cause_type}.{self.state_id}.prevalence")
395
372
 
373
+ def get_prevalence(
374
+ self, builder: Builder, prevalence_data: LookupTableData
375
+ ) -> LookupTable:
376
+ return builder.lookup.build_table(
377
+ prevalence_data, key_columns=["sex"], parameter_columns=["age", "year"]
378
+ )
379
+
396
380
  def load_birth_prevalence_data(self, builder: Builder) -> LookupTableData:
397
381
  if "birth_prevalence" in self._get_data_functions:
398
382
  return self._get_data_functions["birth_prevalence"](builder, self.state_id)
399
383
  else:
400
384
  return 0
401
385
 
386
+ def get_birth_prevalence(
387
+ self, builder: Builder, birth_prevalence_data: LookupTableData
388
+ ) -> LookupTable:
389
+ return builder.lookup.build_table(
390
+ birth_prevalence_data, key_columns=["sex"], parameter_columns=["year"]
391
+ )
392
+
402
393
  def load_dwell_time_data(self, builder: Builder) -> LookupTableData:
403
394
  if "dwell_time" in self._get_data_functions:
404
395
  dwell_time = self._get_data_functions["dwell_time"](builder, self.state_id)
@@ -414,6 +405,17 @@ class DiseaseState(BaseDiseaseState):
414
405
 
415
406
  return dwell_time
416
407
 
408
+ def get_dwell_time_pipeline(
409
+ self, builder: Builder, dwell_time_data: LookupTableData
410
+ ) -> Pipeline:
411
+ return builder.value.register_value_producer(
412
+ f"{self.state_id}.dwell_time",
413
+ source=builder.lookup.build_table(
414
+ dwell_time_data, key_columns=["sex"], parameter_columns=["age", "year"]
415
+ ),
416
+ requires_columns=["age", "sex"],
417
+ )
418
+
417
419
  def load_disability_weight_data(self, builder: Builder) -> LookupTableData:
418
420
  if "disability_weight" in self._get_data_functions:
419
421
  disability_weight = self._get_data_functions["disability_weight"](
@@ -429,6 +431,20 @@ class DiseaseState(BaseDiseaseState):
429
431
 
430
432
  return disability_weight
431
433
 
434
+ def get_base_disability_weight(
435
+ self, builder: Builder, disability_weight_data: LookupTableData
436
+ ) -> LookupTable:
437
+ return builder.lookup.build_table(
438
+ disability_weight_data, key_columns=["sex"], parameter_columns=["age", "year"]
439
+ )
440
+
441
+ def get_disability_weight_pipeline(self, builder: Builder) -> Pipeline:
442
+ return builder.value.register_value_producer(
443
+ f"{self.state_id}.disability_weight",
444
+ source=self.compute_disability_weight,
445
+ requires_columns=["age", "sex", "alive", self.model],
446
+ )
447
+
432
448
  def load_excess_mortality_rate_data(self, builder: Builder) -> LookupTableData:
433
449
  if "excess_mortality_rate" in self._get_data_functions:
434
450
  return self._get_data_functions["excess_mortality_rate"](builder, self.state_id)
@@ -439,6 +455,33 @@ class DiseaseState(BaseDiseaseState):
439
455
  f"{self.cause_type}.{self.state_id}.excess_mortality_rate"
440
456
  )
441
457
 
458
+ def get_base_excess_mortality_rate(
459
+ self, builder: Builder, excess_mortality_data: LookupTableData
460
+ ) -> LookupTable:
461
+ return builder.lookup.build_table(
462
+ excess_mortality_data, key_columns=["sex"], parameter_columns=["age", "year"]
463
+ )
464
+
465
+ def get_excess_mortality_rate_pipeline(self, builder: Builder) -> Pipeline:
466
+ return builder.value.register_rate_producer(
467
+ self.excess_mortality_rate_pipeline_name,
468
+ source=self.compute_excess_mortality_rate,
469
+ requires_columns=["age", "sex", "alive", self.model],
470
+ requires_values=[self.excess_mortality_rate_paf_pipeline_name],
471
+ )
472
+
473
+ def get_joint_paf(self, builder: Builder) -> Pipeline:
474
+ paf = builder.lookup.build_table(0)
475
+ return builder.value.register_value_producer(
476
+ self.excess_mortality_rate_paf_pipeline_name,
477
+ source=lambda idx: [paf(idx)],
478
+ preferred_combiner=list_combiner,
479
+ preferred_post_processor=union_post_processor,
480
+ )
481
+
482
+ def get_randomness_prevalence(self, builder: Builder) -> RandomnessStream:
483
+ return builder.randomness.get_stream(f"{self.state_id}_prevalent_cases")
484
+
442
485
  ##################
443
486
  # Public methods #
444
487
  ##################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vivarium-public-health
3
- Version: 2.0.2
3
+ Version: 2.1.1
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,12 +1,12 @@
1
1
  vivarium_public_health/__about__.py,sha256=RgWycPypKZS80TpSX7o41cREnG8PfguNHDHLuLyl820,487
2
2
  vivarium_public_health/__init__.py,sha256=tomMOl3PI7O8GdxDWGBiBjT0Bwd31GpyQTYTzwIv108,361
3
- vivarium_public_health/_version.py,sha256=tATvJM5shAzfspHYjdVwpV2w3-gDA119NlEYi5X2lFY,22
3
+ vivarium_public_health/_version.py,sha256=zPJIgPGcoSNiD0qme18OnYJYE3A9VVytlhO-V5DaAW0,22
4
4
  vivarium_public_health/utilities.py,sha256=_X9sZQ7flsi2sVWQ9zrf8GJw8QwZsPZm3NUjx1gu7bM,2555
5
5
  vivarium_public_health/disease/__init__.py,sha256=RuuiRcvAJfX9WQGt_WZZjxN7Cu3E5rMTmuaRS-UaFPM,419
6
6
  vivarium_public_health/disease/model.py,sha256=7xFGo6JqPjQjm2VUZ3u3ThXWSzmitTOCZ8N9PTTL6MU,8253
7
7
  vivarium_public_health/disease/models.py,sha256=uiB2qUlxBsPPPmHJ8Cgot_T1ItZ8RYSNVOBtxtn93Y0,3478
8
8
  vivarium_public_health/disease/special_disease.py,sha256=gl8aK0z6afCxiCZxgJafLe4xmbR91zk3079hsi2pUAw,14751
9
- vivarium_public_health/disease/state.py,sha256=yZ76I4mRHfa-KG2lhCJZpVWkgxip0j6r3AkQD5SpTzg,21165
9
+ vivarium_public_health/disease/state.py,sha256=V_X3DPioZJ3SlR8Rp4o8fkdyeBPmEDDjLYOBq6JOcqA,22778
10
10
  vivarium_public_health/disease/transition.py,sha256=Or5nucRzeGG-UuE_CGkPZ9qE35-Ed9I9LWHj4rjknCc,5334
11
11
  vivarium_public_health/metrics/__init__.py,sha256=bWAvvdCm_7RPIazo12qFohA2x5-_EV6ceV8IhKS37sk,209
12
12
  vivarium_public_health/metrics/disability.py,sha256=zm0vAG00wj44CHjYGdT2_pebgARa3XXIerrR06t80rc,3984
@@ -40,8 +40,8 @@ vivarium_public_health/treatment/__init__.py,sha256=wONElu9aJbBYwpYIovYPYaN_GYfV
40
40
  vivarium_public_health/treatment/magic_wand.py,sha256=iPKFN3VjfiMy_XvN94UqM-FUrGuI0ULwmOdAGdOepYQ,1979
41
41
  vivarium_public_health/treatment/scale_up.py,sha256=zTPMfKG38dGBj14QpBeLlmUixx1y_XIMElmTpkklydA,6714
42
42
  vivarium_public_health/treatment/therapeutic_inertia.py,sha256=VwZ7t90zzfGoBusduIvcE4lDe5zTvzmHiUNB3u2I52Y,2339
43
- vivarium_public_health-2.0.2.dist-info/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
44
- vivarium_public_health-2.0.2.dist-info/METADATA,sha256=nbj5JXxhmRd7lWBWvUFvHz8iInnQEFzy823NmkmSn8M,3430
45
- vivarium_public_health-2.0.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
46
- vivarium_public_health-2.0.2.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
47
- vivarium_public_health-2.0.2.dist-info/RECORD,,
43
+ vivarium_public_health-2.1.1.dist-info/LICENSE.txt,sha256=mN4bNLUQNcN9njYRc_3jCZkfPySVpmM6MRps104FxA4,1548
44
+ vivarium_public_health-2.1.1.dist-info/METADATA,sha256=QrLx-cPWz8E_pgj_6ZG3qO0y5KiywQsqVKSBdviNZ3A,3430
45
+ vivarium_public_health-2.1.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
46
+ vivarium_public_health-2.1.1.dist-info/top_level.txt,sha256=VVInlpzCFD0UNNhjOq_j-a29odzjwUwYFTGfvqbi4dY,23
47
+ vivarium_public_health-2.1.1.dist-info/RECORD,,