forked from casact/chainladder-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_chainladder.py
424 lines (377 loc) · 21.1 KB
/
test_chainladder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 19 17:58:03 2017
@author: jboga
"""
import chainladder as cl
import pytest
import os.path
from rpy2.robjects.packages import importr
from rpy2.robjects import pandas2ri, r
pandas2ri.activate()
import numpy as np
CL =importr('ChainLadder')
d = r('data(package=\"ChainLadder\")')
@pytest.mark.parametrize('df',[cl.load_dataset(item) for item in os.listdir(os.path.join(os.path.dirname(os.path.abspath(__file__)),'chainladder','data'))])
def test_data_as_table(df):
a = cl.Triangle(df)
if a.dataform == 'tabular':
assert True
else:
data1 = a.data
a.data_as_table(inplace=True)
a.data_as_triangle(inplace=True)
test = ((data1 == a.data) | ((data1 != data1) & (a.data != a.data))).as_matrix()
assert test.shape[0]*test.shape[1] == sum(sum(test))
@pytest.mark.parametrize('df',[cl.load_dataset(item) for item in os.listdir(os.path.join(os.path.dirname(os.path.abspath(__file__)),'chainladder','data'))])
def test_cum_to_incr_convert(df):
a = cl.Triangle(df)
data1 = a.data
a.cum_to_incr(inplace=True)
a.incr_to_cum(inplace=True)
test = ((data1 == a.data) | ((data1 != data1) & (a.data != a.data))).as_matrix()
assert test.shape[0]*test.shape[1] == sum(sum(test))
@pytest.mark.parametrize('df',[cl.load_dataset(item) for item in os.listdir(os.path.join(os.path.dirname(os.path.abspath(__file__)),'chainladder','data'))])
def test_incr_to_cum_convert(df):
a = cl.Triangle(df)
data1 = a.data
a.incr_to_cum(inplace=True)
a.cum_to_incr(inplace=True)
test = ((data1 == a.data) | ((data1 != data1) & (a.data != a.data))).as_matrix()
assert test.shape[0]*test.shape[1] == sum(sum(test))
l1 = [cl.load_dataset(item) for item in os.listdir(os.path.join(os.path.dirname(os.path.abspath(__file__)),'chainladder','data'))]
l2 = [item for item in os.listdir(os.path.join(os.path.dirname(os.path.abspath(__file__)),'chainladder','data'))]
l3 = list(zip(l1,l2))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_f(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=2).f
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=2)')[4])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_fse(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=2).fse[:-1]
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=2)')[5])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_Fse(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=2).Fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=2)')[6])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_process_risk(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=2).process_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=2)')[8])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_parameter_risk(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=2).parameter_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=2)')[9])
assert np.all(np.array(python).round(5)==r_lang.round(5))
############## alpha = 1
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_f_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=1).f
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=1)')[4])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_fse_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=1).fse[:-1]
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=1)')[5])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_Fse_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=1).Fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=1)')[6])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_process_risk_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=1).process_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=1)')[8])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_parameter_risk_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=1).parameter_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=1)')[9])
assert np.all(np.array(python).round(5)==r_lang.round(5))
############## Alpha = 0
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_f_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=0).f
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=0)')[4])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_fse_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=0).fse[:-1]
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=0)')[5])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_Fse_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=0).Fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=0)')[6])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_process_risk_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=0).process_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=0)')[8])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_parameter_risk_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data),alpha=0).parameter_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ',alpha=0)')[9])
assert np.all(np.array(python).round(5)==r_lang.round(5))
def test_MunichChainladder_1():
python = cl.MunichChainladder(cl.load_dataset('MCLpaid'), cl.load_dataset('MCLincurred'))
r_lang = np.array(r('a<-MunichChainLadder(MCLpaid,MCLincurred)'))
assert np.all((round(python.lambdaI,5)==round(np.array(r_lang[12][0])[0],5)) and
(round(python.lambdaP,5)==round(np.array(r_lang[11][0])[0],5)) and
(python.q_f.round(5) == np.array(r_lang[15]).round(5)))
################# Try with exponential tail
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_f(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong','auto$PersonalAutoIncurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=2).f
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=2)')[4])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_fse(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=2)
if python.chainladder.tail == False:
python = python.fse[:-1]
else:
python = python.fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=2)')[5])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_Fse(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=2).Fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=2)')[6])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_process_risk(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=2).process_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=2)')[8])
if r_data == 'GenIns':
i = 3 # GenIns rounding is so close to 5, that it fails
elif r_data in ['liab$AutoLiab','Mortgage']:
i = 4
else: i= 5
assert np.all(np.array(python).round(i)==r_lang.round(i))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_parameter_risk(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=2).parameter_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=2)')[9])
assert np.all(np.array(python).round(5)==r_lang.round(5))
############## alpha = 1
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_f_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred', 'MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=1).f
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=1)')[4])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_fse_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=1)
if python.chainladder.tail == False:
python = python.fse[:-1]
else:
python = python.fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=1)')[5])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_Fse_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=1).Fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=1)')[6])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_process_risk_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=1).process_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=1)')[8])
if r_data == 'GenIns':
i = 3 # GenIns rounding is so close to 5, that it fails
elif r_data in ['liab$AutoLiab','Mortgage']:
i = 4
else: i= 5
assert np.all(np.array(python).round(i)==r_lang.round(i))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_parameter_risk_a1(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=1).parameter_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=1)')[9])
assert np.all(np.array(python).round(5)==r_lang.round(5))
############## Alpha = 0
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_f_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=0).f
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=0)')[4])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_fse_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=0)
if python.chainladder.tail == False:
python = python.fse[:-1]
else:
python = python.fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=0)')[5])
assert np.all(r_lang.round(5)==python.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_Fse_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=0).Fse
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=0)')[6])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_process_risk_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=0).process_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=0)')[8])
assert np.all(np.array(python).round(5)==r_lang.round(5))
@pytest.mark.parametrize('python_data, r_data',l3)
def test_MackChainladder_tail_parameter_risk_a0(python_data, r_data):
# R MackChainladder does not work on quarterly triangle, so bypassing
# Also eliminating GenInsLong as R MackChainladder fails on tabular form data
if r_data in ['qpaid', 'qincurred', 'GenInsLong', 'auto$PersonalAutoIncurred','MCLincurred']:
assert True
else:
python = cl.MackChainladder(cl.Triangle(python_data), tail=True, alpha=0).parameter_risk
r_lang = np.array(r('mack<-MackChainLadder(' + r_data + ' ,tail=TRUE,alpha=0)')[9])
assert np.all(np.array(python).round(5)==r_lang.round(5))