Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Jul 2, 2024
1 parent 0cf250b commit 40496e5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_pensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,41 @@ def test_replacement_rate_vals(n, w, factor, j, p_in, expected):
)
theta = pensions.replacement_rate_vals(n, w, factor, j, p)
assert np.allclose(theta, expected)


p = Specifications()
p.update_specifications({
"S": 7,
"retirement_age": 4,
"last_career_yrs": 3,
"yr_contr": 4,
"rep_rate_py": 0.2
})
j = 1
w = np.array([1.2, 1.1, 1.21, 1.0, 1.01, 0.99, 0.8])
e = np.array([1.1, 1.11, 0.9, 0.87, 0.87, 0.7, 0.6])
n = np.array([0.4, 0.45, 0.4, 0.42, 0.3, 0.2, 0.2])
g_y = 0.03
L_inc_avg = np.zeros(0)
L_inc_avg_s = np.zeros(p.last_career_yrs)
DB_s = np.zeros(p.retirement_age)
DB = np.zeros(p.S)
DB_loop_expected1 = np.array([0, 0, 0, 0, 0.337864778, 0.327879365, 0.318189065])
args1 = w, e, n, p.retirement_age, p.S, p.g_y, L_inc_avg_s, L_inc_avg, DB_s, DB

test_data = [(args1, DB_loop_expected1)]
# (classes2, args2, NDC_expected2)]

@pytest.mark.parametrize('args,DB_loop_expected', test_data,
ids=['SS/Complete'])
def test_DB_1dim_loop(args, DB_loop_expected):
"""
Test of the pensions.DB_1dim_loop() function.
"""

w, e, n, S_ret, S, g_y, L_inc_avg_s, L_inc_avg, DB_s, DB = args
DB_loop = pensions.DB_1dim_loop(
w, e, n, S_ret, S, g_y, L_inc_avg_s, L_inc_avg, DB_s, DB,
p.last_career_yrs, p.rep_rate,
p.rep_rate_py, p.yr_contr)
assert (np.allclose(DB_loop, DB_loop_expected))

0 comments on commit 40496e5

Please sign in to comment.