Skip to content

Commit

Permalink
resolves #74 Dropped link ratios exposed in transformed triangle
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bogaardt committed Apr 25, 2020
1 parent 1845098 commit 5208181
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions chainladder/core/triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -544,4 +551,3 @@ def broadcast_axis(self, axis, value):

def copy(self):
return self.iloc[:, :]

0 comments on commit 5208181

Please sign in to comment.