File tree Expand file tree Collapse file tree 1 file changed +61
-7
lines changed
chainladder/development/tests Expand file tree Collapse file tree 1 file changed +61
-7
lines changed Original file line number Diff line number Diff line change 11import numpy as np
22import chainladder as cl
3+ import pytest
34
45
56def test_full_slice ():
@@ -278,14 +279,67 @@ def test_new_drop_8():
278279def test_new_drop_9 ():
279280 tri = cl .load_sample ("prism" )["Paid" ].sum ().grain ("OYDQ" )
280281
282+ lhs = cl .Development (drop_high = True ).fit (tri ).cdf_ .to_frame ().fillna (0 ).values
283+ rhs = cl .Development (drop_high = 1 ).fit (tri ).cdf_ .to_frame ().fillna (0 ).values
284+ assert (lhs == rhs ).all ()
285+
286+
287+ @pytest .mark .xfail
288+ def test_new_drop_10 ():
289+ data = {
290+ "valuation" : [
291+ 1981 ,
292+ 1982 ,
293+ 1983 ,
294+ 1984 ,
295+ 1985 ,
296+ 1982 ,
297+ 1983 ,
298+ 1984 ,
299+ 1985 ,
300+ ],
301+ "origin" : [
302+ 1981 ,
303+ 1982 ,
304+ 1983 ,
305+ 1984 ,
306+ 1985 ,
307+ 1981 ,
308+ 1982 ,
309+ 1983 ,
310+ 1984 ,
311+ ],
312+ "values" : [
313+ 100 ,
314+ 200 ,
315+ 300 ,
316+ 400 ,
317+ 500 ,
318+ 200 ,
319+ 200 ,
320+ 300 ,
321+ 800 ,
322+ ],
323+ }
324+
325+ tri = cl .Triangle (
326+ pd .DataFrame (data ),
327+ origin = "origin" ,
328+ development = "valuation" ,
329+ columns = ["values" ],
330+ cumulative = True ,
331+ )
332+
333+ assert np .round (
334+ cl .Development (drop_high = 1 ).fit (tri ).cdf_ .to_frame ().values .flatten ()[0 ], 4
335+ ) == (200 + 300 + 800 ) / (200 + 300 + 400 )
336+
281337 assert (
282- cl .Development (drop_high = True ).fit (tri ).cdf_ .to_frame ().fillna (0 ).values
283- == cl .Development (drop_high = 1 ).fit (tri ).cdf_ .to_frame ().fillna (0 ).values
284- ).all ()
285- assert (
286- cl .Development (drop_high = True ).fit (tri ).cdf_ .to_frame ().fillna (0 ).values
287- >= cl .Development (drop_high = 2 ).fit (tri ).cdf_ .to_frame ().fillna (0 ).values
288- ).all ()
338+ np .round (
339+ cl .Development (drop_high = 2 ).fit (tri ).cdf_ .to_frame ().values .flatten ()[0 ], 4
340+ )
341+ == 1.0000
342+ )
289343
290344
291345def compare_new_drop (dev , tri ):
You can’t perform that action at this time.
0 commit comments