Skip to content

Commit fca981d

Browse files
committed
update r_gov tests
1 parent 7e9abf3 commit fca981d

1 file changed

Lines changed: 35 additions & 16 deletions

File tree

tests/test_fiscal.py

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -259,28 +259,47 @@ def test_get_TR(
259259
r_gov1 = 0.02
260260
r_gov2 = 0.01
261261
r_gov3 = 0.0
262-
r_tpi = np.ones(320) * r
263-
r_gov_tpi = np.ones(320) * r_gov3
264-
p4 = p3.update_specifications({"r_gov_scale": [0.5], "r_gov_shift": [0.03]})
262+
p_tpi = Specifications()
263+
p_tpi.update_specifications(
264+
{
265+
"r_gov_scale": [1.5],
266+
"r_gov_shift": [0.01],
267+
}
268+
)
269+
r_tpi = np.ones(400) * r
270+
r_gov_tpi = np.ones(400) * r * p_tpi.r_gov_scale - p_tpi.r_gov_shift
271+
DY_tpi = np.ones(400) * 0.01
272+
p4 = Specifications()
273+
p4.update_specifications(
274+
{
275+
"r_gov_scale": [1.5],
276+
"r_gov_shift": [0.01],
277+
"r_gov_DY": 0.01,
278+
"r_gov_DY2": 0.001
279+
}
280+
)
281+
p4.r_gov_scale = [1.5]
282+
p4.r_gov_shift = [0.01]
283+
r_gov4 = (
284+
r * p4.r_gov_scale[0] - p4.r_gov_shift[0] +
285+
p4.r_gov_DY * 0.5 + p4.r_gov_DY2 * 0.25
286+
)
287+
265288

266289

267290
@pytest.mark.parametrize(
268-
"r,p,method,r_gov_expected",
291+
"r,p,DY_ratio,method,r_gov_expected",
269292
[
270-
(r, p1, "SS", r_gov1),
271-
(r, p2, "SS", r_gov2),
272-
(r, p3, "SS", r_gov3),
273-
(r, p3, "TPI", r_gov3),
274-
(r, p3, "scalar", r_gov3),
293+
(r, p1, 0, "SS", r_gov1),
294+
(r, p2, 0, "SS", r_gov2),
295+
(r, p3, 0, "SS", r_gov3),
296+
(r_tpi, p_tpi, DY_tpi, "TPI", r_gov_tpi),
297+
(r, p3, 0, "scalar", r_gov3),
298+
(r, p4, 0.5, "scalar", r_gov4),
275299
],
276-
ids=["Scale only", "Scale and shift", "r_gov < 0", "TPI", "scalar"],
300+
ids=["Scale only", "Scale and shift", "r_gov < 0", "TPI", "scalar", "DY params"],
277301
)
278-
def test_get_r_gov(r, p, method, r_gov_expected):
279-
# if r is scalar
280-
if method == "SS":
281-
DY_ratio = 0.0
282-
else:
283-
DY_ratio = np.zeros_like(r)
302+
def test_get_r_gov(r, p, DY_ratio, method, r_gov_expected):
284303
r_gov = fiscal.get_r_gov(r, DY_ratio, p, method, t=0)
285304
assert np.allclose(r_gov, r_gov_expected)
286305

0 commit comments

Comments
 (0)