Skip to content

Commit 40496e5

Browse files
committed
add test
1 parent 0cf250b commit 40496e5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/test_pensions.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,41 @@ def test_replacement_rate_vals(n, w, factor, j, p_in, expected):
7070
)
7171
theta = pensions.replacement_rate_vals(n, w, factor, j, p)
7272
assert np.allclose(theta, expected)
73+
74+
75+
p = Specifications()
76+
p.update_specifications({
77+
"S": 7,
78+
"retirement_age": 4,
79+
"last_career_yrs": 3,
80+
"yr_contr": 4,
81+
"rep_rate_py": 0.2
82+
})
83+
j = 1
84+
w = np.array([1.2, 1.1, 1.21, 1.0, 1.01, 0.99, 0.8])
85+
e = np.array([1.1, 1.11, 0.9, 0.87, 0.87, 0.7, 0.6])
86+
n = np.array([0.4, 0.45, 0.4, 0.42, 0.3, 0.2, 0.2])
87+
g_y = 0.03
88+
L_inc_avg = np.zeros(0)
89+
L_inc_avg_s = np.zeros(p.last_career_yrs)
90+
DB_s = np.zeros(p.retirement_age)
91+
DB = np.zeros(p.S)
92+
DB_loop_expected1 = np.array([0, 0, 0, 0, 0.337864778, 0.327879365, 0.318189065])
93+
args1 = w, e, n, p.retirement_age, p.S, p.g_y, L_inc_avg_s, L_inc_avg, DB_s, DB
94+
95+
test_data = [(args1, DB_loop_expected1)]
96+
# (classes2, args2, NDC_expected2)]
97+
98+
@pytest.mark.parametrize('args,DB_loop_expected', test_data,
99+
ids=['SS/Complete'])
100+
def test_DB_1dim_loop(args, DB_loop_expected):
101+
"""
102+
Test of the pensions.DB_1dim_loop() function.
103+
"""
104+
105+
w, e, n, S_ret, S, g_y, L_inc_avg_s, L_inc_avg, DB_s, DB = args
106+
DB_loop = pensions.DB_1dim_loop(
107+
w, e, n, S_ret, S, g_y, L_inc_avg_s, L_inc_avg, DB_s, DB,
108+
p.last_career_yrs, p.rep_rate,
109+
p.rep_rate_py, p.yr_contr)
110+
assert (np.allclose(DB_loop, DB_loop_expected))

0 commit comments

Comments
 (0)