Skip to content

Make SS and TPI output dictionaries expose the same keys - #1185

Open
arihantlodha-cmd wants to merge 1 commit into
PSLmodels:masterfrom
arihantlodha-cmd:consistent-ss-tpi-output-keys
Open

Make SS and TPI output dictionaries expose the same keys#1185
arihantlodha-cmd wants to merge 1 commit into
PSLmodels:masterfrom
arihantlodha-cmd:consistent-ss-tpi-output-keys

Conversation

@arihantlodha-cmd

Copy link
Copy Markdown

Closes #1152.

PR #1005 made the key names in the steady-state and transition-path output dictionaries consistent, but the two dictionaries still exposed different sets of keys. This makes the same keys available in both.

Before this PR the differences were:

  • In the TPI output but missing from SS: labor_income, capital_income, income_payroll_taxes
  • In the SS output but missing from TPI: factor, theta

Changes:

SS (ogcore/SS.py)

  • Add labor_income (w * n * e) and capital_income (r_p * b_s) to the output dict, computed the same way as their TPI counterparts.
  • Add income_payroll_taxes to the output dict, using the already-computed income_tax_ss.
  • Bug fix: income_tax_ss was computed via tax.income_tax_liab(...) but passed bqssmat (bequests) as the n (labor supply) argument. The TPI equivalent (income_tax_mat) correctly passes labor supply. income_tax_ss was previously never read, so this had no effect until now — but it needs to be correct before it is surfaced in the output. Fixed to pass nssmat.

TPI (ogcore/TPI.py)

  • Add theta and factor to the output dict (both already in scope). These are constants, so they match their SS counterparts.

After the change both dictionaries expose the same 72 keys.

Testing

  • Verified key parity between the two dictionaries: both now expose the same 72 keys.
  • pytest "tests/test_SS.py::test_SS_solver[Baseline]" and pytest "tests/test_TPI.py::test_run_TPI[Baseline]" both pass, exercising the modified output dictionaries at runtime. These tests iterate over the expected (pickled) keys, so the newly added keys don't affect them and existing values are unchanged.
  • ruff format --check . and ruff check . clean.

Happy to adjust naming/placement or add regression coverage for the new keys if you'd like.

Closes PSLmodels#1152. Adds labor_income, capital_income, and income_payroll_taxes
to the SS output dict and theta and factor to the TPI output dict, so both
dictionaries expose the same 72 keys.

Also fixes a latent bug: SS's income_tax_ss was computed via
tax.income_tax_liab but passed bqssmat (bequests) as the n (labor supply)
argument. The value was previously never used; it is now surfaced as
income_payroll_taxes, so the call is corrected to pass nssmat (matching the
TPI income_tax_mat calculation).
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@b0986ac). Learn more about missing BASE report.
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1185   +/-   ##
=========================================
  Coverage          ?   72.67%           
=========================================
  Files             ?       22           
  Lines             ?     5727           
  Branches          ?        0           
=========================================
  Hits              ?     4162           
  Misses            ?     1565           
  Partials          ?        0           
Flag Coverage Δ
unittests 72.67% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ogcore/SS.py 79.12% <100.00%> (ø)
ogcore/TPI.py 36.29% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make consistent output dictionaries for SS and TPI results

2 participants