PolicyEngine / PolicyEngine/policyengine.py

Household results return numeric indices for enum variables (state_code -> 4.0, filing_status -> 0.0)

Open
#459 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7
Forks
9
Avg merge
15h 51m
Merged PRs (30d)
9

Description

Found during the PR #363 review, but pre-existing and identical in the non-axes path: _safe_convert in us/household.py (and the UK counterpart) floats EnumArray int16 indices, so result.household.state_code returns 4.0 instead of "CA" and result.tax_unit.filing_status returns 0.0 instead of "SINGLE". The default person column race already ships this way. EnumArray.decode_to_str() is the proper decode. Fix belongs in the shared result-building path; needs a small sweep of existing tests that may assert the numeric form.

🤖 Generated with Claude Code

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with _safe_convert in us/household.py and its UK counterpart, then inspect the shared result-building path and EnumArray.decode_to_str(). Update the conversion so enum results return their string values rather than numeric indices, and sweep existing tests for assertions of the numeric form.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.