@@ -79,7 +79,7 @@ def test_replacement_rate_vals(n, w, factor, j, p_in, expected):
79
79
# })
80
80
p .S = 7
81
81
p .rep_rate_py = 0.2
82
- p .retirement_age = 4
82
+ p .retire = 4
83
83
p .last_career_yrs = 3
84
84
p .yr_contr = 4
85
85
p .g_y = 0.03
@@ -89,24 +89,136 @@ def test_replacement_rate_vals(n, w, factor, j, p_in, expected):
89
89
n = np .array ([0.4 , 0.45 , 0.4 , 0.42 , 0.3 , 0.2 , 0.2 ])
90
90
L_inc_avg = np .zeros (0 )
91
91
L_inc_avg_s = np .zeros (p .last_career_yrs )
92
- DB_s = np .zeros (p .retirement_age )
93
92
DB = np .zeros (p .S )
94
- DB_loop_expected1 = np .array ([0 , 0 , 0 , 0 , 0.337864778 , 0.327879365 , 0.318189065 ])
95
- args1 = w , e , n , p .retirement_age , p .S , p .g_y , L_inc_avg_s , L_inc_avg , DB_s , DB
93
+ DB_loop_expected1 = np .array (
94
+ [0 , 0 , 0 , 0 , 0.337864778 , 0.327879365 , 0.318189065 ]
95
+ )
96
+ args1 = (
97
+ w ,
98
+ e ,
99
+ n ,
100
+ p .retire ,
101
+ p .S ,
102
+ p .g_y ,
103
+ L_inc_avg_s ,
104
+ L_inc_avg ,
105
+ DB ,
106
+ p .last_career_yrs ,
107
+ p .rep_rate_py ,
108
+ p .yr_contr ,
109
+ )
96
110
97
111
test_data = [(args1 , DB_loop_expected1 )]
98
- # (classes2, args2, NDC_expected2)]
99
112
100
- @pytest .mark .parametrize ('args,DB_loop_expected' , test_data ,
101
- ids = ['SS/Complete' ])
113
+
114
+ @pytest .mark .parametrize (
115
+ "args,DB_loop_expected" , test_data , ids = ["SS/Complete" ]
116
+ )
102
117
def test_DB_1dim_loop (args , DB_loop_expected ):
103
118
"""
104
119
Test of the pensions.DB_1dim_loop() function.
105
120
"""
106
121
107
- w , e , n , S_ret , S , g_y , L_inc_avg_s , L_inc_avg , DB_s , DB = args
122
+ (
123
+ w ,
124
+ e ,
125
+ n ,
126
+ S_ret ,
127
+ S ,
128
+ g_y ,
129
+ L_inc_avg_s ,
130
+ L_inc_avg ,
131
+ DB ,
132
+ last_career_yrs ,
133
+ rep_rate_py ,
134
+ yr_contr ,
135
+ ) = args
108
136
DB_loop = pensions .DB_1dim_loop (
109
- w , e , n , S_ret , S , g_y , L_inc_avg_s , L_inc_avg , DB ,
110
- p .last_career_yrs ,
111
- p .rep_rate_py , p .yr_contr )
112
- assert (np .allclose (DB_loop , DB_loop_expected ))
137
+ w ,
138
+ e ,
139
+ n ,
140
+ S_ret ,
141
+ S ,
142
+ g_y ,
143
+ L_inc_avg_s ,
144
+ L_inc_avg ,
145
+ DB ,
146
+ last_career_yrs ,
147
+ rep_rate_py ,
148
+ yr_contr ,
149
+ )
150
+ assert np .allclose (DB_loop , DB_loop_expected )
151
+
152
+
153
+ p = Specifications ()
154
+ p .S = 7
155
+ p .retire = 4
156
+ per_rmn = p .S
157
+ p .last_career_yrs = 3
158
+ p .yr_contr = p .retire
159
+ p .rep_rate_py = 0.2
160
+ p .g_y = 0.03
161
+ w = np .array ([1.2 , 1.1 , 1.21 , 1 , 1.01 , 0.99 , 0.8 ])
162
+ e = np .array ([1.1 , 1.11 , 0.9 , 0.87 , 0.87 , 0.7 , 0.6 ])
163
+ deriv_DB_loop_expected = np .array (
164
+ [0.352 , 0.3256 , 0.2904 , 0.232 , 0.0 , 0.0 , 0.0 ]
165
+ )
166
+ d_theta_empty = np .zeros_like (w )
167
+ args3 = (
168
+ w ,
169
+ e ,
170
+ p .S ,
171
+ p .retire ,
172
+ per_rmn ,
173
+ p .last_career_yrs ,
174
+ p .rep_rate_py ,
175
+ p .yr_contr ,
176
+ )
177
+
178
+ test_data = [(args3 , deriv_DB_loop_expected )]
179
+
180
+
181
+ @pytest .mark .parametrize ("args,deriv_DB_loop_expected" , test_data )
182
+ def test_deriv_DB_loop (args , deriv_DB_loop_expected ):
183
+ """
184
+ Test of the pensions.deriv_DB_loop() function.
185
+ """
186
+ (w , e , S , retire , per_rmn , last_career_yrs , rep_rate_py , yr_contr ) = args
187
+ deriv_DB_loop = pensions .deriv_DB_loop (
188
+ w , e , S , retire , per_rmn , last_career_yrs , rep_rate_py , yr_contr
189
+ )
190
+
191
+ assert np .allclose (deriv_DB_loop , deriv_DB_loop_expected )
192
+
193
+
194
+ p = Specifications ()
195
+ p .S = 7
196
+ p .retire = 4
197
+ p .vpoint = 0.4
198
+ w = np .array ([1.2 , 1.1 , 1.21 , 1 , 1.01 , 0.99 , 0.8 ])
199
+ e = np .array ([1.1 , 1.11 , 0.9 , 0.87 , 0.87 , 0.7 , 0.6 ])
200
+ p .g_y = 0.03
201
+ factor = 2
202
+ d_theta_empty = np .zeros_like (w )
203
+ deriv_PS_loop_expected1 = np .array (
204
+ [0.003168 , 0.0029304 , 0.0026136 , 0.002088 , 0 , 0 , 0 ]
205
+ )
206
+ args3 = (w , e , p .S , p .retire , per_rmn , d_theta_empty , p .vpoint , factor )
207
+
208
+ test_data = [(args3 , deriv_PS_loop_expected1 )]
209
+
210
+
211
+ @pytest .mark .parametrize (
212
+ "args,deriv_PS_loop_expected" , test_data , ids = ["SS/Complete" ]
213
+ )
214
+ def test_deriv_PS_loop (args , deriv_PS_loop_expected ):
215
+ """
216
+ Test of the pensions.deriv_PS_loop() function.
217
+ """
218
+ (w , e , S , retire , per_rmn , d_theta_empty , vpoint , factor ) = args
219
+
220
+ deriv_PS_loop = pensions .deriv_PS_loop (
221
+ w , e , S , retire , per_rmn , d_theta_empty , vpoint , factor
222
+ )
223
+
224
+ assert np .allclose (deriv_PS_loop , deriv_PS_loop_expected )
0 commit comments