From bb313528dd9f38fb044ced63c36d59a1af089bb3 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 26 Mar 2024 11:05:22 -0400 Subject: [PATCH] test income foreast method --- ccc/tests/test_calcfunctions.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ccc/tests/test_calcfunctions.py b/ccc/tests/test_calcfunctions.py index 3280f6de..56870c38 100644 --- a/ccc/tests/test_calcfunctions.py +++ b/ccc/tests/test_calcfunctions.py @@ -231,6 +231,30 @@ def test_econ(delta, bonus, r, pi, expected_val): assert np.allclose(test_val, expected_val) +Y = np.array([40, 3, 10, 20, 8]) +delta = np.array([0.12, 0.10, 0.15, 0.2, 0.18]) +bonus = np.array([0.0, 0.0, 0.4, 1.0, 0.9]) +r = np.array([0.03, 0.03, 0.03, 0.03, 0.03]) +expected_val = np.array([0.588563059, 0.956320164, 0.924042198, 1, 0.99041001]) +test_data = [(Y, delta, bonus, r, expected_val)] + + +@pytest.mark.parametrize("Y,delta,bonus,r,expected_val", test_data, ids=["Test 0"]) +def test_income_forecast(Y, delta, bonus, r, expected_val): + test_val = cf.income_forecast(Y, delta, bonus, r) + + assert np.allclose(test_val, expected_val) + + +Y = np.array([40, 1, 10, 20, 8]) +bonus = np.array([0, 0, 0.4, 1, 1.2]) +r = np.array([0.12, 0.12, 0.12, 0.12, 0.12]) +expected_val = np.array( + [0.206618803, 0.942329694, 0.749402894, 1, 1.071436018] +) +test_data = [(Y, bonus, r, expected_val)] + + df = pd.DataFrame.from_dict( { "asset_name": [