-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed some tests so that they are easier to read
- Loading branch information
1 parent
56af72a
commit e670e61
Showing
1 changed file
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |