Skip to content

Commit

Permalink
Fixed some tests so that they are easier to read
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethshsu committed May 15, 2024
1 parent 56af72a commit e670e61
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions chainladder/adjustments/tests/test_trend.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
import chainladder as cl
import numpy as np


def test_trend1(clrd):
tri = clrd[['CumPaidLoss', 'EarnedPremDIR']].sum()
assert (
cl.CapeCod(.05).fit(tri['CumPaidLoss'], sample_weight=tri['EarnedPremDIR'].latest_diagonal).ibnr_ ==
cl.CapeCod().fit(cl.Trend(.05).fit_transform(tri['CumPaidLoss']), sample_weight=tri['EarnedPremDIR'].latest_diagonal).ibnr_)
tri = clrd[["CumPaidLoss", "EarnedPremDIR"]].sum()
lhs = (
cl.CapeCod(0.05)
.fit(tri["CumPaidLoss"], sample_weight=tri["EarnedPremDIR"].latest_diagonal)
.ibnr_
)
rhs = (
cl.CapeCod()
.fit(
cl.Trend(0.05).fit_transform(tri["CumPaidLoss"]),
sample_weight=tri["EarnedPremDIR"].latest_diagonal,
)
.ibnr_
)
assert np.round(lhs, 0) == np.round(rhs, 0)


def test_trend2(raa):
tri = raa
assert abs(
cl.Trend(trends=[.05, .05], dates=[(None, '1985'), ('1985', None)], axis='origin').fit(tri).trend_*tri -
tri.trend(.05, axis='origin')).sum().sum() < 1e-6
assert (
abs(
cl.Trend(
trends=[0.05, 0.05],
dates=[(None, "1985"), ("1985", None)],
axis="origin",
)
.fit(tri)
.trend_
* tri
- tri.trend(0.05, axis="origin")
)
.sum()
.sum()
< 1e-6
)

0 comments on commit e670e61

Please sign in to comment.