diff --git a/chainladder/core/triangle.py b/chainladder/core/triangle.py index 2bb4be42..7f884e29 100644 --- a/chainladder/core/triangle.py +++ b/chainladder/core/triangle.py @@ -160,6 +160,8 @@ def latest_diagonal(self): def link_ratio(self): xp = cp.get_array_module(self.values) obj = copy.deepcopy(self) + if hasattr(obj, '_nan_triangle_'): + del obj._nan_triangle_ temp = obj.values.copy() temp[temp == 0] = np.nan val_array = obj.valuation.values.reshape( @@ -174,6 +176,8 @@ def link_ratio(self): val_array = val_array[:-1, :] obj.valuation = pd.DatetimeIndex( pd.DataFrame(val_array).unstack().values).to_period(self._lowest_grain()) + if hasattr(obj, 'w_'): + obj = obj*obj.w_[..., :len(obj.odims), :] return obj @property @@ -384,7 +388,7 @@ def _val_dev_chg(self, kind): return obj - def grain(self, grain='', inplace=False): + def grain(self, grain='', trailing=False, inplace=False): """Changes the grain of a cumulative triangle. Parameters @@ -397,6 +401,9 @@ def grain(self, grain='', inplace=False): incremental : bool Grain does not work on incremental triangles and this argument let's the function know to make it cumuative before operating on the grain. + trailing : bool + For partial years/quarters, trailing will set the year/quarter end to + that of the latest available form the data. inplace : bool Whether to mutate the existing Triangle instance or return a new one. @@ -544,4 +551,3 @@ def broadcast_axis(self, axis, value): def copy(self): return self.iloc[:, :] -