@@ -49,8 +49,8 @@ class Snapshot:
4949 exposure : Exposures
5050 hazard : Hazard
5151 impfset : ImpactFuncSet
52- date : int | datetime.date | str | pd.Timestamp
53- The date of the Snapshot, it can be an integer representing a year,
52+ date : datetime.date | str | pd.Timestamp
53+ The date of the Snapshot, it can be an string representing a year,
5454 a datetime object or a string representation of a datetime object.
5555 ref_only : bool, default False
5656 Should the `Snapshot` contain deep copies of the Exposures, Hazard and Impfset (False)
@@ -83,7 +83,7 @@ def __init__(
8383 hazard : Hazard ,
8484 impfset : ImpactFuncSet ,
8585 measure : Measure | None ,
86- date : int | datetime .date | str | pd .Timestamp ,
86+ date : datetime .date | str | pd .Timestamp ,
8787 ref_only : bool = False ,
8888 _from_factory : bool = False ,
8989 ) -> None :
@@ -107,7 +107,7 @@ def from_triplet(
107107 exposure : Exposures ,
108108 hazard : Hazard ,
109109 impfset : ImpactFuncSet ,
110- date : int | datetime .date | str | pd .Timestamp ,
110+ date : datetime .date | str | pd .Timestamp ,
111111 ref_only : bool = False ,
112112 ) -> "Snapshot" :
113113 """Create a Snapshot from exposure, hazard and impact functions set
@@ -122,7 +122,7 @@ def from_triplet(
122122 exposure : Exposures
123123 hazard : Hazard
124124 impfset : ImpactFuncSet
125- date : int | datetime.date | str | pd.Timestamp
125+ date : datetime.date | str | pd.Timestamp
126126 ref_only : bool
127127 If true, uses references to the exposure, hazard and impact
128128 function objects. Note that modifying the original objects after
@@ -186,10 +186,7 @@ def impact_calc_data(self) -> dict:
186186
187187 @staticmethod
188188 def _convert_to_timestamp (date_arg ) -> pd .Timestamp :
189- """Convert date argument of type int or str or datetime.date to pandas Timestamp object."""
190- if isinstance (date_arg , int ):
191- # Assume the integer represents a year
192- return pd .Timestamp (year = date_arg , month = 1 , day = 1 )
189+ """Convert date argument of type str or datetime.date to pandas Timestamp object."""
193190 if isinstance (date_arg , str ):
194191 # Try to parse the string as a date
195192 try :
@@ -201,9 +198,7 @@ def _convert_to_timestamp(date_arg) -> pd.Timestamp:
201198 if isinstance (date_arg , pd .Timestamp ):
202199 return date_arg
203200
204- raise TypeError (
205- "date_arg must be an int, str, datetime.date or pandas.Timestamp"
206- )
201+ raise TypeError ("date_arg must be an str, datetime.date or pandas.Timestamp" )
207202
208203 def apply_measure (self , measure : Measure ) -> "Snapshot" :
209204 """Create a new snapshot by applying a Measure object.
0 commit comments