@@ -39,6 +39,17 @@ class Snapshot:
3939 """
4040 A snapshot of exposure, hazard, and impact function at a specific date.
4141
42+ Parameters
43+ ----------
44+ exposure : Exposures
45+ hazard : Hazard
46+ impfset : ImpactFuncSet
47+ date : int | datetime.date | str
48+ The date of the Snapshot, it can be an integer representing a year,
49+ a datetime object or a string representation of a datetime object
50+ with format YYYY-MM-DD.
51+
52+
4253 Attributes
4354 ----------
4455 date : datetime
@@ -62,28 +73,11 @@ def __init__(
6273 impfset : ImpactFuncSet ,
6374 date : int | datetime .date | str ,
6475 ) -> None :
65- """Initialise a new `Snapshot`
66-
67- This deepcopies the provided exposure, hazard and impfset, and coerces
68- the given date to a datetime object.
69-
70- Parameters
71- ----------
72- exposure : Exposures
73- hazard : Hazard
74- impfset : ImpactFuncSet
75- date : int | datetime.date | str
76- The date of the Snapshot, it can be an integer representing a year,
77- a datetime object or a string representation of a datetime object
78- with format YYYY-MM-DD.
79-
80- """
81-
8276 self ._exposure = copy .deepcopy (exposure )
8377 self ._hazard = copy .deepcopy (hazard )
8478 self ._impfset = copy .deepcopy (impfset )
85- self .measure = None
86- self .date = self ._convert_to_date (date )
79+ self ._measure = None
80+ self ._date = self ._convert_to_date (date )
8781
8882 @property
8983 def exposure (self ) -> Exposures :
@@ -100,8 +94,19 @@ def impfset(self) -> ImpactFuncSet:
10094 """Impact function set data for the snapshot."""
10195 return self ._impfset
10296
97+ @property
98+ def measure (self ) -> Measure | None :
99+ """Impact function set data for the snapshot."""
100+ return self ._measure
101+
102+ @property
103+ def date (self ) -> datetime .date :
104+ """Impact function set data for the snapshot."""
105+ return self ._date
106+
103107 @staticmethod
104108 def _convert_to_date (date_arg ) -> datetime .date :
109+ """Convert date argument of type int or str to a datetime.date object."""
105110 if isinstance (date_arg , int ):
106111 # Assume the integer represents a year
107112 return datetime .date (date_arg , 1 , 1 )
@@ -135,9 +140,8 @@ def apply_measure(self, measure: Measure) -> "Snapshot":
135140 """
136141
137142 LOGGER .debug (f"Applying measure { measure .name } on snapshot { id (self )} " )
138- exp_new , impfset_new , haz_new = measure . apply (
139- self .exposure , self .impfset , self .hazard
143+ snap = Snapshot (
144+ * measure . apply ( self .exposure , self .impfset , self .hazard ), self . date
140145 )
141- snap = Snapshot (exp_new , haz_new , impfset_new , self .date )
142- snap .measure = measure
146+ snap ._measure = measure
143147 return snap
0 commit comments