From a671e67ccf8fa2961b499aff747c9a002b2fbe50 Mon Sep 17 00:00:00 2001 From: Steve Bachmeier Date: Wed, 28 Aug 2024 14:52:53 -0700 Subject: [PATCH 1/3] Add missing results module docstrings; strengthen SimpleCause docs and rename class method --- CHANGELOG.rst | 6 ++++ .../results/disability.py | 8 ++--- src/vivarium_public_health/results/disease.py | 6 ++-- .../results/mortality.py | 8 ++--- .../results/observer.py | 10 ++++++ .../results/simple_cause.py | 31 +++++++++++++++---- 6 files changed, 52 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c4d81fd7..24000a14 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,9 @@ +**3.0.5 - 08/28/24** + + - Add missing results module-level docstrings + - Strengthen the SimpleCause docstring + - Rename the SimpleCause class method + **3.0.4 - 08/28/24** - Strengthen results docstrings and clean up others throughout diff --git a/src/vivarium_public_health/results/disability.py b/src/vivarium_public_health/results/disability.py index 32099563..67a836d5 100644 --- a/src/vivarium_public_health/results/disability.py +++ b/src/vivarium_public_health/results/disability.py @@ -1,7 +1,7 @@ """ -=================== -Disability Observer -=================== +==================== +Disability Observers +==================== This module contains tools for observing years lived with disability (YLDs) in the simulation. @@ -102,7 +102,7 @@ def set_causes_of_disability(self, builder: Builder) -> None: ) # Convert to SimpleCause instances and add on all_causes causes_of_disability = [ - SimpleCause.create_from_disease_state(cause) for cause in causes_of_disability + SimpleCause.create_from_specific_cause(cause) for cause in causes_of_disability ] + [SimpleCause("all_causes", "all_causes", "cause")] excluded_causes = ( diff --git a/src/vivarium_public_health/results/disease.py b/src/vivarium_public_health/results/disease.py index d6cbd4d6..df61ef4f 100644 --- a/src/vivarium_public_health/results/disease.py +++ b/src/vivarium_public_health/results/disease.py @@ -1,7 +1,7 @@ """ -================ -Disease Observer -================ +================= +Disease Observers +================= This module contains tools for observing disease incidence and prevalence in the simulation. diff --git a/src/vivarium_public_health/results/mortality.py b/src/vivarium_public_health/results/mortality.py index fc11c7f3..051ac391 100644 --- a/src/vivarium_public_health/results/mortality.py +++ b/src/vivarium_public_health/results/mortality.py @@ -1,7 +1,7 @@ """ -================== -Mortality Observer -================== +=================== +Mortality Observers +=================== This module contains tools for observing cause-specific and excess mortality in the simulation, including "other causes". @@ -130,7 +130,7 @@ def set_causes_of_death(self, builder: Builder) -> None: # Convert to SimpleCauses and add on other_causes and not_dead self.causes_of_death = [ - SimpleCause.create_from_disease_state(cause) for cause in causes_of_death + SimpleCause.create_from_specific_cause(cause) for cause in causes_of_death ] + [ SimpleCause("not_dead", "not_dead", "cause"), SimpleCause("other_causes", "other_causes", "cause"), diff --git a/src/vivarium_public_health/results/observer.py b/src/vivarium_public_health/results/observer.py index 977874b7..f3e87dfc 100644 --- a/src/vivarium_public_health/results/observer.py +++ b/src/vivarium_public_health/results/observer.py @@ -1,3 +1,13 @@ +""" +=============== +Basic Observers +=============== + +This module contains convencience classes for building concrete observers in +public health models. + +""" + from typing import Callable, List, Optional, Union import pandas as pd diff --git a/src/vivarium_public_health/results/simple_cause.py b/src/vivarium_public_health/results/simple_cause.py index 304af3e0..a4af09cd 100644 --- a/src/vivarium_public_health/results/simple_cause.py +++ b/src/vivarium_public_health/results/simple_cause.py @@ -1,12 +1,21 @@ +""" +============ +Simple Cause +============ + +This module contains tools for creating a minimal representation of a cause +as required by observers. + +""" + from dataclasses import dataclass @dataclass class SimpleCause: - """A simple dataclass to represent the bare minimum information needed - for observers, e.g. 'all_causes' as a cause of disability. + """A simple dataclass to represent the bare minimum information needed by observers. - It also includes a class method to convert a provided disease state into a + It also includes a class method to convert a provided cause into a ``SimpleCause`` instance. """ @@ -19,6 +28,16 @@ class SimpleCause: """The cause type of the cause.""" @classmethod - def create_from_disease_state(cls, disease_state: type) -> "SimpleCause": - """Create a SimpleCause instance from a""" - return cls(disease_state.state_id, disease_state.model, disease_state.cause_type) + def create_from_specific_cause(cls, cause: type) -> "SimpleCause": + """Create a SimpleCause instance from a more specific cause. + + Parameters + ---------- + cause + The cause to be converted into a SimpleCause instance. + + Returns + ------- + A SimpleCause instance. + """ + return cls(cause.state_id, cause.model, cause.cause_type) From 40756b104bf7aa2ee77ea0675472b10c2a29f160 Mon Sep 17 00:00:00 2001 From: Steve Bachmeier <23350991+stevebachmeier@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:33:26 -0600 Subject: [PATCH 2/3] Update CHANGELOG.rst --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 24000a14..23e67d0c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,4 +1,4 @@ -**3.0.5 - 08/28/24** +**3.0.5 - 08/29/24** - Add missing results module-level docstrings - Strengthen the SimpleCause docstring From b518e692939802970a3f9f6ac92b5fd3bfa3bd6b Mon Sep 17 00:00:00 2001 From: Steve Bachmeier <23350991+stevebachmeier@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:02:23 -0600 Subject: [PATCH 3/3] Update src/vivarium_public_health/results/observer.py Co-authored-by: Rajan Mudambi <11376379+rmudambi@users.noreply.github.com> --- src/vivarium_public_health/results/observer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vivarium_public_health/results/observer.py b/src/vivarium_public_health/results/observer.py index f3e87dfc..a1d894c0 100644 --- a/src/vivarium_public_health/results/observer.py +++ b/src/vivarium_public_health/results/observer.py @@ -3,7 +3,7 @@ Basic Observers =============== -This module contains convencience classes for building concrete observers in +This module contains convenience classes for building concrete observers in public health models. """