|
11 | 11 | from chainladder.utils.sparse import sp |
12 | 12 | from chainladder.core.slice import VirtualColumns |
13 | 13 | from chainladder.core.correlation import DevelopmentCorrelation, ValuationCorrelation |
14 | | -from chainladder.utils.utility_functions import concat, num_to_nan, num_to_value |
| 14 | +from chainladder.utils.utility_functions import concat, num_to_nan, num_to_value, to_period |
15 | 15 | from chainladder import options |
16 | 16 |
|
17 | 17 | try: |
@@ -194,16 +194,12 @@ def __init__( |
194 | 194 |
|
195 | 195 | # Ensure that origin_date values represent the beginning of the period. |
196 | 196 | # i.e., 1990 means the start of 1990. |
197 | | - origin_date: Series = origin_date.dt.to_period( |
198 | | - self.origin_grain |
199 | | - ).dt.to_timestamp(how="s") |
200 | | - |
| 197 | + origin_date: Series = to_period(origin_date,self.origin_grain).dt.to_timestamp(how="s") |
| 198 | + |
201 | 199 | # Ensure that development_date values represent the end of the period. |
202 | 200 | # i.e., 1990 means the end of 1990 assuming annual development periods. |
203 | | - development_date: Series = development_date.dt.to_period( |
204 | | - self.development_grain |
205 | | - ).dt.to_timestamp(how="e") |
206 | | - |
| 201 | + development_date: Series = to_period(development_date,self.development_grain).dt.to_timestamp(how="e") |
| 202 | + |
207 | 203 | # Aggregate dates to the origin/development grains. |
208 | 204 | data_agg: DataFrame = self._aggregate_data( |
209 | 205 | data=data, |
@@ -239,7 +235,7 @@ def __init__( |
239 | 235 | self.vdims = np.array(columns) |
240 | 236 | self.odims, orig_idx = self._set_odims(data_agg, date_axes) |
241 | 237 | self.ddims, dev_idx = self._set_ddims(data_agg, date_axes) |
242 | | - |
| 238 | + |
243 | 239 | # Set remaining triangle properties. |
244 | 240 | val_date: Timestamp = data_agg["__development__"].max() |
245 | 241 | val_date = val_date.compute() if hasattr(val_date, "compute") else val_date |
|
0 commit comments