Skip to content

Restore idtl=5 full-text output in cli#936

Merged
PavelMakarchuk merged 2 commits into
mainfrom
cli-idtl5-formatter
May 28, 2026
Merged

Restore idtl=5 full-text output in cli#936
PavelMakarchuk merged 2 commits into
mainfrom
cli-idtl5-formatter

Conversation

@PavelMakarchuk
Copy link
Copy Markdown
Collaborator

Summary

Bring back TAXSIM-35's labeled-section human-readable output format (idtl=5) to the cli stdin/stdout flow. Previously only the legacy exe.py PyInstaller entry point handled idtl=5; the modern Microsim-based cli.py always emitted CSV regardless of input idtl.

Context

Closes #933 (idtl=5 portion — the cli-vs-exe pension-allocation portion was already addressed by PR #935). Daniel flagged that cli.py was ignoring idtl=5; the legacy exe.py was removed in PR #855 (April 2026), and the idtl=5 path was lost in the transition.

Mechanism

  • New module core/text_formatter.py renders one result-DataFrame row in TAXSIM-35's labeled format using existing variable_mappings.yaml metadata (full_text_group, text_description, group_order). No fresh Simulation needed — values come straight from the Microsim output.
  • New _emit_results helper in cli.py routes per-row based on idtl: CSV for idtl=0/2, labeled-section text for idtl=5. Mixed-idtl inputs interleave outputs in original input order.
  • Default behavior (no idtl=5 anywhere) is unchanged — pure CSV.

Test plan

  • 4 new tests in tests/test_cli_idtl5.py (idtl=5 emits sections; idtl=5 doesn't emit CSV header; idtl=2 still emits CSV; idtl=5 shows federal tax)
  • 42 related existing tests pass (cli/stitched/spouse-splitting/three-pass)
  • CI passes

Closes #933 (idtl=5 part).

The legacy exe.py PyInstaller entry point produced TAXSIM's
labeled-section human-readable output for idtl=5. After exe.py was
removed in PR #855, the modern Microsim-based cli.py always emitted
CSV, ignoring idtl. Daniel flagged the regression in #933.

Add `core/text_formatter.py` that renders one result-DataFrame row
in TAXSIM-35 format using the existing variable_mappings.yaml
metadata (full_text_group, text_description, group_order). No fresh
Simulation needed — values come straight from the Microsim output.

Wire `_emit_results` into the cli stdin/stdout flow: pure-CSV when
no row has idtl=5 (existing behavior), per-row labeled-section
output for idtl=5 rows, interleaved with CSV for mixed input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-taxsim Ready Ready Preview, Comment May 28, 2026 1:10pm

Request Review

The prior implementation went through set_index('taxsimid') and
.to_dict(), which appended taxsimid as the last column when
serialized back to CSV. Use direct row lookup instead so the CSV
emission preserves the standard `taxsimid,year,state,...` header
order downstream parsers expect.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@PavelMakarchuk PavelMakarchuk merged commit 9b81c4c into main May 28, 2026
10 of 11 checks passed
@PavelMakarchuk PavelMakarchuk deleted the cli-idtl5-formatter branch May 28, 2026 13:56
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.

CO joint 2025 58page 56sage 20Kpwages 10Kswages 5Kintrec 64Kpensions

1 participant