From 6e6e446500c99d5e89f5b9fdfc9d7b4185070405 Mon Sep 17 00:00:00 2001 From: arihantlodha-cmd Date: Wed, 5 Aug 2026 19:10:56 +0900 Subject: [PATCH] Add SS-solve model-run tests for NDC and Points System pensions Partially addresses #1014. PR #1167 added a steady-state solve test for the Defined Benefits system only; its docstring notes the analogous NDC and Points System runs should be added. This adds those two tests, mirroring test_SS_solve_defined_benefits with the same structure and assertions and the system-specific parameters already used elsewhere in the module. Confirms all three pension systems solve the steady state with positive pension outlays. Scoped to test coverage only; the remaining time-varying retirement age and earnings items in #1014 are left to the active work in that area. --- tests/test_pensions.py | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/test_pensions.py b/tests/test_pensions.py index 8b407da52..989daaca2 100644 --- a/tests/test_pensions.py +++ b/tests/test_pensions.py @@ -1048,3 +1048,55 @@ def test_SS_solve_defined_benefits(tmp_path): Y = np.asarray(ss["Y"]).sum() assert ss["agg_pension_outlays"] > 0.0 assert 0.0 < ss["agg_pension_outlays"] / Y < 1.0 + + +@pytest.mark.local +def test_SS_solve_notional_defined_contribution(tmp_path): + """ + The steady state must solve with the Notional Defined Contribution + pension system and produce positive aggregate pension outlays (the + NDC counterpart to test_SS_solve_defined_benefits, Issue #1014). + """ + from ogcore.execute import runner + from ogcore import utils + + p = Specifications(baseline=True, num_workers=1) + p.update_specifications( + { + "pension_system": "Notional Defined Contribution", + "tau_p": 0.1, + "ndc_growth_rate": "LR GDP", + "dir_growth_rate": "r", + } + ) + p.baseline_dir = p.output_base = str(tmp_path) + runner(p, time_path=False, client=None) + ss = utils.safe_read_pickle(str(tmp_path / "SS" / "SS_vars.pkl")) + Y = np.asarray(ss["Y"]).sum() + assert ss["agg_pension_outlays"] > 0.0 + assert 0.0 < ss["agg_pension_outlays"] / Y < 1.0 + + +@pytest.mark.local +def test_SS_solve_points_system(tmp_path): + """ + The steady state must solve with the Points System pension system + and produce positive aggregate pension outlays (the Points System + counterpart to test_SS_solve_defined_benefits, Issue #1014). + """ + from ogcore.execute import runner + from ogcore import utils + + p = Specifications(baseline=True, num_workers=1) + p.update_specifications( + { + "pension_system": "Points System", + "vpoint": 0.5, + } + ) + p.baseline_dir = p.output_base = str(tmp_path) + runner(p, time_path=False, client=None) + ss = utils.safe_read_pickle(str(tmp_path / "SS" / "SS_vars.pkl")) + Y = np.asarray(ss["Y"]).sum() + assert ss["agg_pension_outlays"] > 0.0 + assert 0.0 < ss["agg_pension_outlays"] / Y < 1.0