From 75b9d64b5ea59097ad5ea81c43952b303e0e51b4 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 23:23:14 +0000 Subject: [PATCH 01/16] Round summed resources to cents before exact-limit asset tests Balances are stored as float32, so three accounts that add to exactly a limit in cents can sum a fraction of a cent above it (178.57 + 1,547.79 + 273.64 = 2,000.0001) and fail an "at or below" test, or below it and pass a "below" test. Add a shared round_to_cents helper and apply it where SSI, SNAP, Medicaid, the Medicare Savings Programs, BBCE and 47 state programs compare summed resources with a dollar limit. Each site has a YAML witness at the limit that fails on main, and a cent-over (or cent-under) case. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LwQq6HXUrFaqEeR9DeqWcq --- changelog.d/round-summed-limits.fixed.md | 1 + .../is_medically_needy_for_medicaid.yaml | 35 +++++ .../eligibility/msp_asset_eligible.yaml | 27 ++++ .../meets_tanf_non_cash_asset_test.yaml | 23 ++++ ...sources_deemed_from_ineligible_parent.yaml | 36 ++++++ .../resources/meets_ssi_resource_test.yaml | 25 ++++ .../dpa/atap/ak_atap_resources_eligible.yaml | 25 ++++ .../ar/dhs/tea/ar_tea_resources_eligible.yaml | 25 ++++ .../hhs/tanf/az_tanf_resources_eligible.yaml | 25 ++++ .../ca_capi_resource_eligible.yaml | 29 +++++ .../states/co/ssa/oap/co_oap_eligible.yaml | 29 +++++ .../eligibility/ct_ssp_resource_eligible.yaml | 29 +++++ .../ct_tfa_resources_eligible.yaml | 25 ++++ .../dc_tanf_resources_eligible.yaml | 25 ++++ .../de_tanf_resources_eligible.yaml | 25 ++++ .../dcf/tanf/fl_tca_resources_eligible.yaml | 25 ++++ .../ga_tanf_resources_eligible.yaml | 25 ++++ .../ia/dhs/fip/ia_fip_resources_eligible.yaml | 25 ++++ .../states/ia/hhs/ssa/ia_ssa_eligible.yaml | 28 ++++ .../id/tafi/id_tafi_resources_eligible.yaml | 25 ++++ .../resources/in_tanf_resources_eligible.yaml | 25 ++++ .../dcf/tanf/ks_tanf_resources_eligible.yaml | 25 ++++ .../dcbs/ktap/ky_ktap_resource_eligible.yaml | 25 ++++ .../dhhs/tanf/me_tanf_resources_eligible.yaml | 25 ++++ .../mi_fip_resources_eligible.yaml | 25 ++++ .../dcyf/mfip/mn_mfip_resources_eligible.yaml | 25 ++++ .../eligibility/mn_msa_resource_eligible.yaml | 29 +++++ .../dss/tanf/mo_tanf_resources_eligible.yaml | 25 ++++ .../dhs/tanf/ms_tanf_resources_eligible.yaml | 25 ++++ .../eligibility/ms_hmw_resource_eligible.yaml | 29 +++++ .../mt_tanf_resources_eligible.yaml | 25 ++++ .../dhs/tanf/nd_tanf_resources_eligible.yaml | 25 ++++ .../dhhs/adc/ne_adc_resources_eligible.yaml | 25 ++++ .../dhhs/fanf/nh_fanf_resources_eligible.yaml | 25 ++++ .../states/nh/dhhs/ssp/nh_ssp_eligible.yaml | 28 ++++ .../wfnj/nj_wfnj_resources_eligible.yaml | 25 ++++ .../nm_works_resources_eligible.yaml | 25 ++++ .../nv_tanf_resources_eligible.yaml | 25 ++++ .../otda/tanf/ny_tanf_resources_eligible.yaml | 25 ++++ .../dhs/tanf/ok_tanf_resources_eligible.yaml | 25 ++++ .../odhs/tanf/or_tanf_resources_eligible.yaml | 25 ++++ .../pa_tanf_resources_eligible.yaml | 25 ++++ .../dhs/works/ri_works_resource_eligible.yaml | 25 ++++ .../sc/tanf/sc_tanf_resources_eligible.yaml | 25 ++++ .../sd_tanf_resources_eligible.yaml | 25 ++++ .../eligibility/tn_ff_resources_eligible.yaml | 25 ++++ .../tx_tanf_resources_eligible.yaml | 25 ++++ .../ut_fep_resources_eligible.yaml | 25 ++++ .../vt_reach_up_resources_eligible.yaml | 25 ++++ .../dshs/tanf/wa_tanf_resources_eligible.yaml | 25 ++++ .../works/wi_works_resources_eligible.yaml | 25 ++++ .../works/wv_works_resources_eligible.yaml | 25 ++++ .../power/wy_power_resources_eligible.yaml | 25 ++++ .../eligibility/meets_snap_asset_test.yaml | 23 ++++ .../unit/test_round_to_cents_properties.py | 121 ++++++++++++++++++ policyengine_us/tools/general.py | 14 ++ ...ional_senior_or_disabled_asset_eligible.py | 2 +- .../is_medically_needy_for_medicaid.py | 3 +- .../eligibility/msp_asset_eligible.py | 11 +- .../meets_tanf_non_cash_asset_test.py | 3 +- ...resources_deemed_from_ineligible_parent.py | 7 +- .../resources/meets_ssi_resource_test.py | 11 +- .../eligibility/ak_atap_resources_eligible.py | 3 +- .../eligibility/ar_tea_resources_eligible.py | 3 +- .../eligibility/az_tanf_resources_eligible.py | 3 +- .../eligibility/ca_capi_resource_eligible.py | 3 +- .../gov/states/co/ssa/oap/co_oap_eligible.py | 3 +- .../eligibility/ct_ssp_resource_eligible.py | 3 +- .../eligibility/ct_tfa_resources_eligible.py | 3 +- .../eligibility/dc_tanf_resources_eligible.py | 5 +- .../eligibility/de_tanf_resources_eligible.py | 3 +- .../eligibility/fl_tca_resources_eligible.py | 3 +- .../eligibility/ga_tanf_resources_eligible.py | 3 +- .../eligibility/ia_fip_resources_eligible.py | 3 +- .../gov/states/ia/hhs/ssa/ia_ssa_eligible.py | 2 + .../eligibility/id_tafi_resources_eligible.py | 3 +- .../eligibility/in_tanf_resources_eligible.py | 3 +- .../eligibility/ks_tanf_resources_eligible.py | 3 +- .../eligibility/ky_ktap_resource_eligible.py | 3 +- .../eligibility/me_tanf_resources_eligible.py | 5 +- .../eligibility/mi_fip_resources_eligible.py | 3 +- .../eligibility/mn_mfip_resources_eligible.py | 3 +- .../eligibility/mn_msa_resource_eligible.py | 3 +- .../eligibility/mo_tanf_resources_eligible.py | 3 +- .../eligibility/ms_tanf_resources_eligible.py | 5 +- .../eligibility/ms_hmw_resource_eligible.py | 3 +- .../eligibility/mt_tanf_resources_eligible.py | 5 +- .../eligibility/nd_tanf_resources_eligible.py | 3 +- .../eligibility/ne_adc_resources_eligible.py | 3 +- .../eligibility/nh_fanf_resources_eligible.py | 3 +- .../gov/states/nh/dhhs/ssp/nh_ssp_eligible.py | 2 + .../eligibility/nj_wfnj_resources_eligible.py | 3 +- .../nm_works_resources_eligible.py | 5 +- .../eligibility/nv_tanf_resources_eligible.py | 3 +- .../eligibility/ny_tanf_resources_eligible.py | 3 +- .../eligibility/ok_tanf_resources_eligible.py | 3 +- .../eligibility/or_tanf_resources_eligible.py | 5 +- .../eligibility/pa_tanf_resources_eligible.py | 6 +- .../eligibility/ri_works_resource_eligible.py | 3 +- .../eligibility/sc_tanf_resources_eligible.py | 3 +- .../eligibility/sd_tanf_resources_eligible.py | 3 +- .../eligibility/tn_ff_resources_eligible.py | 5 +- .../eligibility/tx_tanf_resources_eligible.py | 5 +- .../eligibility/ut_fep_resources_eligible.py | 3 +- .../vt_reach_up_resources_eligible.py | 3 +- .../dshs/tanf/wa_tanf_resources_eligible.py | 5 +- .../wi_works_resources_eligible.py | 3 +- .../wv_works_resources_eligible.py | 5 +- .../wy_power_resources_eligible.py | 3 +- .../snap/eligibility/meets_snap_asset_test.py | 3 +- 110 files changed, 1648 insertions(+), 60 deletions(-) create mode 100644 changelog.d/round-summed-limits.fixed.md create mode 100644 policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml create mode 100644 policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/ssp/nh_ssp_eligible.yaml create mode 100644 policyengine_us/tests/unit/test_round_to_cents_properties.py diff --git a/changelog.d/round-summed-limits.fixed.md b/changelog.d/round-summed-limits.fixed.md new file mode 100644 index 00000000000..548cceea1c7 --- /dev/null +++ b/changelog.d/round-summed-limits.fixed.md @@ -0,0 +1 @@ +Round summed resources to whole cents before SSI, SNAP, Medicaid, Medicare Savings Program and state asset tests compare them with their dollar limits, so balances that add to exactly a limit pass or fail as the total does. diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml index a3934f084f7..7257fdd5de9 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml @@ -940,3 +940,38 @@ # 2027 still reads the 195,000 couple limit; 31,000 first applies in 2028. is_in_medicaid_medically_needy_category: [true, true] is_medically_needy_for_medicaid: [true, true] + +# Arkansas' 2,000 individual asset limit: 178.57 + 1,547.79 + 273.64 = +# 2,000.00. The float32 balances add to 2,000.0001 unless rounded to cents. +- name: Three accounts that total exactly the Arkansas limit pass + period: 2026 + input: + is_disabled: true + meets_ssi_disability_criteria: true + is_in_medicaid_medically_needy_category: true + is_adult_for_medicaid: false + is_optional_senior_or_disabled_for_medicaid: false + ssi_countable_income: 0 + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.64 + state_code: AR + output: + is_medically_needy_for_medicaid: true + +# 178.57 + 1,547.79 + 273.65 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the Arkansas limit fail + period: 2026 + input: + is_disabled: true + meets_ssi_disability_criteria: true + is_in_medicaid_medically_needy_category: true + is_adult_for_medicaid: false + is_optional_senior_or_disabled_for_medicaid: false + ssi_countable_income: 0 + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.65 + state_code: AR + output: + is_medically_needy_for_medicaid: false diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml index feaba98d662..e932d51a68d 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml @@ -437,3 +437,30 @@ # July 2027; resources may not exceed it. msp_asset_eligible: 2027-07: [true, true] + +# 42 U.S.C. 1396d(p)(1)(C): 2,885.40 + 5,798.41 + 976.19 = 9,660.00, at the +# 2025 individual limit. The float32 balances add to 9,660.001 unless rounded. +- name: Three accounts that total exactly the individual limit pass + period: 2025-01 + input: + age: 67 + bank_account_assets: 2_885.40 + stock_assets: 5_798.41 + bond_assets: 976.19 + spm_unit_is_married: false + state_code: TX + output: + msp_asset_eligible: true + +# 2,885.40 + 5,798.41 + 976.20 = 9,660.01, a cent over the limit. +- name: Three accounts a cent over the individual limit fail + period: 2025-01 + input: + age: 67 + bank_account_assets: 2_885.40 + stock_assets: 5_798.41 + bond_assets: 976.20 + spm_unit_is_married: false + state_code: TX + output: + msp_asset_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml index 9a37b0b65a0..998283aefdb 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml @@ -106,3 +106,26 @@ household_vehicles_value: 18_000 output: meets_tanf_non_cash_asset_test: true + +# Idaho's 5,000 BBCE asset limit: 3,247.08 + 1,316.70 + 436.22 = 5,000.00. +# The float32 balances add to 5,000.0005 unless rounded to cents. +- name: Three accounts that total exactly the Idaho limit pass + period: 2026 + input: + state_code_str: ID + bank_account_assets: 3_247.08 + stock_assets: 1_316.70 + bond_assets: 436.22 + output: + meets_tanf_non_cash_asset_test: true + +# 3,247.08 + 1,316.70 + 436.23 = 5,000.01, a cent over the limit. +- name: Three accounts a cent over the Idaho limit fail + period: 2026 + input: + state_code_str: ID + bank_account_assets: 3_247.08 + stock_assets: 1_316.70 + bond_assets: 436.23 + output: + meets_tanf_non_cash_asset_test: false diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 7d42e07cc67..660a4855fb3 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -397,6 +397,42 @@ ssi_resources_deemed_from_ineligible_parent: [0, 500, 0, 500, 0, 500] meets_ssi_resource_test: [false, true, false, true, false, false] +# 20 CFR 416.1202(b)(1), 416.1205: the child's 575.52 + 570.57 + 353.91 = +# 1,500.00 plus parental excess 2,500 - 2,000 = 500 is 2,000.00, at the +# individual limit. The child's float32 balances add to 1,500.0001 unless +# rounded to cents. +- name: Child accounts plus parental excess that total exactly the limit pass + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_500 + child: + age: 16 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.91 + tax_units: + tax_unit: + members: [parent, child] + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 500] + meets_ssi_resource_test: [false, true] + # POMS SI 01330.340 White example: parent pool1200 <=couple limit3000; child deemed0. - name: POMS White eligible parent leaves no excess resources to deem period: 2024-01 diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml index 111d5625edf..208c36cb1f0 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml @@ -326,3 +326,28 @@ ssi_resources_deemed_from_ineligible_parent: [0, 0, 0, 0, 0, 0, 0, 0, 0] ssi_resources_deemed_from_ineligible_spouse: [3001, 0, 0, 0, 0, 0, 0, 0, 0] meets_ssi_resource_test: [true, true, true, true, true, true, true, true, true] + +# 20 CFR 416.1205: 178.57 + 1,547.79 + 273.64 = 2,000.00, at the individual +# limit. The three float32 balances add to 2,000.0001 unless rounded to cents. +- name: Three accounts that total exactly the individual limit pass + period: 2026-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.64 + output: + meets_ssi_resource_test: true + +# 178.57 + 1,547.79 + 273.65 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the individual limit fail + period: 2026-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.65 + output: + meets_ssi_resource_test: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ak/dpa/atap/ak_atap_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ak/dpa/atap/ak_atap_resources_eligible.yaml index 7c1b7871e76..cdf490fab39 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ak/dpa/atap/ak_atap_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ak/dpa/atap/ak_atap_resources_eligible.yaml @@ -188,3 +188,28 @@ # Elderly, limit is $3,000 # $3,000 = $3,000 = eligible ak_atap_resources_eligible: true + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: AK + output: + ak_atap_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: AK + output: + ak_atap_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ar/dhs/tea/ar_tea_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ar/dhs/tea/ar_tea_resources_eligible.yaml index 3ff73c08f4c..35116efc03b 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ar/dhs/tea/ar_tea_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ar/dhs/tea/ar_tea_resources_eligible.yaml @@ -95,3 +95,28 @@ output: ar_tea_resources_eligible: false # 10,000 > 3,000 -> ineligible + +# 798.28 + 2,187.62 + 14.10 = 3,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 3,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.10 + state_code: AR + output: + ar_tea_resources_eligible: true + +# 798.28 + 2,187.62 + 14.11 = 3,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.11 + state_code: AR + output: + ar_tea_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/az/hhs/tanf/az_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/az/hhs/tanf/az_tanf_resources_eligible.yaml index 253c6e15d87..13ad274e098 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/az/hhs/tanf/az_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/az/hhs/tanf/az_tanf_resources_eligible.yaml @@ -100,3 +100,28 @@ output: # $5,000 > $2,000 limit az_tanf_resources_eligible: false + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: AZ + output: + az_tanf_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: AZ + output: + az_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.yaml index e21c6962b06..2e7d8d9d241 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.yaml @@ -33,3 +33,32 @@ state_code: CA output: ca_capi_resource_eligible: false + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: CA + output: + ca_capi_resource_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: CA + output: + ca_capi_resource_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml index 88b99f6d860..af164364611 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml @@ -47,3 +47,32 @@ state_code: CO output: co_oap_eligible: true + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: CO + output: + co_oap_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: CO + output: + co_oap_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.yaml index f1c4a0a51dc..f88d486d645 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.yaml @@ -204,3 +204,32 @@ output: # Married households use the $2,400 couple limit; $2,500 is ineligible. ct_ssp_resource_eligible: [false, false] + +# 1,079.68 + 511.39 + 8.93 = 1,600.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,600 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_079.68 + stock_assets: 511.39 + bond_assets: 8.93 + state_code: CT + output: + ct_ssp_resource_eligible: true + +# 1,079.68 + 511.39 + 8.94 = 1,600.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_079.68 + stock_assets: 511.39 + bond_assets: 8.94 + state_code: CT + output: + ct_ssp_resource_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.yaml index 9fbf36fe64d..65e8bf5fdc3 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.yaml @@ -123,3 +123,28 @@ output: # $5,000 > $3,000 old limit, ineligible before 10/1/2023 ct_tfa_resources_eligible: false + +# 4,489.49 + 1,282.41 + 228.10 = 6,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 6,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_489.49 + stock_assets: 1_282.41 + bond_assets: 228.10 + state_code: CT + output: + ct_tfa_resources_eligible: true + +# 4,489.49 + 1,282.41 + 228.11 = 6,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_489.49 + stock_assets: 1_282.41 + bond_assets: 228.11 + state_code: CT + output: + ct_tfa_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.yaml index f316a3c6abd..004e26a22b4 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.yaml @@ -35,3 +35,28 @@ bank_account_assets: 2_001 output: dc_tanf_resources_eligible: false + +# 798.28 + 2,187.62 + 14.10 = 3,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 3,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.10 + state_code: DC + output: + dc_tanf_resources_eligible: true + +# 798.28 + 2,187.62 + 14.11 = 3,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.11 + state_code: DC + output: + dc_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.yaml index 42366652f8c..8a0d4c517f6 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.yaml @@ -72,3 +72,28 @@ output: # $10,001 > $10,000 limit → ineligible de_tanf_resources_eligible: false + +# 8,688.73 + 9.74 + 1,301.53 = 10,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 10,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.53 + state_code: DE + output: + de_tanf_resources_eligible: true + +# 8,688.73 + 9.74 + 1,301.54 = 10,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.54 + state_code: DE + output: + de_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/fl/dcf/tanf/fl_tca_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/fl/dcf/tanf/fl_tca_resources_eligible.yaml index f8b813e1729..b281102d1c2 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/fl/dcf/tanf/fl_tca_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/fl/dcf/tanf/fl_tca_resources_eligible.yaml @@ -69,3 +69,28 @@ state_code: FL output: fl_tca_resources_eligible: false + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: FL + output: + fl_tca_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: FL + output: + fl_tca_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.yaml index 21f0ca1b77e..da1ffd0b19d 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.yaml @@ -29,3 +29,28 @@ spm_unit_cash_assets: 999 output: ga_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.90 = 1,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.90 + state_code: GA + output: + ga_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.91 = 1,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.91 + state_code: GA + output: + ga_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ia/dhs/fip/ia_fip_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ia/dhs/fip/ia_fip_resources_eligible.yaml index 5aab0ffe678..3e665e4b9cf 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ia/dhs/fip/ia_fip_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ia/dhs/fip/ia_fip_resources_eligible.yaml @@ -97,3 +97,28 @@ output: # At limit should be eligible (<=) ia_fip_resources_eligible: true + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: IA + output: + ia_fip_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: IA + output: + ia_fip_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml new file mode 100644 index 00000000000..48895eb269d --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml @@ -0,0 +1,28 @@ +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: IA + output: + ia_ssa_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: IA + output: + ia_ssa_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/id/tafi/id_tafi_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/id/tafi/id_tafi_resources_eligible.yaml index 451c82e2971..7bdf37bdcaa 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/id/tafi/id_tafi_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/id/tafi/id_tafi_resources_eligible.yaml @@ -101,3 +101,28 @@ output: id_tafi_resources_eligible: false # $100,000 > $5,000 -> ineligible + +# 4,211.74 + 769.20 + 19.06 = 5,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 5,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_211.74 + stock_assets: 769.20 + bond_assets: 19.06 + state_code: ID + output: + id_tafi_resources_eligible: true + +# 4,211.74 + 769.20 + 19.07 = 5,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_211.74 + stock_assets: 769.20 + bond_assets: 19.07 + state_code: ID + output: + id_tafi_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/in/fssa/tanf/resources/in_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/in/fssa/tanf/resources/in_tanf_resources_eligible.yaml index 0e5da21a6d4..3f2a4f46298 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/in/fssa/tanf/resources/in_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/in/fssa/tanf/resources/in_tanf_resources_eligible.yaml @@ -58,3 +58,28 @@ output: in_tanf_resources_eligible: true # 0 <= 1_000 = true + +# 650.46 + 299.64 + 49.90 = 1,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.90 + state_code: IN + output: + in_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.91 = 1,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.91 + state_code: IN + output: + in_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ks/dcf/tanf/ks_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ks/dcf/tanf/ks_tanf_resources_eligible.yaml index 6c8dd12e410..3952e174c96 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ks/dcf/tanf/ks_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ks/dcf/tanf/ks_tanf_resources_eligible.yaml @@ -40,3 +40,28 @@ spm_unit_cash_assets: 10_000 output: ks_tanf_resources_eligible: false + +# 798.28 + 2,187.62 + 14.10 = 3,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 3,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.10 + state_code: KS + output: + ks_tanf_resources_eligible: true + +# 798.28 + 2,187.62 + 14.11 = 3,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.11 + state_code: KS + output: + ks_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ky/dcbs/ktap/ky_ktap_resource_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ky/dcbs/ktap/ky_ktap_resource_eligible.yaml index fd1658a596d..c0e3229af88 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ky/dcbs/ktap/ky_ktap_resource_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ky/dcbs/ktap/ky_ktap_resource_eligible.yaml @@ -102,3 +102,28 @@ output: # Not in Kentucky ky_ktap_resource_eligible: false + +# 8,688.73 + 9.74 + 1,301.53 = 10,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 10,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.53 + state_code: KY + output: + ky_ktap_resource_eligible: true + +# 8,688.73 + 9.74 + 1,301.54 = 10,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.54 + state_code: KY + output: + ky_ktap_resource_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/me/dhhs/tanf/me_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/me/dhhs/tanf/me_tanf_resources_eligible.yaml index 3024313a3a5..3574d25a15a 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/me/dhhs/tanf/me_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/me/dhhs/tanf/me_tanf_resources_eligible.yaml @@ -27,3 +27,28 @@ spm_unit_cash_assets: 0 output: me_tanf_resources_eligible: true + +# 8,688.73 + 9.74 + 1,301.53 = 10,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 10,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.53 + state_code: ME + output: + me_tanf_resources_eligible: true + +# 8,688.73 + 9.74 + 1,301.54 = 10,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.54 + state_code: ME + output: + me_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.yaml index 9c15f884ddd..500406f49c5 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.yaml @@ -45,3 +45,28 @@ spm_unit_cash_assets: 10_000 output: mi_fip_resources_eligible: 0 + +# 8,612.82 + 6,310.95 + 76.23 = 15,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 15,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_612.82 + stock_assets: 6_310.95 + bond_assets: 76.23 + state_code: MI + output: + mi_fip_resources_eligible: true + +# 8,612.82 + 6,310.95 + 76.24 = 15,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_612.82 + stock_assets: 6_310.95 + bond_assets: 76.24 + state_code: MI + output: + mi_fip_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/mn/dcyf/mfip/mn_mfip_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/mn/dcyf/mfip/mn_mfip_resources_eligible.yaml index 10a5e6fc792..301006eec8e 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/mn/dcyf/mfip/mn_mfip_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/mn/dcyf/mfip/mn_mfip_resources_eligible.yaml @@ -82,3 +82,28 @@ # Limit: $10,000 # Eligible: 10,001 <= 10,000 = false mn_mfip_resources_eligible: false + +# 8,688.73 + 9.74 + 1,301.53 = 10,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 10,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.53 + state_code: MN + output: + mn_mfip_resources_eligible: true + +# 8,688.73 + 9.74 + 1,301.54 = 10,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.54 + state_code: MN + output: + mn_mfip_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.yaml index e51576f874a..ddc7e1bec8c 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.yaml @@ -332,3 +332,32 @@ state_code: MN output: mn_msa_resource_eligible: true + +# 8,688.73 + 9.74 + 1,301.53 = 10,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 10,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.53 + state_code: MN + output: + mn_msa_resource_eligible: true + +# 8,688.73 + 9.74 + 1,301.54 = 10,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.54 + state_code: MN + output: + mn_msa_resource_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/mo/dss/tanf/mo_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/mo/dss/tanf/mo_tanf_resources_eligible.yaml index 6abfee83c58..50616a884c9 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/mo/dss/tanf/mo_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/mo/dss/tanf/mo_tanf_resources_eligible.yaml @@ -21,3 +21,28 @@ spm_unit_cash_assets: 1_001 output: mo_tanf_resources_eligible: false + +# 650.46 + 299.64 + 49.90 = 1,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.90 + state_code: MO + output: + mo_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.91 = 1,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.91 + state_code: MO + output: + mo_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ms/dhs/tanf/ms_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ms/dhs/tanf/ms_tanf_resources_eligible.yaml index f6c851d2cae..33e366dd5bb 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ms/dhs/tanf/ms_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ms/dhs/tanf/ms_tanf_resources_eligible.yaml @@ -64,3 +64,28 @@ output: # Not in MS, returns false (defined_for = MS) ms_tanf_resources_eligible: false + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: MS + output: + ms_tanf_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: MS + output: + ms_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.yaml index 6bcc9a817e5..d1d0a3b36f5 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.yaml @@ -109,3 +109,32 @@ members: [person2] output: ms_hmw_resource_eligible: [true, true] + +# 1,843.69 + 2,145.15 + 11.16 = 4,000.00, which the limit excludes. +# The float32 balances add to a fraction of a cent below 4,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit fail + period: 2025 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_843.69 + stock_assets: 2_145.15 + bond_assets: 11.16 + state_code: MS + output: + ms_hmw_resource_eligible: false + +# 1,843.69 + 2,145.15 + 11.15 = 3,999.99, a cent under the limit. +- name: Three accounts a cent under the resource limit pass + period: 2025 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_843.69 + stock_assets: 2_145.15 + bond_assets: 11.15 + state_code: MS + output: + ms_hmw_resource_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.yaml index f883908a09f..8413dc1b1c0 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.yaml @@ -21,3 +21,28 @@ bank_account_assets: 0 output: mt_tanf_resources_eligible: true + +# 798.28 + 2,187.62 + 14.10 = 3,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 3,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.10 + state_code: MT + output: + mt_tanf_resources_eligible: true + +# 798.28 + 2,187.62 + 14.11 = 3,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.11 + state_code: MT + output: + mt_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/dhs/tanf/nd_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/dhs/tanf/nd_tanf_resources_eligible.yaml index 08bf4c5395d..8ed8999c375 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/dhs/tanf/nd_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/dhs/tanf/nd_tanf_resources_eligible.yaml @@ -237,3 +237,28 @@ # Limit: $6,000 + $25 * (10-2) = $6,000 + $200 = $6,200 # $6,200 <= $6,200 = true nd_tanf_resources_eligible: true + +# 798.28 + 2,187.62 + 14.10 = 3,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 3,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.10 + state_code: ND + output: + nd_tanf_resources_eligible: true + +# 798.28 + 2,187.62 + 14.11 = 3,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 798.28 + stock_assets: 2_187.62 + bond_assets: 14.11 + state_code: ND + output: + nd_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ne/dhhs/adc/ne_adc_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ne/dhhs/adc/ne_adc_resources_eligible.yaml index 596d450fe45..28a326e8432 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ne/dhhs/adc/ne_adc_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ne/dhhs/adc/ne_adc_resources_eligible.yaml @@ -84,3 +84,28 @@ spm_unit_size: 2 ne_adc_resources_eligible: false # Resources ($6,001) > Limit ($6,000) -> false + +# 2,286.12 + 404.84 + 1,309.04 = 4,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 4,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025 + input: + age: 30 + bank_account_assets: 2_286.12 + stock_assets: 404.84 + bond_assets: 1_309.04 + state_code: NE + output: + ne_adc_resources_eligible: true + +# 2,286.12 + 404.84 + 1,309.05 = 4,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025 + input: + age: 30 + bank_account_assets: 2_286.12 + stock_assets: 404.84 + bond_assets: 1_309.05 + state_code: NE + output: + ne_adc_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/fanf/nh_fanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/fanf/nh_fanf_resources_eligible.yaml index a64ded75848..8b2eb46310e 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/fanf/nh_fanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/fanf/nh_fanf_resources_eligible.yaml @@ -118,3 +118,28 @@ output: # $1,999 < $2,000 limit = eligible nh_fanf_resources_eligible: true + +# 719.22 + 208.18 + 72.60 = 1,000.00, which the limit excludes. +# The float32 balances add to a fraction of a cent below 1,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit fail + period: 2025 + input: + age: 30 + bank_account_assets: 719.22 + stock_assets: 208.18 + bond_assets: 72.60 + state_code: NH + output: + nh_fanf_resources_eligible: false + +# 719.22 + 208.18 + 72.59 = 999.99, a cent under the limit. +- name: Three accounts a cent under the resource limit pass + period: 2025 + input: + age: 30 + bank_account_assets: 719.22 + stock_assets: 208.18 + bond_assets: 72.59 + state_code: NH + output: + nh_fanf_resources_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/ssp/nh_ssp_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/ssp/nh_ssp_eligible.yaml new file mode 100644 index 00000000000..894d144a8c8 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/nh/dhhs/ssp/nh_ssp_eligible.yaml @@ -0,0 +1,28 @@ +# 285.92 + 1,181.93 + 32.15 = 1,500.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,500 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 285.92 + stock_assets: 1_181.93 + bond_assets: 32.15 + state_code: NH + output: + nh_ssp_eligible: true + +# 285.92 + 1,181.93 + 32.16 = 1,500.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 285.92 + stock_assets: 1_181.93 + bond_assets: 32.16 + state_code: NH + output: + nh_ssp_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/nj/njdhs/wfnj/nj_wfnj_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/nj/njdhs/wfnj/nj_wfnj_resources_eligible.yaml index 6fc296c5bdf..992dcf63659 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nj/njdhs/wfnj/nj_wfnj_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nj/njdhs/wfnj/nj_wfnj_resources_eligible.yaml @@ -21,3 +21,28 @@ spm_unit_cash_assets: 0 output: nj_wfnj_resources_eligible: true + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: NJ + output: + nj_wfnj_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: NJ + output: + nj_wfnj_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.yaml index 13fb0f6fbcd..fcee32c4d3b 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.yaml @@ -36,3 +36,28 @@ # Liquid resources alone can fail the NM Works test even before adding any # future modeled non-liquid countable resources. nm_works_resources_eligible: false + +# 285.92 + 1,181.93 + 32.15 = 1,500.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,500 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 285.92 + stock_assets: 1_181.93 + bond_assets: 32.15 + state_code: NM + output: + nm_works_resources_eligible: true + +# 285.92 + 1,181.93 + 32.16 = 1,500.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 285.92 + stock_assets: 1_181.93 + bond_assets: 32.16 + state_code: NM + output: + nm_works_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.yaml index 9f571c0547d..a8b4ad3b553 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.yaml @@ -24,3 +24,28 @@ spm_unit_cash_assets: 10_001 output: nv_tanf_resources_eligible: false + +# 8,688.73 + 9.74 + 1,301.53 = 10,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 10,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.53 + state_code: NV + output: + nv_tanf_resources_eligible: true + +# 8,688.73 + 9.74 + 1,301.54 = 10,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.54 + state_code: NV + output: + nv_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ny/otda/tanf/ny_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ny/otda/tanf/ny_tanf_resources_eligible.yaml index 5fdaef1d68a..19757c115f5 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ny/otda/tanf/ny_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ny/otda/tanf/ny_tanf_resources_eligible.yaml @@ -171,3 +171,28 @@ # Pre-reform: disability did NOT qualify for higher limit # Uses $2,000 limit, $2,500 > $2,000 → ineligible ny_tanf_resources_eligible: false + +# 2,105.87 + 384.60 + 9.53 = 2,500.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,500 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 2_105.87 + stock_assets: 384.60 + bond_assets: 9.53 + state_code: NY + output: + ny_tanf_resources_eligible: true + +# 2,105.87 + 384.60 + 9.54 = 2,500.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 2_105.87 + stock_assets: 384.60 + bond_assets: 9.54 + state_code: NY + output: + ny_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ok/dhs/tanf/ok_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ok/dhs/tanf/ok_tanf_resources_eligible.yaml index 38583a1f602..cac5d84846c 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ok/dhs/tanf/ok_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ok/dhs/tanf/ok_tanf_resources_eligible.yaml @@ -77,3 +77,28 @@ state_code: OK output: ok_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.90 = 1,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.90 + state_code: OK + output: + ok_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.91 = 1,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.91 + state_code: OK + output: + ok_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/or/odhs/tanf/or_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/or/odhs/tanf/or_tanf_resources_eligible.yaml index 1186d1002bf..98ca066c457 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/or/odhs/tanf/or_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/or/odhs/tanf/or_tanf_resources_eligible.yaml @@ -35,3 +35,28 @@ spm_unit_cash_assets: 10_001 output: or_tanf_resources_eligible: false + +# 8,688.73 + 9.74 + 1,301.53 = 10,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 10,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.53 + state_code: OR + output: + or_tanf_resources_eligible: true + +# 8,688.73 + 9.74 + 1,301.54 = 10,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 8_688.73 + stock_assets: 9.74 + bond_assets: 1_301.54 + state_code: OR + output: + or_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.yaml index a959a2e9858..db07aa1209f 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.yaml @@ -45,3 +45,28 @@ state_code: PA output: pa_tanf_resources_eligible: false + +# 650.46 + 299.64 + 49.90 = 1,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.90 + state_code: PA + output: + pa_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.91 = 1,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.91 + state_code: PA + output: + pa_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ri/dhs/works/ri_works_resource_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ri/dhs/works/ri_works_resource_eligible.yaml index 6c572074ff6..ba661907dce 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ri/dhs/works/ri_works_resource_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ri/dhs/works/ri_works_resource_eligible.yaml @@ -64,3 +64,28 @@ # Limit: $5,000 # $4,999 <= $5,000 = true ri_works_resource_eligible: true + +# 4,211.74 + 769.20 + 19.06 = 5,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 5,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_211.74 + stock_assets: 769.20 + bond_assets: 19.06 + state_code: RI + output: + ri_works_resource_eligible: true + +# 4,211.74 + 769.20 + 19.07 = 5,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_211.74 + stock_assets: 769.20 + bond_assets: 19.07 + state_code: RI + output: + ri_works_resource_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/sc/tanf/sc_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/sc/tanf/sc_tanf_resources_eligible.yaml index ef036df8b90..09d3821e098 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/sc/tanf/sc_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/sc/tanf/sc_tanf_resources_eligible.yaml @@ -34,3 +34,28 @@ output: sc_tanf_resources_eligible: true # 0 <= 2,500 -> eligible + +# 2,105.87 + 384.60 + 9.53 = 2,500.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,500 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 2_105.87 + stock_assets: 384.60 + bond_assets: 9.53 + state_code: SC + output: + sc_tanf_resources_eligible: true + +# 2,105.87 + 384.60 + 9.54 = 2,500.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 2_105.87 + stock_assets: 384.60 + bond_assets: 9.54 + state_code: SC + output: + sc_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.yaml index e26e7dedeb8..dfdcecd592d 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.yaml @@ -102,3 +102,28 @@ # Limit: $2,000 # Eligible: $1,999 <= $2,000 = true sd_tanf_resources_eligible: true + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: SD + output: + sd_tanf_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: SD + output: + sd_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.yaml index a8bd6fe0df9..77d310f3adc 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.yaml @@ -114,3 +114,28 @@ output: # Countable: $3,000 liquid assets + ($6,600 - $4,600 vehicle exclusion) = $5,000 tn_ff_resources_eligible: false + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: TN + output: + tn_ff_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: TN + output: + tn_ff_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.yaml index c3a2135753c..8b11f01a5f2 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.yaml @@ -42,3 +42,28 @@ output: tx_tanf_resources_eligible: true # Resources (0) <= limit (1,000) → Pass + +# 650.46 + 299.64 + 49.90 = 1,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 1,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.90 + state_code: TX + output: + tx_tanf_resources_eligible: true + +# 650.46 + 299.64 + 49.91 = 1,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 650.46 + stock_assets: 299.64 + bond_assets: 49.91 + state_code: TX + output: + tx_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.yaml index f8905ef04be..746a2074200 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.yaml @@ -45,3 +45,28 @@ output: # Resources = 5,000 > 2,000 - ineligible ut_fep_resources_eligible: false + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: UT + output: + ut_fep_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: UT + output: + ut_fep_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/vt/dcf/reach_up/vt_reach_up_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/vt/dcf/reach_up/vt_reach_up_resources_eligible.yaml index 1072da1660a..3e503e86178 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/vt/dcf/reach_up/vt_reach_up_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/vt/dcf/reach_up/vt_reach_up_resources_eligible.yaml @@ -73,3 +73,28 @@ output: # Assets: $9,001 > $9,000 limit vt_reach_up_resources_eligible: false + +# 617.28 + 8,353.98 + 28.74 = 9,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 9,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 617.28 + stock_assets: 8_353.98 + bond_assets: 28.74 + state_code: VT + output: + vt_reach_up_resources_eligible: true + +# 617.28 + 8,353.98 + 28.75 = 9,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 617.28 + stock_assets: 8_353.98 + bond_assets: 28.75 + state_code: VT + output: + vt_reach_up_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.yaml index ee925dfa47f..c14319af143 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.yaml @@ -50,3 +50,28 @@ bank_account_assets: 1_001 output: wa_tanf_resources_eligible: false + +# 8,978.98 + 2,564.81 + 456.21 = 12,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 12,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025 + input: + age: 30 + bank_account_assets: 8_978.98 + stock_assets: 2_564.81 + bond_assets: 456.21 + state_code: WA + output: + wa_tanf_resources_eligible: true + +# 8,978.98 + 2,564.81 + 456.22 = 12,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025 + input: + age: 30 + bank_account_assets: 8_978.98 + stock_assets: 2_564.81 + bond_assets: 456.22 + state_code: WA + output: + wa_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/wi/dcf/works/wi_works_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/wi/dcf/works/wi_works_resources_eligible.yaml index 62907a62354..ee465405121 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/wi/dcf/works/wi_works_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/wi/dcf/works/wi_works_resources_eligible.yaml @@ -36,3 +36,28 @@ state_code: CA output: wi_works_resources_eligible: false + +# 2,105.87 + 384.60 + 9.53 = 2,500.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,500 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025 + input: + age: 30 + bank_account_assets: 2_105.87 + stock_assets: 384.60 + bond_assets: 9.53 + state_code: WI + output: + wi_works_resources_eligible: true + +# 2,105.87 + 384.60 + 9.54 = 2,500.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025 + input: + age: 30 + bank_account_assets: 2_105.87 + stock_assets: 384.60 + bond_assets: 9.54 + state_code: WI + output: + wi_works_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/wv/dhhr/works/wv_works_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/wv/dhhr/works/wv_works_resources_eligible.yaml index 64cb29352e1..16e4e33fab5 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/wv/dhhr/works/wv_works_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/wv/dhhr/works/wv_works_resources_eligible.yaml @@ -50,3 +50,28 @@ spm_unit_cash_assets: 10_000 output: wv_works_resources_eligible: false + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: WV + output: + wv_works_resources_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: WV + output: + wv_works_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/wy/dfs/power/wy_power_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/wy/dfs/power/wy_power_resources_eligible.yaml index e1aeccfbe8d..0f12cd002d9 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/wy/dfs/power/wy_power_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/wy/dfs/power/wy_power_resources_eligible.yaml @@ -34,3 +34,28 @@ spm_unit_cash_assets: 5_001 output: wy_power_resources_eligible: false + +# 4,211.74 + 769.20 + 19.06 = 5,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 5,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_211.74 + stock_assets: 769.20 + bond_assets: 19.06 + state_code: WY + output: + wy_power_resources_eligible: true + +# 4,211.74 + 769.20 + 19.07 = 5,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 4_211.74 + stock_assets: 769.20 + bond_assets: 19.07 + state_code: WY + output: + wy_power_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/meets_snap_asset_test.yaml b/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/meets_snap_asset_test.yaml index 58a3ceb5d15..2367a19f859 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/meets_snap_asset_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/meets_snap_asset_test.yaml @@ -78,3 +78,26 @@ # $4,000 is between the $3,000 standard and $4,500 elderly/disabled # limits, and the eligible elderly member confers the higher limit. meets_snap_asset_test: true + +# 7 U.S.C. 2014(g)(1): 2,607.87 + 29.87 + 362.26 = 3,000.00, at the FY2025 +# standard limit. The float32 balances add to 3,000.0002 unless rounded. +- name: Three accounts that total exactly the standard limit pass + period: 2025-01 + input: + age: 30 + bank_account_assets: 2_607.87 + stock_assets: 29.87 + bond_assets: 362.26 + output: + meets_snap_asset_test: true + +# 2,607.87 + 29.87 + 362.27 = 3,000.01, a cent over the limit. +- name: Three accounts a cent over the standard limit fail + period: 2025-01 + input: + age: 30 + bank_account_assets: 2_607.87 + stock_assets: 29.87 + bond_assets: 362.27 + output: + meets_snap_asset_test: false diff --git a/policyengine_us/tests/unit/test_round_to_cents_properties.py b/policyengine_us/tests/unit/test_round_to_cents_properties.py new file mode 100644 index 00000000000..415fd6d7fb5 --- /dev/null +++ b/policyengine_us/tests/unit/test_round_to_cents_properties.py @@ -0,0 +1,121 @@ +"""Hypothesis checks that splitting a total into cents doesn't change a limit test. + +Account balances are stored as float32, so three balances that add to a limit +in cents can sum a fraction of a cent above or below it. Asset tests round the +sum to cents before comparing it with the limit (``round_to_cents``). + +The first property checks the helper alone, without a model, on both ways +the model sums inputs: float32 addition within one entity, and a float64 sum +cast back to float32 when person inputs are added up to a group entity. + +The second property runs the model. Each example is one situation of +single-person households. Each household splits a total at, a cent below or +a cent above the SSI and SNAP limits among bank, stock and bond assets, and +its result must match the result for the same total held in one account. +Hypothesis is a dev extra, so this module skips without it. +""" + +import numpy as np +import pytest + +from policyengine_us import Simulation +from policyengine_us.tools.general import round_to_cents + +hypothesis = pytest.importorskip("hypothesis") +st = pytest.importorskip("hypothesis.strategies") + +ACCOUNTS = ("bank_account_assets", "stock_assets", "bond_assets") + +# Three float32 parts and two float32 additions each err by at most half a +# unit in the last place of the total. Below 2**14 dollars that unit is at +# most 2**-10, so the sum stays within 5 / 2**11 < 0.005 of the total. +MAX_CENTS = 2**14 * 100 - 1 + + +@st.composite +def cent_split(draw, total_cents): + """Three whole-cent parts that add to total_cents.""" + cuts = sorted(draw(st.integers(0, total_cents)) for _ in range(2)) + return (cuts[0], cuts[1] - cuts[0], total_cents - cuts[1]) + + +@st.composite +def total_and_split(draw): + total = draw(st.integers(0, MAX_CENTS)) + return total, draw(cent_split(total)) + + +@hypothesis.settings(max_examples=2_000, deadline=None) +@hypothesis.given(total_and_split()) +def test_rounded_sum_of_float32_parts_is_the_total(case): + total, parts = case + values = [np.float32(part / 100) for part in parts] + # Float32 addition, as a formula adding one entity's own inputs. + float32_sum = values[0] + values[1] + values[2] + # A float64 sum stored as float32, as an aggregate to a group entity. + float64_sum = np.float32(sum(float(value) for value in values)) + for amount in (float32_sum, float64_sum): + assert round_to_cents(amount) == total / 100 + + +YEAR = 2026 +# 20 CFR 416.1205: the individual limit is 2,000. Everyone is 70, so SNAP +# applies its FY2026 limit for households with an elderly member, 4,500 +# (7 U.S.C. 2014(g)(1)). +LIMITS = {"meets_ssi_resource_test": 2_000, "meets_snap_asset_test": 4_500} + + +@st.composite +def household(draw): + test = draw(st.sampled_from(sorted(LIMITS))) + total = LIMITS[test] * 100 + draw(st.sampled_from([-1, 0, 1])) + return test, draw(cent_split(total)) + + +def build_situation(households): + people = {} + groups = {} + for i, (_, parts) in enumerate(households): + for split in (False, True): + name = f"h{i}_{'split' if split else 'whole'}" + amounts = parts if split else (sum(parts), 0, 0) + person = { + "age": {YEAR: 70}, + "is_ssi_aged_blind_disabled": {YEAR: True}, + } + for account, cents in zip(ACCOUNTS, amounts): + person[account] = {YEAR: cents / 100} + people[name] = person + groups[name] = {"members": [name]} + return { + "people": people, + **{ + entity: groups + for entity in ( + "tax_units", + "spm_units", + "families", + "marital_units", + "households", + ) + }, + } + + +@hypothesis.settings( + max_examples=10, + deadline=None, + suppress_health_check=[ + hypothesis.HealthCheck.too_slow, + hypothesis.HealthCheck.data_too_large, + ], +) +@hypothesis.given(st.lists(household(), min_size=1, max_size=20)) +def test_split_accounts_match_one_account(households): + simulation = Simulation(situation=build_situation(households)) + period = f"{YEAR}-01" + results = {test: np.asarray(simulation.calculate(test, period)) for test in LIMITS} + # People alternate whole, split, so each person's group holds only them. + for i, (test, parts) in enumerate(households): + whole, split = results[test][2 * i], results[test][2 * i + 1] + assert split == whole, (test, parts) diff --git a/policyengine_us/tools/general.py b/policyengine_us/tools/general.py index 7afc7860fd7..5c031eb37ec 100644 --- a/policyengine_us/tools/general.py +++ b/policyengine_us/tools/general.py @@ -14,6 +14,20 @@ USD = "currency-USD" +def round_to_cents(amount): + """Round a dollar amount to whole cents, as a float64 array. + + Inputs are stored as float32, which holds most cent amounts only + approximately. A sum of several of them can land a fraction of a cent + above or below the whole-cent total they represent: three balances + entered as 178.57, 1,547.79 and 273.64 add to 2,000.0001 in float32. + Rounding the sum before an exact-limit comparison compares the total the + inputs represent, so a split of a total among accounts or people passes + or fails the limit as the total does. + """ + return np.round(np.asarray(amount, dtype=np.float64), 2) + + def has_input_for_period(simulation, variable, period): """Whether the visible array for this exact period was set as an input. diff --git a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/is_optional_senior_or_disabled_asset_eligible.py b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/is_optional_senior_or_disabled_asset_eligible.py index b4745bda5ad..c09be4d4c19 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/is_optional_senior_or_disabled_asset_eligible.py +++ b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/is_optional_senior_or_disabled_asset_eligible.py @@ -19,7 +19,7 @@ def formula(person, period, parameters): # the individual or the married couple, not the tax filing unit. personal_assets = person("ssi_countable_resources", period) # $ # Inputs are stored as float32, so compare whole cents with the limit. - assets = np.round(person.marital_unit.sum(personal_assets), 2) + assets = round_to_cents(person.marital_unit.sum(personal_assets)) is_couple = person.marital_unit.nb_persons() == 2 state = person.household("state_code_str", period) diff --git a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py index 633c16213f9..54fa24bdece 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py +++ b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py @@ -57,7 +57,8 @@ def formula(person, period, parameters): income = marital_unit.sum( personal_income - medical_expenses - parental_expense_share ) - assets = marital_unit.sum(personal_assets) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(marital_unit.sum(personal_assets)) ma = parameters(period).gov.hhs.medicaid mn = ma.eligibility.categories.medically_needy is_joint = marital_unit.nb_persons() == 2 diff --git a/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py b/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py index 98455cb905b..c0fa8859dd2 100644 --- a/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py +++ b/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py @@ -24,10 +24,13 @@ def formula(person, period, parameters): # If asset test doesn't apply, everyone is asset-eligible personal_resources = person("ssi_countable_resources", period.this_year) married = person.spm_unit("spm_unit_is_married", period.this_year) - countable_resources = where( - married, - person.marital_unit.sum(personal_resources), - personal_resources, + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + where( + married, + person.marital_unit.sum(personal_resources), + personal_resources, + ) ) # States may set a higher limit than the federal one, never a lower one. state_limit = p.asset.state_limit diff --git a/policyengine_us/variables/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.py b/policyengine_us/variables/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.py index 7cfb1a7e15c..bd326fec4e4 100644 --- a/policyengine_us/variables/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.py +++ b/policyengine_us/variables/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.py @@ -24,6 +24,7 @@ def formula(spm_unit, period, parameters): 0, ) tx_vehicle_value = max_(vehicle_value - vehicle_exemption, 0) - assets = assets + where(state == "TX", tx_vehicle_value, 0) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(assets + where(state == "TX", tx_vehicle_value, 0)) asset_limit = limits.asset_limit[state] return assets <= asset_limit diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py index 2c0a1f658dd..0b9fe1dec7c 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py @@ -120,11 +120,12 @@ def formula(person, period, parameters): # 'only to the extent that those resources exceed the resource limits # described in § 416.1205': use the reformable individual/couple limits. allowance = where(parent_count > 1, p.couple, p.individual) - excess = max_(0, parental_resources - allowance) + # Inputs are stored as float32, so compare whole cents with the limits. + excess = max_(0, round_to_cents(parental_resources) - allowance) # Do not discard ABD parents. SI 01330.310 B-C says zero if parent(s) # meets resource eligibility, usual deeming if not. The Ryder example # (.340) has an ABD mother failing the couple limit: 3100-3000=100. - own_resources = person("ssi_countable_resources", period) + own_resources = round_to_cents(person("ssi_countable_resources", period)) active = person("is_ssi_resource_deeming_child", period) & ( own_resources <= p.individual ) @@ -150,7 +151,7 @@ def formula(person, period, parameters): count = np.bincount(pool[active & income_eligible], minlength=pool_count) share = excess / max_(1, count[pool]) deemed = where(active, share, deemed) - remaining = active & (own_resources + share <= p.individual) + remaining = active & (round_to_cents(own_resources + share) <= p.individual) if np.array_equal(active, remaining): break active = remaining diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py index 8a593952788..6c789f8c52d 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py @@ -25,10 +25,13 @@ def formula(person, period, parameters): "ssi_resources_deemed_from_ineligible_parent", ], ) - countable_resources = where( - joint_claim, - person.marital_unit.sum(personal_resources), - personal_resources + deemed_resources, + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + where( + joint_claim, + person.marital_unit.sum(personal_resources), + personal_resources + deemed_resources, + ) ) # 416.1205(a): an individual living with an ineligible spouse counts # 'including the resources of the spouse' against the spouse limit. diff --git a/policyengine_us/variables/gov/states/ak/dpa/atap/eligibility/ak_atap_resources_eligible.py b/policyengine_us/variables/gov/states/ak/dpa/atap/eligibility/ak_atap_resources_eligible.py index 34b4fd788d9..b352a28ccb2 100644 --- a/policyengine_us/variables/gov/states/ak/dpa/atap/eligibility/ak_atap_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ak/dpa/atap/eligibility/ak_atap_resources_eligible.py @@ -14,7 +14,8 @@ class ak_atap_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ak.dpa.atap.resource_limit - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) # Higher limit if household has elderly member (age 60+) person = spm_unit.members diff --git a/policyengine_us/variables/gov/states/ar/dhs/tea/eligibility/ar_tea_resources_eligible.py b/policyengine_us/variables/gov/states/ar/dhs/tea/eligibility/ar_tea_resources_eligible.py index a9dd2f42819..3d6ecda781d 100644 --- a/policyengine_us/variables/gov/states/ar/dhs/tea/eligibility/ar_tea_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ar/dhs/tea/eligibility/ar_tea_resources_eligible.py @@ -15,5 +15,6 @@ def formula(spm_unit, period, parameters): # Per 208.00.13 Ark. Code R. Section 001, Section 3.4 p = parameters(period).gov.states.ar.dhs.tea.resources # Use federal asset calculation for SPM unit - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/states/az/hhs/tanf/eligibility/az_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/az/hhs/tanf/eligibility/az_tanf_resources_eligible.py index 4cdea6416b5..d7b36d6b804 100644 --- a/policyengine_us/variables/gov/states/az/hhs/tanf/eligibility/az_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/az/hhs/tanf/eligibility/az_tanf_resources_eligible.py @@ -13,5 +13,6 @@ class az_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.az.hhs.tanf.resources - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.py b/policyengine_us/variables/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.py index 89ba309b6b7..af80f3980bc 100644 --- a/policyengine_us/variables/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.py +++ b/policyengine_us/variables/gov/states/ca/cdss/capi/eligibility/ca_capi_resource_eligible.py @@ -10,7 +10,8 @@ class ca_capi_resource_eligible(Variable): reference = "https://www.cdss.ca.gov/Portals/9/CAPI/CAPI_Regulations-Accessible.pdf" def formula(spm_unit, period, parameters): - resources = spm_unit("ca_capi_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("ca_capi_resources", period)) p = parameters(period).gov.states.ca.cdss.capi.resources married = spm_unit("spm_unit_is_married", period) resource_limit = where(married, p.limit.couple, p.limit.single) diff --git a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py index 5d9e562ce4c..9eb4dbcb247 100644 --- a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py +++ b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py @@ -9,7 +9,8 @@ class co_oap_eligible(Variable): defined_for = StateCode.CO def formula(person, period, parameters): - assets = person("ssi_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(person("ssi_countable_resources", period)) joint_claim = person("ssi_claim_is_joint", period) p = parameters(period).gov.states.co.ssa.oap asset_limit = where(joint_claim, p.resources.couple, p.resources.single) diff --git a/policyengine_us/variables/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.py b/policyengine_us/variables/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.py index f4e5cf330f0..97ad8dfea5b 100644 --- a/policyengine_us/variables/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.py +++ b/policyengine_us/variables/gov/states/ct/dss/ssp/eligibility/ct_ssp_resource_eligible.py @@ -35,4 +35,5 @@ def formula(person, period, parameters): p.asset_limit.couple, p.asset_limit.individual, ) - return resources <= limit + # Inputs are stored as float32, so compare whole cents with the limit. + return round_to_cents(resources) <= limit diff --git a/policyengine_us/variables/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.py b/policyengine_us/variables/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.py index 5b6de4508de..379336c8115 100644 --- a/policyengine_us/variables/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ct/dss/tfa/eligibility/ct_tfa_resources_eligible.py @@ -13,5 +13,6 @@ class ct_tfa_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ct.dss.tfa.resource - assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return assets <= p.limit diff --git a/policyengine_us/variables/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.py index d69a7d04eaf..37b07a2aa2c 100644 --- a/policyengine_us/variables/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/dc/dhs/tanf/eligibility/dc_tanf_resources_eligible.py @@ -24,5 +24,8 @@ def formula(spm_unit, period, parameters): p.higher.amount, p.lower.amount, ) - countable_resources = spm_unit("dc_tanf_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("dc_tanf_countable_resources", period) + ) return countable_resources <= resource_limit diff --git a/policyengine_us/variables/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.py index 97c1189e3b9..692ba24d48a 100644 --- a/policyengine_us/variables/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/de/dhss/tanf/eligibility/de_tanf_resources_eligible.py @@ -12,6 +12,7 @@ class de_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): # Per DSSM 4002: Resource limit is $10,000 p = parameters(period).gov.states.de.dhss.tanf - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.resource_limit diff --git a/policyengine_us/variables/gov/states/fl/dcf/tanf/eligibility/fl_tca_resources_eligible.py b/policyengine_us/variables/gov/states/fl/dcf/tanf/eligibility/fl_tca_resources_eligible.py index 1be15ff8877..58cbc2d93e7 100644 --- a/policyengine_us/variables/gov/states/fl/dcf/tanf/eligibility/fl_tca_resources_eligible.py +++ b/policyengine_us/variables/gov/states/fl/dcf/tanf/eligibility/fl_tca_resources_eligible.py @@ -15,5 +15,6 @@ class fl_tca_resources_eligible(Variable): def formula(spm_unit, period, parameters): # Per Florida DCF: Countable assets must be <= $2,000 p = parameters(period).gov.states.fl.dcf.tanf.resources - assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return assets <= p.asset_limit diff --git a/policyengine_us/variables/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.py index a15e7b7049c..5d7e01e7b23 100644 --- a/policyengine_us/variables/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ga/dfcs/tanf/eligibility/ga_tanf_resources_eligible.py @@ -18,5 +18,6 @@ def formula(spm_unit, period, parameters): # In a more complete implementation, this would account for # excluded resources (primary residence, household goods, etc.) # and vehicle value limits - cash_assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + cash_assets = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return cash_assets <= p.limit diff --git a/policyengine_us/variables/gov/states/ia/dhs/fip/eligibility/ia_fip_resources_eligible.py b/policyengine_us/variables/gov/states/ia/dhs/fip/eligibility/ia_fip_resources_eligible.py index 5db0c542a5b..fb075e93bb7 100644 --- a/policyengine_us/variables/gov/states/ia/dhs/fip/eligibility/ia_fip_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ia/dhs/fip/eligibility/ia_fip_resources_eligible.py @@ -19,5 +19,6 @@ def formula(spm_unit, period, parameters): p.recipient_limit, p.applicant_limit, ) - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= limit diff --git a/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py b/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py index 9bdb207b59b..c04e6fad062 100644 --- a/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py +++ b/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py @@ -44,6 +44,8 @@ def formula(person, period, parameters): ) resource = where(couple, person.marital_unit.sum(resource), resource) resource = resource + person("ia_ssa_resources_deemed_from_parents", period) + # Inputs are stored as float32, so compare whole cents with the limit. + resource = round_to_cents(resource) # 6-B Resources prints "$2,000 for an individual" and "$3,000 for a # married couple living together" under 20 CFR 416.1202; these equal # the SSI limits of 20 CFR 416.1205, so the federal parameters are used diff --git a/policyengine_us/variables/gov/states/id/tafi/eligibility/id_tafi_resources_eligible.py b/policyengine_us/variables/gov/states/id/tafi/eligibility/id_tafi_resources_eligible.py index f348121d4c0..41902b707e1 100644 --- a/policyengine_us/variables/gov/states/id/tafi/eligibility/id_tafi_resources_eligible.py +++ b/policyengine_us/variables/gov/states/id/tafi/eligibility/id_tafi_resources_eligible.py @@ -12,5 +12,6 @@ class id_tafi_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.id.tafi.resources # Per IDAPA 16.03.08.200: Resources must not exceed $5,000 - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/states/in/fssa/tanf/eligibility/in_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/in/fssa/tanf/eligibility/in_tanf_resources_eligible.py index bf033a68739..621ec6ead8e 100644 --- a/policyengine_us/variables/gov/states/in/fssa/tanf/eligibility/in_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/in/fssa/tanf/eligibility/in_tanf_resources_eligible.py @@ -14,7 +14,8 @@ class in_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states["in"].fssa.tanf.resources.limit - countable = spm_unit("in_tanf_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable = round_to_cents(spm_unit("in_tanf_countable_resources", period)) is_enrolled = spm_unit("is_tanf_enrolled", period) limit = where( diff --git a/policyengine_us/variables/gov/states/ks/dcf/tanf/eligibility/ks_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/ks/dcf/tanf/eligibility/ks_tanf_resources_eligible.py index 8fcc8858c32..87b2e17eaf5 100644 --- a/policyengine_us/variables/gov/states/ks/dcf/tanf/eligibility/ks_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ks/dcf/tanf/eligibility/ks_tanf_resources_eligible.py @@ -15,5 +15,6 @@ class ks_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): # Per KEESM 5110: Resource limit is $3,000 p = parameters(period).gov.states.ks.dcf.tanf.resource_limit - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.amount diff --git a/policyengine_us/variables/gov/states/ky/dcbs/ktap/eligibility/ky_ktap_resource_eligible.py b/policyengine_us/variables/gov/states/ky/dcbs/ktap/eligibility/ky_ktap_resource_eligible.py index e73597c2678..6dc029862af 100644 --- a/policyengine_us/variables/gov/states/ky/dcbs/ktap/eligibility/ky_ktap_resource_eligible.py +++ b/policyengine_us/variables/gov/states/ky/dcbs/ktap/eligibility/ky_ktap_resource_eligible.py @@ -11,5 +11,6 @@ class ky_ktap_resource_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ky.dcbs.ktap.eligibility - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.resource_limit diff --git a/policyengine_us/variables/gov/states/me/dhhs/tanf/eligibility/me_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/me/dhhs/tanf/eligibility/me_tanf_resources_eligible.py index 64f0dd1b647..651e4499b58 100644 --- a/policyengine_us/variables/gov/states/me/dhhs/tanf/eligibility/me_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/me/dhhs/tanf/eligibility/me_tanf_resources_eligible.py @@ -17,5 +17,8 @@ def formula(spm_unit, period, parameters): # Resource limit is $10,000 per family # One vehicle per licensed driver is exempt p = parameters(period).gov.states.me.dhhs.tanf - countable_resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("spm_unit_cash_assets", period.this_year) + ) return countable_resources <= p.resource_limit diff --git a/policyengine_us/variables/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.py b/policyengine_us/variables/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.py index f779f24d077..622cc1efd5a 100644 --- a/policyengine_us/variables/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.py +++ b/policyengine_us/variables/gov/states/mi/mdhhs/fip/eligibility/mi_fip_resources_eligible.py @@ -17,6 +17,7 @@ def formula(spm_unit, period, parameters): # Count liquid financial assets explicitly. BEM 400 excludes several # non-liquid resources that are not yet modeled separately here. - assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return assets <= p.resources.limit diff --git a/policyengine_us/variables/gov/states/mn/dcyf/mfip/eligibility/mn_mfip_resources_eligible.py b/policyengine_us/variables/gov/states/mn/dcyf/mfip/eligibility/mn_mfip_resources_eligible.py index df1826a132e..b23c3a1da1a 100644 --- a/policyengine_us/variables/gov/states/mn/dcyf/mfip/eligibility/mn_mfip_resources_eligible.py +++ b/policyengine_us/variables/gov/states/mn/dcyf/mfip/eligibility/mn_mfip_resources_eligible.py @@ -13,5 +13,6 @@ def formula(spm_unit, period, parameters): # Per MN Stat. 256P.02, Subd. 2: # Assets must not exceed $10,000. p = parameters(period).gov.states.mn.dcyf.mfip.resources - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.py b/policyengine_us/variables/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.py index dcbab010738..98379d99009 100644 --- a/policyengine_us/variables/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.py +++ b/policyengine_us/variables/gov/states/mn/dhs/msa/eligibility/mn_msa_resource_eligible.py @@ -25,5 +25,6 @@ def formula(person, period, parameters): p = parameters(period).gov.states.mn.dhs.msa.eligibility receives_ssi = (person("ssi", period) > 0) | person("receives_ssi", period) countable_resources = person("ssi_countable_resources", period.this_year) - unit_resources = person.marital_unit.sum(countable_resources) + # Inputs are stored as float32, so compare whole cents with the limit. + unit_resources = round_to_cents(person.marital_unit.sum(countable_resources)) return receives_ssi | (unit_resources <= p.asset_limit.non_ssi_track) diff --git a/policyengine_us/variables/gov/states/mo/dss/tanf/eligibility/mo_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/mo/dss/tanf/eligibility/mo_tanf_resources_eligible.py index 29a469b49b0..9c0cee65722 100644 --- a/policyengine_us/variables/gov/states/mo/dss/tanf/eligibility/mo_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/mo/dss/tanf/eligibility/mo_tanf_resources_eligible.py @@ -20,5 +20,6 @@ def formula(spm_unit, period, parameters): # pact"); IEP participation is not observable, so the $1,000 limit # applies to all units. p = parameters(period).gov.states.mo.dss.tanf.resource_limit - resources = spm_unit("mo_tanf_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("mo_tanf_countable_resources", period)) return resources <= p.amount diff --git a/policyengine_us/variables/gov/states/ms/dhs/tanf/eligibility/ms_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/ms/dhs/tanf/eligibility/ms_tanf_resources_eligible.py index 337e0289112..d469c4e8bbb 100644 --- a/policyengine_us/variables/gov/states/ms/dhs/tanf/eligibility/ms_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ms/dhs/tanf/eligibility/ms_tanf_resources_eligible.py @@ -15,5 +15,8 @@ class ms_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ms.dhs.tanf.resources - household_assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + household_assets = round_to_cents( + spm_unit("spm_unit_cash_assets", period.this_year) + ) return household_assets <= p.limit diff --git a/policyengine_us/variables/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.py b/policyengine_us/variables/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.py index 8cf9b04ed93..edb83ae7be6 100644 --- a/policyengine_us/variables/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.py +++ b/policyengine_us/variables/gov/states/ms/dom/hmw/eligibility/ms_hmw_resource_eligible.py @@ -23,4 +23,5 @@ def formula(person, period, parameters): personal_resources, ) p = parameters(period).gov.states.ms.dom.hmw.resources.limit - return resources < where(couple, p.couple, p.individual) + # Inputs are stored as float32, so compare whole cents with the limit. + return round_to_cents(resources) < where(couple, p.couple, p.individual) diff --git a/policyengine_us/variables/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.py index d05fd7d9d16..cb4dcd924f6 100644 --- a/policyengine_us/variables/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/mt/dhs/tanf/eligibility/mt_tanf_resources_eligible.py @@ -11,5 +11,8 @@ class mt_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.mt.dhs.tanf.resource_limit - countable_resources = spm_unit("mt_tanf_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("mt_tanf_countable_resources", period) + ) return countable_resources <= p.amount diff --git a/policyengine_us/variables/gov/states/nd/dhs/tanf/eligibility/nd_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/nd/dhs/tanf/eligibility/nd_tanf_resources_eligible.py index cba07aa9691..d8630342090 100644 --- a/policyengine_us/variables/gov/states/nd/dhs/tanf/eligibility/nd_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/nd/dhs/tanf/eligibility/nd_tanf_resources_eligible.py @@ -11,7 +11,8 @@ class nd_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.nd.dhs.tanf.resources.limit - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) unit_size = spm_unit("spm_unit_size", period.this_year) capped_size = min_(unit_size, 2) base_limit = p.base[capped_size] diff --git a/policyengine_us/variables/gov/states/ne/dhhs/adc/eligibility/ne_adc_resources_eligible.py b/policyengine_us/variables/gov/states/ne/dhhs/adc/eligibility/ne_adc_resources_eligible.py index d2a5813e246..e57f9d19eca 100644 --- a/policyengine_us/variables/gov/states/ne/dhhs/adc/eligibility/ne_adc_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ne/dhhs/adc/eligibility/ne_adc_resources_eligible.py @@ -15,7 +15,8 @@ class ne_adc_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ne.dhhs.adc # Count explicitly modeled liquid financial assets. - countable_resources = spm_unit("spm_unit_cash_assets", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents(spm_unit("spm_unit_cash_assets", period)) size = spm_unit("spm_unit_size", period) # Resource limits: $4,000 for 1 person, $6,000 for 2+ persons limit = p.resources.limit.calc(size) diff --git a/policyengine_us/variables/gov/states/nh/dhhs/fanf/eligibility/nh_fanf_resources_eligible.py b/policyengine_us/variables/gov/states/nh/dhhs/fanf/eligibility/nh_fanf_resources_eligible.py index 4494d90ee00..b586b9bacea 100644 --- a/policyengine_us/variables/gov/states/nh/dhhs/fanf/eligibility/nh_fanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/nh/dhhs/fanf/eligibility/nh_fanf_resources_eligible.py @@ -19,7 +19,8 @@ def formula(spm_unit, period, parameters): # NOTE: One vehicle per adult is excluded regardless of value. # Resource limits differ for applicants ($1,000) vs recipients ($5,000 as of 07/01/22) p = parameters(period).gov.states.nh.dhhs.fanf.resources - resources = spm_unit("spm_unit_cash_assets", period) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period)) # He-W 656.06(a)(1) also treats an applicant who received FANF in any # one of the previous 6 months as a recipient. The inputs have no # 6-month look-back, so current enrollment stands in for it. diff --git a/policyengine_us/variables/gov/states/nh/dhhs/ssp/nh_ssp_eligible.py b/policyengine_us/variables/gov/states/nh/dhhs/ssp/nh_ssp_eligible.py index 4ba8532fe3f..b931c4de3d6 100644 --- a/policyengine_us/variables/gov/states/nh/dhhs/ssp/nh_ssp_eligible.py +++ b/policyengine_us/variables/gov/states/nh/dhhs/ssp/nh_ssp_eligible.py @@ -42,6 +42,8 @@ def formula(person, period, parameters): resources = resources + essential * max_( essential_resources, spouse_value(essential_resources, spouse) ) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(resources) # He-W 616.02(a): qualified aliens under 8 USC 1641(b) are eligible once # the waiting period since entry has elapsed, which also covers entry # before August 22, 1996. AAM 305.11 exempts the listed statuses, as diff --git a/policyengine_us/variables/gov/states/nj/njdhs/wfnj/eligibility/nj_wfnj_resources_eligible.py b/policyengine_us/variables/gov/states/nj/njdhs/wfnj/eligibility/nj_wfnj_resources_eligible.py index 52729d916fb..0933ef6c5f7 100644 --- a/policyengine_us/variables/gov/states/nj/njdhs/wfnj/eligibility/nj_wfnj_resources_eligible.py +++ b/policyengine_us/variables/gov/states/nj/njdhs/wfnj/eligibility/nj_wfnj_resources_eligible.py @@ -11,5 +11,6 @@ class nj_wfnj_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.nj.njdhs.wfnj.resources - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.py b/policyengine_us/variables/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.py index ea5843c25d3..e41f1d96fad 100644 --- a/policyengine_us/variables/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.py +++ b/policyengine_us/variables/gov/states/nm/hca/nm_works/eligibility/nm_works_resources_eligible.py @@ -11,7 +11,10 @@ class nm_works_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.nm.hca.nm_works.resources.limit - liquid_resources = spm_unit("nm_works_countable_liquid_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + liquid_resources = round_to_cents( + spm_unit("nm_works_countable_liquid_resources", period) + ) non_liquid_resources = spm_unit( "nm_works_countable_non_liquid_resources", period ) diff --git a/policyengine_us/variables/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.py index aa7c78bfff2..6c6f08ff330 100644 --- a/policyengine_us/variables/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/nv/dwss/tanf/eligibility/nv_tanf_resources_eligible.py @@ -14,5 +14,6 @@ def formula(spm_unit, period, parameters): # Nevada excludes the home and up to two vehicles, so use liquid # financial assets explicitly until those vehicle exclusions are # modeled separately. - assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return assets <= p.amount diff --git a/policyengine_us/variables/gov/states/ny/otda/tanf/eligibility/ny_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/ny/otda/tanf/eligibility/ny_tanf_resources_eligible.py index 8a5ee8a8fd0..56c2e4af153 100644 --- a/policyengine_us/variables/gov/states/ny/otda/tanf/eligibility/ny_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ny/otda/tanf/eligibility/ny_tanf_resources_eligible.py @@ -34,5 +34,6 @@ def formula(spm_unit, period, parameters): p.resource_limit.higher.amount, p.resource_limit.lower.amount, ) - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= resource_limit diff --git a/policyengine_us/variables/gov/states/ok/dhs/tanf/eligibility/ok_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/ok/dhs/tanf/eligibility/ok_tanf_resources_eligible.py index 5b29e7bdfb2..0952aef98e3 100644 --- a/policyengine_us/variables/gov/states/ok/dhs/tanf/eligibility/ok_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ok/dhs/tanf/eligibility/ok_tanf_resources_eligible.py @@ -14,5 +14,6 @@ class ok_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ok.dhs.tanf.resources # Per OAC 340:10-3-5: Maximum countable reserve is $1,000 - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/states/or/odhs/tanf/eligibility/or_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/or/odhs/tanf/eligibility/or_tanf_resources_eligible.py index 58f51d3a206..be74e18548a 100644 --- a/policyengine_us/variables/gov/states/or/odhs/tanf/eligibility/or_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/or/odhs/tanf/eligibility/or_tanf_resources_eligible.py @@ -15,5 +15,8 @@ class or_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states["or"].odhs.tanf.resources.limit # Count explicitly modeled liquid financial assets. - countable_resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("spm_unit_cash_assets", period.this_year) + ) return countable_resources <= p.amount diff --git a/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py index fb86153e9de..61a88c49e66 100644 --- a/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py @@ -12,6 +12,10 @@ class pa_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.pa.dhs.tanf - household_assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + + household_assets = round_to_cents( + spm_unit("spm_unit_cash_assets", period.this_year) + ) return household_assets <= p.resource_limit diff --git a/policyengine_us/variables/gov/states/ri/dhs/works/eligibility/ri_works_resource_eligible.py b/policyengine_us/variables/gov/states/ri/dhs/works/eligibility/ri_works_resource_eligible.py index 94ed47b2733..bb5033b466b 100644 --- a/policyengine_us/variables/gov/states/ri/dhs/works/eligibility/ri_works_resource_eligible.py +++ b/policyengine_us/variables/gov/states/ri/dhs/works/eligibility/ri_works_resource_eligible.py @@ -14,5 +14,6 @@ class ri_works_resource_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ri.dhs.works - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.resource_limit diff --git a/policyengine_us/variables/gov/states/sc/tanf/eligibility/sc_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/sc/tanf/eligibility/sc_tanf_resources_eligible.py index 1e6c3f92bac..83f72782efc 100644 --- a/policyengine_us/variables/gov/states/sc/tanf/eligibility/sc_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/sc/tanf/eligibility/sc_tanf_resources_eligible.py @@ -11,5 +11,6 @@ class sc_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.sc.tanf.resources - assets = spm_unit("sc_tanf_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("sc_tanf_countable_resources", period)) return assets <= p.limit diff --git a/policyengine_us/variables/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.py index 4aa8067f568..2a0feb13035 100644 --- a/policyengine_us/variables/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/sd/dss/tanf/eligibility/sd_tanf_resources_eligible.py @@ -11,5 +11,6 @@ class sd_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.sd.dss.tanf.resources - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.py b/policyengine_us/variables/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.py index 023b4003ece..aba97c3046c 100644 --- a/policyengine_us/variables/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.py +++ b/policyengine_us/variables/gov/states/tn/dhs/ff/eligibility/tn_ff_resources_eligible.py @@ -10,6 +10,9 @@ class tn_ff_resources_eligible(Variable): defined_for = StateCode.TN def formula(spm_unit, period, parameters): - countable_resources = spm_unit("tn_ff_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("tn_ff_countable_resources", period) + ) p = parameters(period).gov.states.tn.dhs.ff.resources return countable_resources <= p.limit diff --git a/policyengine_us/variables/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.py index 65248230bf3..e438cc96097 100644 --- a/policyengine_us/variables/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/tx/tanf/eligibility/tx_tanf_resources_eligible.py @@ -13,7 +13,10 @@ class tx_tanf_resources_eligible(Variable): defined_for = StateCode.TX def formula(spm_unit, period, parameters): - countable_resources = spm_unit("tx_tanf_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("tx_tanf_countable_resources", period) + ) p = parameters(period).gov.states.tx.tanf.resources return countable_resources <= p.resource_limit diff --git a/policyengine_us/variables/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.py b/policyengine_us/variables/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.py index d4404c00f8e..d08d1e7a029 100644 --- a/policyengine_us/variables/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ut/dwf/fep/eligibility/ut_fep_resources_eligible.py @@ -15,5 +15,6 @@ def formula(spm_unit, period, parameters): p = parameters(period).gov.states.ut.dwf.fep.resources.limit # Count liquid financial assets explicitly; other excluded resources # are not yet modeled separately here. - assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return assets <= p.amount diff --git a/policyengine_us/variables/gov/states/vt/dcf/reach_up/eligibility/vt_reach_up_resources_eligible.py b/policyengine_us/variables/gov/states/vt/dcf/reach_up/eligibility/vt_reach_up_resources_eligible.py index b0f625dc3f8..5dacf52526e 100644 --- a/policyengine_us/variables/gov/states/vt/dcf/reach_up/eligibility/vt_reach_up_resources_eligible.py +++ b/policyengine_us/variables/gov/states/vt/dcf/reach_up/eligibility/vt_reach_up_resources_eligible.py @@ -14,5 +14,6 @@ def formula(spm_unit, period, parameters): p = parameters(period).gov.states.vt.dcf.reach_up.resources # NOTE: Many exclusions exist (vehicles, retirement accounts, etc.) # that are not separately tracked in PolicyEngine - assets = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return assets <= p.limit diff --git a/policyengine_us/variables/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.py index 984fd596db5..ab86366a75e 100644 --- a/policyengine_us/variables/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/wa/dshs/tanf/wa_tanf_resources_eligible.py @@ -11,5 +11,8 @@ class wa_tanf_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.wa.dshs.tanf - countable_resources = spm_unit("wa_tanf_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("wa_tanf_countable_resources", period) + ) return countable_resources <= p.resource_limit diff --git a/policyengine_us/variables/gov/states/wi/dcf/works/eligibility/wi_works_resources_eligible.py b/policyengine_us/variables/gov/states/wi/dcf/works/eligibility/wi_works_resources_eligible.py index 7871b8455c5..14c8e8ce701 100644 --- a/policyengine_us/variables/gov/states/wi/dcf/works/eligibility/wi_works_resources_eligible.py +++ b/policyengine_us/variables/gov/states/wi/dcf/works/eligibility/wi_works_resources_eligible.py @@ -13,6 +13,7 @@ class wi_works_resources_eligible(Variable): defined_for = StateCode.WI def formula(spm_unit, period, parameters): - countable = spm_unit("wi_works_countable_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable = round_to_cents(spm_unit("wi_works_countable_resources", period)) p = parameters(period).gov.states.wi.dcf.works.asset return countable <= p.limit diff --git a/policyengine_us/variables/gov/states/wv/dhhr/works/eligibility/wv_works_resources_eligible.py b/policyengine_us/variables/gov/states/wv/dhhr/works/eligibility/wv_works_resources_eligible.py index d22bd9bdfa5..8ffbd787b1f 100644 --- a/policyengine_us/variables/gov/states/wv/dhhr/works/eligibility/wv_works_resources_eligible.py +++ b/policyengine_us/variables/gov/states/wv/dhhr/works/eligibility/wv_works_resources_eligible.py @@ -12,5 +12,8 @@ class wv_works_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.wv.dhhr.works.resources # Count explicitly modeled liquid financial assets. - countable_resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_resources = round_to_cents( + spm_unit("spm_unit_cash_assets", period.this_year) + ) return countable_resources <= p.limit diff --git a/policyengine_us/variables/gov/states/wy/dfs/power/eligibility/wy_power_resources_eligible.py b/policyengine_us/variables/gov/states/wy/dfs/power/eligibility/wy_power_resources_eligible.py index 792b0606f84..6e5c7c395a2 100644 --- a/policyengine_us/variables/gov/states/wy/dfs/power/eligibility/wy_power_resources_eligible.py +++ b/policyengine_us/variables/gov/states/wy/dfs/power/eligibility/wy_power_resources_eligible.py @@ -14,5 +14,6 @@ class wy_power_resources_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.wy.dfs.power.resources - resources = spm_unit("spm_unit_cash_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("spm_unit_cash_assets", period.this_year)) return resources <= p.limit diff --git a/policyengine_us/variables/gov/usda/snap/eligibility/meets_snap_asset_test.py b/policyengine_us/variables/gov/usda/snap/eligibility/meets_snap_asset_test.py index a7b89c647c5..3c03accc5a0 100644 --- a/policyengine_us/variables/gov/usda/snap/eligibility/meets_snap_asset_test.py +++ b/policyengine_us/variables/gov/usda/snap/eligibility/meets_snap_asset_test.py @@ -26,7 +26,8 @@ def formula(spm_unit, period, parameters): # their share at the moment. has_elderly_or_disabled = spm_unit("has_snap_elderly_disabled_member", period) asset_test = parameters(period).gov.usda.snap.asset_test - assets = spm_unit("snap_assets", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + assets = round_to_cents(spm_unit("snap_assets", period.this_year)) asset_limit = where( has_elderly_or_disabled, asset_test.limit.elderly_disabled, From d4760909d9f764d4ff4ec5a37e3e5f53b9f982a6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 23:43:01 +0000 Subject: [PATCH 02/16] Round CalWORKs and Illinois AABD resources to cents, and move the medically needy witness to Hawaii The Arkansas case counted the unit as an SSI recipient, which bars the medically needy pathway, so it couldn't show the asset boundary. Hawaii has the same 2,000 limit and reaches it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LwQq6HXUrFaqEeR9DeqWcq --- .../is_medically_needy_for_medicaid.yaml | 10 +++---- .../ca_tanf_resources_eligible.yaml | 25 ++++++++++++++++ .../asset/il_aabd_asset_value_eligible.yaml | 29 +++++++++++++++++++ .../eligibility/ca_tanf_resources_eligible.py | 3 +- .../asset/il_aabd_asset_value_eligible.py | 3 +- 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml index 7257fdd5de9..c3191a38bf0 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml @@ -941,9 +941,9 @@ is_in_medicaid_medically_needy_category: [true, true] is_medically_needy_for_medicaid: [true, true] -# Arkansas' 2,000 individual asset limit: 178.57 + 1,547.79 + 273.64 = +# Hawaii's 2,000 individual asset limit: 178.57 + 1,547.79 + 273.64 = # 2,000.00. The float32 balances add to 2,000.0001 unless rounded to cents. -- name: Three accounts that total exactly the Arkansas limit pass +- name: Three accounts that total exactly the Hawaii limit pass period: 2026 input: is_disabled: true @@ -955,12 +955,12 @@ bank_account_assets: 178.57 stock_assets: 1_547.79 bond_assets: 273.64 - state_code: AR + state_code: HI output: is_medically_needy_for_medicaid: true # 178.57 + 1,547.79 + 273.65 = 2,000.01, a cent over the limit. -- name: Three accounts a cent over the Arkansas limit fail +- name: Three accounts a cent over the Hawaii limit fail period: 2026 input: is_disabled: true @@ -972,6 +972,6 @@ bank_account_assets: 178.57 stock_assets: 1_547.79 bond_assets: 273.65 - state_code: AR + state_code: HI output: is_medically_needy_for_medicaid: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.yaml index 56a3befc19b..741e139b403 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.yaml @@ -143,3 +143,28 @@ # Resources: 14,000 + 501 = 14,501 exceeds the lower resource limit # but stays within the higher limit for households with an elderly member ca_tanf_resources_eligible: true + +# 8,441.48 + 8.48 + 3,687.04 = 12,137.00, at the limit. +# The float32 balances add to a fraction of a cent above 12,137 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025 + input: + age: 30 + bank_account_assets: 8_441.48 + stock_assets: 8.48 + bond_assets: 3_687.04 + state_code: CA + output: + ca_tanf_resources_eligible: true + +# 8,441.48 + 8.48 + 3,687.05 = 12,137.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025 + input: + age: 30 + bank_account_assets: 8_441.48 + stock_assets: 8.48 + bond_assets: 3_687.05 + state_code: CA + output: + ca_tanf_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.yaml index e3f21170387..3a60f1a78e6 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.yaml @@ -33,3 +33,32 @@ state_code: IL output: il_aabd_asset_value_eligible: true + +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. +# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +- name: Three accounts that total exactly the resource limit pass + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.02 + state_code: IL + output: + il_aabd_asset_value_eligible: true + +# 1,157.81 + 285.17 + 557.03 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the resource limit fail + period: 2025-01 + input: + age: 70 + is_ssi_aged_blind_disabled: true + is_ssi_disabled: true + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.03 + state_code: IL + output: + il_aabd_asset_value_eligible: false diff --git a/policyengine_us/variables/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.py index 3d48ac8ead1..346d9c99fed 100644 --- a/policyengine_us/variables/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/ca/cdss/tanf/cash/eligibility/ca_tanf_resources_eligible.py @@ -10,6 +10,7 @@ class ca_tanf_resources_eligible(Variable): reference = "https://my.dpss.lacounty.gov/public/en/home/epolicy/program/calworks/property/property.html" def formula(spm_unit, period, parameters): - resources = spm_unit("ca_tanf_resources", period) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents(spm_unit("ca_tanf_resources", period)) limit = spm_unit("ca_tanf_resources_limit", period) return resources <= limit diff --git a/policyengine_us/variables/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.py b/policyengine_us/variables/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.py index 70eeaf73810..2912c634701 100644 --- a/policyengine_us/variables/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.py +++ b/policyengine_us/variables/gov/states/il/dhs/aabd/asset/il_aabd_asset_value_eligible.py @@ -16,7 +16,8 @@ class il_aabd_asset_value_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.states.il.dhs.aabd.asset.disregard size = spm_unit("spm_unit_size", period) - countable_asset = spm_unit("il_aabd_countable_assets", period) + # Inputs are stored as float32, so compare whole cents with the limit. + countable_asset = round_to_cents(spm_unit("il_aabd_countable_assets", period)) capped_size = min_(size, 2) reduced_unit_size = max_(size - 2, 0) p1 = p.base[capped_size] From 56f56d1c657a6f45f29fe98c99be88c286b89ab1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 00:20:56 +0000 Subject: [PATCH 03/16] Pin float32-drifting splits in the BBCE witness and the property test snap_assets sums person inputs to the SPM unit in float64 before storing float32, so the Idaho witness needs a split that drifts on that path too. Hypothesis favours edge splits that never drift; pinned examples make the model property fail without the rounding. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LwQq6HXUrFaqEeR9DeqWcq --- .../non_cash/meets_tanf_non_cash_asset_test.yaml | 16 ++++++++-------- .../tests/unit/test_round_to_cents_properties.py | 9 +++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml index 998283aefdb..fc4e1b64f1a 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml @@ -107,25 +107,25 @@ output: meets_tanf_non_cash_asset_test: true -# Idaho's 5,000 BBCE asset limit: 3,247.08 + 1,316.70 + 436.22 = 5,000.00. +# Idaho's 5,000 BBCE asset limit: 4,338.99 + 609.03 + 51.98 = 5,000.00. # The float32 balances add to 5,000.0005 unless rounded to cents. - name: Three accounts that total exactly the Idaho limit pass period: 2026 input: state_code_str: ID - bank_account_assets: 3_247.08 - stock_assets: 1_316.70 - bond_assets: 436.22 + bank_account_assets: 4_338.99 + stock_assets: 609.03 + bond_assets: 51.98 output: meets_tanf_non_cash_asset_test: true -# 3,247.08 + 1,316.70 + 436.23 = 5,000.01, a cent over the limit. +# 4,338.99 + 609.03 + 51.99 = 5,000.01, a cent over the limit. - name: Three accounts a cent over the Idaho limit fail period: 2026 input: state_code_str: ID - bank_account_assets: 3_247.08 - stock_assets: 1_316.70 - bond_assets: 436.23 + bank_account_assets: 4_338.99 + stock_assets: 609.03 + bond_assets: 51.99 output: meets_tanf_non_cash_asset_test: false diff --git a/policyengine_us/tests/unit/test_round_to_cents_properties.py b/policyengine_us/tests/unit/test_round_to_cents_properties.py index 415fd6d7fb5..5a25c329a1a 100644 --- a/policyengine_us/tests/unit/test_round_to_cents_properties.py +++ b/policyengine_us/tests/unit/test_round_to_cents_properties.py @@ -111,6 +111,15 @@ def build_situation(households): ], ) @hypothesis.given(st.lists(household(), min_size=1, max_size=20)) +# Hypothesis favours splits at the edges, which don't drift, so these pin +# splits whose float32 sums land above the limit: 2,000.0001 for SSI and +# 4,500.0005 for SNAP. +@hypothesis.example( + [ + ("meets_ssi_resource_test", (17_857, 154_779, 27_364)), + ("meets_snap_asset_test", (418_399, 3_831, 27_770)), + ] +) def test_split_accounts_match_one_account(households): simulation = Simulation(situation=build_situation(households)) period = f"{YEAR}-01" From 220543dd31c96f70721ef8e954626d068682efec Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 04:41:29 +0000 Subject: [PATCH 04/16] Keep the SSI parental deemed share exact; round only float32 sums Rounding own resources plus the share to cents turned a child's true 2,000.0033 into 2,000.00 and passed them, though main fails them. That is a rule about how a share counts, not float noise. POMS SI 01330.200 B says to equally divide the deemed resources among the children, and 20 CFR 416.1202(b)(1) sets no rounding rule, so the share now stays unrounded. The rounding stays on the sums of float32 balances the comparisons reach: the deemors' total before the parental limit comes off, a child's own balances, a couple's balances on a joint claim, and a person's own plus an ineligible spouse's. New YAML pins the review's three-child witness (all fail, as on main), a whole-cent share at the limit that main fails, a cent-over companion for the deemed-parent case, and at-limit and cent-over pairs for the spousal and joint paths. Co-Authored-By: Claude Opus 5.5 --- ...sources_deemed_from_ineligible_parent.yaml | 137 ++++++++++++++++++ .../resources/meets_ssi_resource_test.yaml | 131 +++++++++++++++++ ...resources_deemed_from_ineligible_parent.py | 13 +- .../resources/meets_ssi_resource_test.py | 26 ++-- 4 files changed, 290 insertions(+), 17 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 660a4855fb3..03173f032ad 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -433,6 +433,143 @@ ssi_resources_deemed_from_ineligible_parent: [0, 500] meets_ssi_resource_test: [false, true] +# The child's 575.52 + 570.57 + 353.92 = 1,500.01 plus the same 500 is +# 2,000.01, a cent over the individual limit. +- name: Child accounts plus parental excess a cent over the limit fail + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_500 + child: + age: 16 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.92 + tax_units: + tax_unit: + members: [parent, child] + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 500] + meets_ssi_resource_test: [false, false] + +# POMS SI 01330.200 B: 'equally divide the value of the deemed resources +# among those children'; 20 CFR 416.1202(b)(1) sets no rounding rule for a +# child's share. The parent's 2,100 is 100 over the individual limit, so +# each of three children is deemed 100 / 3 = 33.3333. Each child holds +# 1,966.67 in one account, so the total of 2,000.0033 is over the limit. +- name: A share of parental excess counts to the fraction of a cent + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_100 + child1: + age: 8 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_966.67 + child2: + age: 10 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_966.67 + child3: + age: 12 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_966.67 + tax_units: + tax_unit: + members: [parent, child1, child2, child3] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + child2_unit: + members: [child2] + child3_unit: + members: [child3] + households: + household: + members: [parent, child1, child2, child3] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 33.3333, 33.3333, 33.3333] + meets_ssi_resource_test: [false, false, false, false] + +# The parent's 2,100 is 100 over the individual limit, which divides among +# four children as 25 each. The first child's 178.57 + 1,522.79 + 273.64 = +# 1,975.00 plus 25 is 2,000.00, at the limit. That child's float32 balances +# add to 1,975.0001 unless rounded to cents. +- name: Child accounts plus a share of parental excess that total exactly the limit pass + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_100 + child1: + age: 8 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 178.57 + stock_assets: 1_522.79 + bond_assets: 273.64 + child2: + age: 10 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + child3: + age: 12 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + child4: + age: 14 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + tax_units: + tax_unit: + members: [parent, child1, child2, child3, child4] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + child2_unit: + members: [child2] + child3_unit: + members: [child3] + child4_unit: + members: [child4] + households: + household: + members: [parent, child1, child2, child3, child4] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 25, 25, 25, 25] + meets_ssi_resource_test: [false, true, true, true, true] + # POMS SI 01330.340 White example: parent pool1200 <=couple limit3000; child deemed0. - name: POMS White eligible parent leaves no excess resources to deem period: 2024-01 diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml index 208c36cb1f0..99b9b0ac73a 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml @@ -351,3 +351,134 @@ bond_assets: 273.65 output: meets_ssi_resource_test: false + +# 20 CFR 416.1202(a), 416.1205: the claimant's and the ineligible spouse's +# 575.52 + 570.57 + 353.91 = 1,500.00 each add to 3,000.00, at the couple +# limit. The float32 balances add to 3,000.0002 unless rounded to cents. +- name: Spousal accounts that total exactly the couple limit pass + period: 2026-01 + input: + people: + claimant: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_head: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.91 + spouse: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_spouse: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.91 + tax_units: + family: + members: [claimant, spouse] + marital_units: + family_couple_0: + members: [claimant, spouse] + households: + family: + members: [claimant, spouse] + output: + ssi_claim_is_joint: [false, false] + meets_ssi_resource_test: [true, true] + +# The spouse's 575.52 + 570.57 + 353.92 = 1,500.01 makes 3,000.01, a cent +# over the couple limit. The spouse, who isn't aged, blind or disabled, is +# tested alone against the individual limit and passes. +- name: Spousal accounts a cent over the couple limit fail + period: 2026-01 + input: + people: + claimant: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_head: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.91 + spouse: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_spouse: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.92 + tax_units: + family: + members: [claimant, spouse] + marital_units: + family_couple_0: + members: [claimant, spouse] + households: + family: + members: [claimant, spouse] + output: + ssi_claim_is_joint: [false, false] + meets_ssi_resource_test: [false, true] + +# 20 CFR 416.1205: a jointly eligible couple's 1,500.00 in one account and +# 575.52 + 570.57 + 353.91 = 1,500.00 add to 3,000.00, at the couple limit. +# The float32 balances add to 3,000.0001 unless rounded to cents. +- name: Joint claim accounts that total exactly the couple limit pass + period: 2026-01 + input: + people: + claimant: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_head: true + bank_account_assets: 1_500 + spouse: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_spouse: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.91 + tax_units: + family: + members: [claimant, spouse] + marital_units: + family_couple_0: + members: [claimant, spouse] + households: + family: + members: [claimant, spouse] + output: + ssi_claim_is_joint: [true, true] + meets_ssi_resource_test: [true, true] + +# The spouse's 575.52 + 570.57 + 353.92 = 1,500.01 makes 3,000.01, a cent +# over the couple limit. +- name: Joint claim accounts a cent over the couple limit fail + period: 2026-01 + input: + people: + claimant: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_head: true + bank_account_assets: 1_500 + spouse: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_spouse: true + bank_account_assets: 575.52 + stock_assets: 570.57 + bond_assets: 353.92 + tax_units: + family: + members: [claimant, spouse] + marital_units: + family_couple_0: + members: [claimant, spouse] + households: + family: + members: [claimant, spouse] + output: + ssi_claim_is_joint: [true, true] + meets_ssi_resource_test: [false, false] diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py index 0b9fe1dec7c..28334d22c0a 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py @@ -120,11 +120,14 @@ def formula(person, period, parameters): # 'only to the extent that those resources exceed the resource limits # described in § 416.1205': use the reformable individual/couple limits. allowance = where(parent_count > 1, p.couple, p.individual) - # Inputs are stored as float32, so compare whole cents with the limits. + # Balances are float32 inputs. Each deemor's are added together, then + # the deemors' totals, so the sum can land a fraction of a cent off + # the total it represents: round it to cents before the limit comes off. excess = max_(0, round_to_cents(parental_resources) - allowance) # Do not discard ABD parents. SI 01330.310 B-C says zero if parent(s) # meets resource eligibility, usual deeming if not. The Ryder example # (.340) has an ABD mother failing the couple limit: 3100-3000=100. + # The child's own float32 balances are added together: round to cents. own_resources = round_to_cents(person("ssi_countable_resources", period)) active = person("is_ssi_resource_deeming_child", period) & ( own_resources <= p.individual @@ -149,9 +152,15 @@ def formula(person, period, parameters): pool_count = int(np.max(pool, initial=-1)) + 1 for _ in range(rounds): count = np.bincount(pool[active & income_eligible], minlength=pool_count) + # The share is a division, not a sum of balances, so it stays + # exact: SI 01330.200 B says to 'equally divide the value of the + # deemed resources among those children', and 416.1202(b)(1) sets + # no rule for rounding a child's share. + # https://secure.ssa.gov/poms.nsf/lnx/0501330200 + # https://www.law.cornell.edu/cfr/text/20/416.1202 share = excess / max_(1, count[pool]) deemed = where(active, share, deemed) - remaining = active & (round_to_cents(own_resources + share) <= p.individual) + remaining = active & (own_resources + share <= p.individual) if np.array_equal(active, remaining): break active = remaining diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py index 6c789f8c52d..e206d99cd66 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py @@ -17,21 +17,17 @@ def formula(person, period, parameters): joint_claim = person("ssi_claim_is_joint", period) personal_resources = person("ssi_countable_resources", period) spousal_deeming = person("is_ssi_spousal_resource_deeming_applies", period) - deemed_resources = add( - person, - period, - [ - "ssi_resources_deemed_from_ineligible_spouse", - "ssi_resources_deemed_from_ineligible_parent", - ], - ) - # Inputs are stored as float32, so compare whole cents with the limit. - countable_resources = round_to_cents( - where( - joint_claim, - person.marital_unit.sum(personal_resources), - personal_resources + deemed_resources, - ) + spouse_resources = person("ssi_resources_deemed_from_ineligible_spouse", period) + parent_resources = person("ssi_resources_deemed_from_ineligible_parent", period) + # Balances are float32 inputs, so a sum of them can land a fraction of + # a cent off the total it represents. Round each such sum to cents: a + # couple's balances, or a person's own plus a spouse's. The parental + # share is an equal division with no rounding rule (SI 01330.200 B, + # 416.1202(b)(1)), so it is added unrounded. + countable_resources = where( + joint_claim, + round_to_cents(person.marital_unit.sum(personal_resources)), + round_to_cents(personal_resources + spouse_resources) + parent_resources, ) # 416.1205(a): an individual living with an ineligible spouse counts # 'including the resources of the spouse' against the spouse limit. From 365613ef887108da57acf050eced500fe677dd8e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 04:41:29 +0000 Subject: [PATCH 05/16] Round Maryland PAA and Virginia Auxiliary Grant resources to cents Both compare ssi_countable_resources, a float32 sum of bank, stock and bond balances, with the $2,000 SSI limit, so three balances that add to exactly $2,000.00 failed as $2,000.0001. Each fix gets an at-limit case and a cent-over companion. Co-Authored-By: Claude Opus 5.5 --- .../md/dhs/fia/paa/md_paa_eligible.yaml | 42 +++++++++++++++++++ .../gov/states/va/dars/ag/va_ag_eligible.yaml | 35 ++++++++++++++++ .../states/md/dhs/fia/paa/md_paa_eligible.py | 5 ++- .../gov/states/va/dars/ag/va_ag_eligible.py | 5 ++- 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 policyengine_us/tests/policy/baseline/gov/states/va/dars/ag/va_ag_eligible.yaml diff --git a/policyengine_us/tests/policy/baseline/gov/states/md/dhs/fia/paa/md_paa_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/md/dhs/fia/paa/md_paa_eligible.yaml index e139b19db84..827caa644a9 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/md/dhs/fia/paa/md_paa_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/md/dhs/fia/paa/md_paa_eligible.yaml @@ -386,3 +386,45 @@ state_code: MD output: md_paa_eligible: true + +# PAA Manual §500's $2,000 limit: 178.57 + 1,547.79 + 273.64 = 2,000.00, at +# the limit. The three float32 balances add to 2,000.0001 unless rounded to +# cents. +- name: Case 19, three accounts that total exactly the resource limit are eligible. + period: 2026-01 + input: + people: + person1: + age: 70 + is_disabled: true + ssi: 800 + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.64 + md_paa_living_arrangement: CARE_HOME_LEVEL_B + households: + household: + members: [person1] + state_code: MD + output: + md_paa_eligible: true + +# 178.57 + 1,547.79 + 273.65 = 2,000.01, a cent over the limit. +- name: Case 20, three accounts a cent over the resource limit are ineligible. + period: 2026-01 + input: + people: + person1: + age: 70 + is_disabled: true + ssi: 800 + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.65 + md_paa_living_arrangement: CARE_HOME_LEVEL_B + households: + household: + members: [person1] + state_code: MD + output: + md_paa_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/states/va/dars/ag/va_ag_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/va/dars/ag/va_ag_eligible.yaml new file mode 100644 index 00000000000..fb98c10be34 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/va/dars/ag/va_ag_eligible.yaml @@ -0,0 +1,35 @@ +# An applicant who doesn't receive SSI is tested against the SSI resource +# limits. 178.57 + 1,547.79 + 273.64 = 2,000.00, at the $2,000 individual +# limit. The three float32 balances add to 2,000.0001 unless rounded to cents. +- name: Three accounts that total exactly the individual resource limit are eligible + period: 2026-01 + input: + state_code: VA + age: 70 + is_disabled: true + is_ssi_aged_blind_disabled: true + va_ag_certified: true + ssi: 0 + social_security: 30_000 + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.64 + output: + va_ag_eligible: true + +# 178.57 + 1,547.79 + 273.65 = 2,000.01, a cent over the limit. +- name: Three accounts a cent over the individual resource limit are ineligible + period: 2026-01 + input: + state_code: VA + age: 70 + is_disabled: true + is_ssi_aged_blind_disabled: true + va_ag_certified: true + ssi: 0 + social_security: 30_000 + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.65 + output: + va_ag_eligible: false diff --git a/policyengine_us/variables/gov/states/md/dhs/fia/paa/md_paa_eligible.py b/policyengine_us/variables/gov/states/md/dhs/fia/paa/md_paa_eligible.py index 5d71e550170..2559d8f9f62 100644 --- a/policyengine_us/variables/gov/states/md/dhs/fia/paa/md_paa_eligible.py +++ b/policyengine_us/variables/gov/states/md/dhs/fia/paa/md_paa_eligible.py @@ -61,7 +61,10 @@ def formula(person, period, parameters): ssi_resource_limit = parameters( period ).gov.ssa.ssi.eligibility.resources.limit.individual - ssi_resources = person("ssi_countable_resources", period.this_year) + # Inputs are stored as float32, so compare whole cents with the limit. + ssi_resources = round_to_cents( + person("ssi_countable_resources", period.this_year) + ) resource_eligible = ssi_resources <= ssi_resource_limit living_arrangement = person("md_paa_living_arrangement", period) in_facility = living_arrangement != living_arrangement.possible_values.NONE diff --git a/policyengine_us/variables/gov/states/va/dars/ag/va_ag_eligible.py b/policyengine_us/variables/gov/states/va/dars/ag/va_ag_eligible.py index acc268b6f8e..7a1f7ed8d4d 100644 --- a/policyengine_us/variables/gov/states/va/dars/ag/va_ag_eligible.py +++ b/policyengine_us/variables/gov/states/va/dars/ag/va_ag_eligible.py @@ -18,7 +18,10 @@ def formula(person, period, parameters): person.marital_unit.sum(person("va_ag_is_joint_initial_month", period)) == 2 ) resources = person("ssi_countable_resources", period.this_year) - resources = where(joint, person.marital_unit.sum(resources), resources) + # Inputs are stored as float32, so compare whole cents with the limit. + resources = round_to_cents( + where(joint, person.marital_unit.sum(resources), resources) + ) limits = parameters(period).gov.ssa.ssi.eligibility.resources.limit receives_ssi = (person("ssi", period) > 0) | person("receives_ssi", period) resource_eligible = receives_ssi | ( From 4d6efb0473bc972c3294a5905e258913606d8e37 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 04:41:29 +0000 Subject: [PATCH 06/16] Correct the exactness bound and drop the model property test Below 2**15 dollars a float32 half unit is at most 2**-10, so five half units stay under half a cent: the helper's guarantee holds below $32,768, not $16,384, and the property now draws totals up to $32,767.99. The model property built a Simulation per example, and only its pinned example caught anything; the YAML at-limit cases cover that, so it goes. Also remove a stray blank line in the Pennsylvania TANF formula. Co-Authored-By: Claude Opus 5.5 --- .../unit/test_round_to_cents_properties.py | 97 ++----------------- .../eligibility/pa_tanf_resources_eligible.py | 1 - 2 files changed, 9 insertions(+), 89 deletions(-) diff --git a/policyengine_us/tests/unit/test_round_to_cents_properties.py b/policyengine_us/tests/unit/test_round_to_cents_properties.py index 5a25c329a1a..8dfc05b2b56 100644 --- a/policyengine_us/tests/unit/test_round_to_cents_properties.py +++ b/policyengine_us/tests/unit/test_round_to_cents_properties.py @@ -1,35 +1,28 @@ -"""Hypothesis checks that splitting a total into cents doesn't change a limit test. +"""Hypothesis check that splitting a total into cents doesn't change a limit test. Account balances are stored as float32, so three balances that add to a limit in cents can sum a fraction of a cent above or below it. Asset tests round the sum to cents before comparing it with the limit (``round_to_cents``). -The first property checks the helper alone, without a model, on both ways -the model sums inputs: float32 addition within one entity, and a float64 sum -cast back to float32 when person inputs are added up to a group entity. - -The second property runs the model. Each example is one situation of -single-person households. Each household splits a total at, a cent below or -a cent above the SSI and SNAP limits among bank, stock and bond assets, and -its result must match the result for the same total held in one account. -Hypothesis is a dev extra, so this module skips without it. +The property checks the helper alone, without a model, on both ways the model +sums inputs: float32 addition within one entity, and a float64 sum cast back +to float32 when person inputs are added up to a group entity. The YAML cases +at each fixed limit check the model. Hypothesis is a dev extra, so this module +skips without it. """ import numpy as np import pytest -from policyengine_us import Simulation from policyengine_us.tools.general import round_to_cents hypothesis = pytest.importorskip("hypothesis") st = pytest.importorskip("hypothesis.strategies") -ACCOUNTS = ("bank_account_assets", "stock_assets", "bond_assets") - # Three float32 parts and two float32 additions each err by at most half a -# unit in the last place of the total. Below 2**14 dollars that unit is at -# most 2**-10, so the sum stays within 5 / 2**11 < 0.005 of the total. -MAX_CENTS = 2**14 * 100 - 1 +# unit in the last place of the total. Below 2**15 dollars a half unit is at +# most 2**-10, so the sum stays within 5 / 2**10 < 0.005 of the total. +MAX_CENTS = 2**15 * 100 - 1 @st.composite @@ -56,75 +49,3 @@ def test_rounded_sum_of_float32_parts_is_the_total(case): float64_sum = np.float32(sum(float(value) for value in values)) for amount in (float32_sum, float64_sum): assert round_to_cents(amount) == total / 100 - - -YEAR = 2026 -# 20 CFR 416.1205: the individual limit is 2,000. Everyone is 70, so SNAP -# applies its FY2026 limit for households with an elderly member, 4,500 -# (7 U.S.C. 2014(g)(1)). -LIMITS = {"meets_ssi_resource_test": 2_000, "meets_snap_asset_test": 4_500} - - -@st.composite -def household(draw): - test = draw(st.sampled_from(sorted(LIMITS))) - total = LIMITS[test] * 100 + draw(st.sampled_from([-1, 0, 1])) - return test, draw(cent_split(total)) - - -def build_situation(households): - people = {} - groups = {} - for i, (_, parts) in enumerate(households): - for split in (False, True): - name = f"h{i}_{'split' if split else 'whole'}" - amounts = parts if split else (sum(parts), 0, 0) - person = { - "age": {YEAR: 70}, - "is_ssi_aged_blind_disabled": {YEAR: True}, - } - for account, cents in zip(ACCOUNTS, amounts): - person[account] = {YEAR: cents / 100} - people[name] = person - groups[name] = {"members": [name]} - return { - "people": people, - **{ - entity: groups - for entity in ( - "tax_units", - "spm_units", - "families", - "marital_units", - "households", - ) - }, - } - - -@hypothesis.settings( - max_examples=10, - deadline=None, - suppress_health_check=[ - hypothesis.HealthCheck.too_slow, - hypothesis.HealthCheck.data_too_large, - ], -) -@hypothesis.given(st.lists(household(), min_size=1, max_size=20)) -# Hypothesis favours splits at the edges, which don't drift, so these pin -# splits whose float32 sums land above the limit: 2,000.0001 for SSI and -# 4,500.0005 for SNAP. -@hypothesis.example( - [ - ("meets_ssi_resource_test", (17_857, 154_779, 27_364)), - ("meets_snap_asset_test", (418_399, 3_831, 27_770)), - ] -) -def test_split_accounts_match_one_account(households): - simulation = Simulation(situation=build_situation(households)) - period = f"{YEAR}-01" - results = {test: np.asarray(simulation.calculate(test, period)) for test in LIMITS} - # People alternate whole, split, so each person's group holds only them. - for i, (test, parts) in enumerate(households): - whole, split = results[test][2 * i], results[test][2 * i + 1] - assert split == whole, (test, parts) diff --git a/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py b/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py index 61a88c49e66..bda666ab06f 100644 --- a/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py +++ b/policyengine_us/variables/gov/states/pa/dhs/tanf/eligibility/pa_tanf_resources_eligible.py @@ -13,7 +13,6 @@ def formula(spm_unit, period, parameters): p = parameters(period).gov.states.pa.dhs.tanf # Inputs are stored as float32, so compare whole cents with the limit. - household_assets = round_to_cents( spm_unit("spm_unit_cash_assets", period.this_year) ) From b7773a86b4e0c3c9d8b519c1e937cfc1a4c4070c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 04:49:49 +0000 Subject: [PATCH 07/16] Pin the exact share in the deemed-parent division loop Rounding own resources plus the share inside the loop alone keeps the review's three-child witness unchanged, since all three children stay or leave together. This case lets one child leave the division on the exact share, so the other two divide the excess as 50 each; rounding the loop's total would keep all three at 33.33. Main gives the same result as this branch. Co-Authored-By: Claude Opus 5.5 --- ...sources_deemed_from_ineligible_parent.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 03173f032ad..3e2b151e86b 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -516,6 +516,53 @@ ssi_resources_deemed_from_ineligible_parent: [0, 33.3333, 33.3333, 33.3333] meets_ssi_resource_test: [false, false, false, false] +# SI 01330.200 B: when a child is ineligible, 'divide the value of the deemed +# resources among the remaining eligible children'. The first child's +# 1,966.67 plus the exact share of 33.3333 is over the limit, so that child +# leaves the division and keeps the share last tested; the other two +# children, who hold nothing, divide the 100 as 50 each. +- name: A child whom an unrounded share takes over the limit leaves the division + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_100 + child1: + age: 8 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_966.67 + child2: + age: 10 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + child3: + age: 12 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + tax_units: + tax_unit: + members: [parent, child1, child2, child3] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + child2_unit: + members: [child2] + child3_unit: + members: [child3] + households: + household: + members: [parent, child1, child2, child3] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 33.3333, 50, 50] + meets_ssi_resource_test: [false, false, true, true] + # The parent's 2,100 is 100 over the individual limit, which divides among # four children as 25 each. The first child's 178.57 + 1,522.79 + 273.64 = # 1,975.00 plus 25 is 2,000.00, at the limit. That child's float32 balances From 0e3f0a468380d52975a1556791e1c0defd22c81e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 05:15:27 +0000 Subject: [PATCH 08/16] Keep parental shares exact in the medically needy and Iowa SSA tests Both add a parental share to a child's resources and then rounded the total to cents, which absorbed a fraction-of-a-cent share the same way the SSI test did. Medically needy adds SSI's own share; Iowa divides the excess as SSI does. Round only the summed balances and add the share unrounded, as the SSI resource test now does. The medically needy witness is a disabled child whose own income is too high for SSI, so they don't count in the division but are deemed the share their SSI-eligible siblings divide: 1,966.67 plus 33.3333 fails, as on main, and a whole-cent share at the limit passes, which main fails. Iowa's computed share doesn't give that witness: a child whom the share takes over the limit leaves the division and is deemed the remaining children's larger share, or the whole excess if none remain. So its witness enters a certified share. Co-Authored-By: Claude Opus 5.5 --- .../is_medically_needy_for_medicaid.yaml | 143 ++++++++++++++++++ .../states/ia/hhs/ssa/ia_ssa_eligible.yaml | 68 +++++++++ .../is_medically_needy_for_medicaid.py | 10 +- .../gov/states/ia/hhs/ssa/ia_ssa_eligible.py | 10 +- 4 files changed, 225 insertions(+), 6 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml index c3191a38bf0..ca07572b347 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml @@ -975,3 +975,146 @@ state_code: HI output: is_medically_needy_for_medicaid: false + + +# A child's resources include the SSI parental share (Cases 5 and 6). The +# first child's own income is too high for SSI, as in Case 5, so they don't +# count in the division but are still deemed the share the three SSI-eligible +# siblings divide (SI 01330.200 B, which sets no rounding rule for a share). +# The parent's 2,100 is 100 over the SSI individual allowance, so the share +# is 100 / 3 = 33.3333. The first child's 1,966.67 in one account plus the +# share is 2,000.0033, over Massachusetts's 2,000 limit. The siblings receive +# SSI, so they qualify through that pathway instead; the parent's 80,000 of +# wages keeps the children out of the MAGI child groups. +- name: Case 37, a fractional parental share counts against a disabled child's asset limit. + period: 2026 + input: + people: + parent: + age: 40 + is_tax_unit_head: true + is_parent: true + employment_income_before_lsr: 80_000 + bank_account_assets: 2_100 + child1: + age: 8 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 21_358 + medicaid_medically_needy_medical_expenses: 16_000 + is_optional_senior_or_disabled_for_medicaid: false + bank_account_assets: 1_966.67 + child2: + age: 10 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + child3: + age: 12 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + child4: + age: 14 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + tax_units: + tax_unit: + members: [parent, child1, child2, child3, child4] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + child2_unit: + members: [child2] + child3_unit: + members: [child3] + child4_unit: + members: [child4] + households: + household: + members: [parent, child1, child2, child3, child4] + state_code: MA + output: + ssi_resources_deemed_from_ineligible_parent: + 2026-01: [0, 33.3333, 33.3333, 33.3333, 33.3333] + is_medically_needy_for_medicaid: [false, false, false, false, false] + +# With four SSI-eligible siblings the parent's 100 of excess divides as 25 +# each. The first child's 178.57 + 1,522.79 + 273.64 = 1,975.00 plus 25 is +# 2,000.00, at the limit, and income 21,358 - 16,000 = 5,358 <= 6,264 as in +# Case 5. That child's float32 balances add to 1,975.0001 unless rounded to +# cents. +- name: Case 38, a disabled child's accounts plus a whole-cent parental share at the asset limit qualify. + period: 2026 + input: + people: + parent: + age: 40 + is_tax_unit_head: true + is_parent: true + employment_income_before_lsr: 80_000 + bank_account_assets: 2_100 + child1: + age: 8 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 21_358 + medicaid_medically_needy_medical_expenses: 16_000 + is_optional_senior_or_disabled_for_medicaid: false + bank_account_assets: 178.57 + stock_assets: 1_522.79 + bond_assets: 273.64 + child2: + age: 10 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + child3: + age: 12 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + child4: + age: 14 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + child5: + age: 16 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + tax_units: + tax_unit: + members: [parent, child1, child2, child3, child4, child5] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + child2_unit: + members: [child2] + child3_unit: + members: [child3] + child4_unit: + members: [child4] + child5_unit: + members: [child5] + households: + household: + members: [parent, child1, child2, child3, child4, child5] + state_code: MA + output: + ssi_resources_deemed_from_ineligible_parent: + 2026-01: [0, 25, 25, 25, 25, 25] + is_medically_needy_for_medicaid: [false, true, false, false, false, false] diff --git a/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml index 48895eb269d..3c5c7e5b0b7 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_eligible.yaml @@ -26,3 +26,71 @@ state_code: IA output: ia_ssa_eligible: false + +# ia_ssa_resources_deemed_from_parents divides the parental excess among the +# children as SSI does, and a certified share can be entered instead. A share +# of 33.3333 (100 divided among three children) plus the child's 1,966.67 in +# one account is 2,000.0033, over the limit: the share isn't rounded to +# cents, as SSI sets no rounding rule for it (SI 01330.200 B). +- name: A fractional share of parental excess counts against the resource limit + period: 2026-01 + input: + people: + parent: + age: 40 + child: + age: 10 + bank_account_assets: 1_966.67 + ia_ssa_resources_deemed_from_parents: 33.3333 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: true + meets_ssi_disability_criteria: true + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + tax_units: + family: + members: [parent, child] + households: + home: + members: [parent, child] + state_code: IA + output: + ia_ssa_eligible: [false, false] + +# A share of 25 (100 divided among four children) plus the child's 178.57 + +# 1,522.79 + 273.64 = 1,975.00 is 2,000.00, at the limit. The child's float32 +# balances add to 1,975.0001 unless rounded to cents. +- name: Three accounts plus a whole-cent share of parental excess at the limit pass + period: 2026-01 + input: + people: + parent: + age: 40 + child: + age: 10 + bank_account_assets: 178.57 + stock_assets: 1_522.79 + bond_assets: 273.64 + ia_ssa_resources_deemed_from_parents: 25 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: true + meets_ssi_disability_criteria: true + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + tax_units: + family: + members: [parent, child] + households: + home: + members: [parent, child] + state_code: IA + output: + ia_ssa_eligible: [false, true] diff --git a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py index 54fa24bdece..ea217c5be14 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py +++ b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py @@ -33,7 +33,8 @@ def formula(person, period, parameters): # includes their deemed income. SSI's allocation gates apply: a child # whose own resources exceed the SSI individual limit, or who fails # SSI's immigration test, is deemed nothing. - personal_assets = person("ssi_countable_resources", period) + person( + personal_assets = person("ssi_countable_resources", period) + deemed_assets = person( "ssi_resources_deemed_from_ineligible_parent", period.first_month ) # SSI financial responsibility rules (42 CFR 435.602): the unit is @@ -57,8 +58,11 @@ def formula(person, period, parameters): income = marital_unit.sum( personal_income - medical_expenses - parental_expense_share ) - # Inputs are stored as float32, so compare whole cents with the limit. - assets = round_to_cents(marital_unit.sum(personal_assets)) + # Balances are float32 inputs, so round their sum to cents. The SSI + # parental share is an equal division with no rounding rule (SI + # 01330.200 B, 416.1202(b)(1)), so it is added unrounded. + own_assets = round_to_cents(marital_unit.sum(personal_assets)) + assets = own_assets + marital_unit.sum(deemed_assets) ma = parameters(period).gov.hhs.medicaid mn = ma.eligibility.categories.medically_needy is_joint = marital_unit.nb_persons() == 2 diff --git a/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py b/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py index c04e6fad062..56bdd0255ee 100644 --- a/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py +++ b/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_eligible.py @@ -43,9 +43,13 @@ def formula(person, period, parameters): community | person("ia_ssa_rcf_couple_budget", period) ) resource = where(couple, person.marital_unit.sum(resource), resource) - resource = resource + person("ia_ssa_resources_deemed_from_parents", period) - # Inputs are stored as float32, so compare whole cents with the limit. - resource = round_to_cents(resource) + # Balances are float32 inputs, so round their sum to cents. The + # parental share divides the excess as SSI does, and SSI sets no rule + # for rounding a share (SI 01330.200 B, 416.1202(b)(1)), so it is + # added unrounded. + resource = round_to_cents(resource) + person( + "ia_ssa_resources_deemed_from_parents", period + ) # 6-B Resources prints "$2,000 for an individual" and "$3,000 for a # married couple living together" under 20 CFR 416.1202; these equal # the SSI limits of 20 CFR 416.1205, so the federal parameters are used From 7a72caaa57a508ce07591cfc06c4cd96741991af Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 05:54:30 +0000 Subject: [PATCH 09/16] Compare own resources plus an exact share in whole cents Keeping the parental share unrounded left two float errors that decide totals at the limit. Float64 addition put 1,983.90 + 48.30 / 3 at 2,000.0000000000002, which removed an at-limit child from the division and raised the siblings' shares. And core stores the share as float32: a share of 100.01 reads back as 100.010002, so a child with 1,899.99 failed a $2,000 limit that main and the previous head passed. The deeming loops now test divisor x own + excess <= divisor x limit in whole cents, and store each share as the largest float32 at or below it, so own resources plus the share read back stay within any limit the exact total meets. The share is still never rounded to cents. Iowa's loop also rounds the deemors' total and the child's own balances, which it summed in float32 without rounding. New cases: a whole-cent share at the limit (SSI, medically needy and Iowa), 16.10 shares that keep an at-limit child in the division (SSI and Iowa), a parent's three-account split at the Iowa allowance, and an Iowa child whose three accounts plus the share total the limit. Co-Authored-By: Claude Opus 5.5 --- .../is_medically_needy_for_medicaid.yaml | 38 +++ ...sources_deemed_from_ineligible_parent.yaml | 82 +++++ .../ia_ssa_resources_deemed_from_parents.yaml | 299 ++++++++++++++++++ policyengine_us/tools/general.py | 34 ++ ...resources_deemed_from_ineligible_parent.py | 14 +- .../ia_ssa_resources_deemed_from_parents.py | 17 +- 6 files changed, 475 insertions(+), 9 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml index ca07572b347..7331422ee87 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml @@ -1118,3 +1118,41 @@ ssi_resources_deemed_from_ineligible_parent: 2026-01: [0, 25, 25, 25, 25, 25] is_medically_needy_for_medicaid: [false, true, false, false, false, false] + +# The parent's 2,100.01 is 100.01 over the SSI individual allowance, all +# deemed to the only child, whose own income is too high for SSI. The +# child's 1,899.99 plus 100.01 is exactly 2,000.00, at the limit. +- name: Case 39, a disabled child's whole-cent parental share that reaches the asset limit exactly qualifies. + period: 2026 + input: + people: + parent: + age: 40 + is_tax_unit_head: true + is_parent: true + employment_income_before_lsr: 80_000 + bank_account_assets: 2_100.01 + child1: + age: 8 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 21_358 + medicaid_medically_needy_medical_expenses: 16_000 + is_optional_senior_or_disabled_for_medicaid: false + bank_account_assets: 1_899.99 + tax_units: + tax_unit: + members: [parent, child1] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + households: + household: + members: [parent, child1] + state_code: MA + output: + ssi_resources_deemed_from_ineligible_parent: + 2026-01: [0, 100.01] + is_medically_needy_for_medicaid: [false, true] diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 3e2b151e86b..347927b3a52 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -617,6 +617,88 @@ ssi_resources_deemed_from_ineligible_parent: [0, 25, 25, 25, 25] meets_ssi_resource_test: [false, true, true, true, true] +# 20 CFR 416.1202(b)(1): the parent's 2,100.01 is 100.01 over the +# individual limit, all deemed to the only child, whose 1,899.99 brings the +# total to exactly 2,000.00. Stored as the nearest float32, the 100.01 share +# would read back as 100.010002 and push that total over the limit. +- name: A whole-cent parental share that brings a child exactly to the limit passes + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_100.01 + child: + age: 16 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_899.99 + tax_units: + tax_unit: + members: [parent, child] + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 100.01] + meets_ssi_resource_test: [false, true] + +# SI 01330.200 B: the parent's 2,048.30 is 48.30 over the individual limit, +# which divides among three children as 16.10 each. The first child's +# 1,983.90 plus 16.10 is exactly 2,000.00, so all three stay in the division +# and pass. In float64, 1,983.90 + 48.30 / 3 is 2,000.0000000000002, which +# would remove the first child and raise the others' shares. +- name: A child whom a share reaches exactly to the limit stays in the division + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_048.30 + child1: + age: 8 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_983.90 + child2: + age: 10 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_980 + child3: + age: 12 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + tax_units: + tax_unit: + members: [parent, child1, child2, child3] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + child2_unit: + members: [child2] + child3_unit: + members: [child3] + households: + household: + members: [parent, child1, child2, child3] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 16.10, 16.10, 16.10] + meets_ssi_resource_test: [false, true, true, true] + # POMS SI 01330.340 White example: parent pool1200 <=couple limit3000; child deemed0. - name: POMS White eligible parent leaves no excess resources to deem period: 2024-01 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml index a4329d445fe..48504beceeb 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml @@ -422,3 +422,302 @@ ia_ssa_resources_deemed_from_parents: [0, 200] ia_ssa_eligible: [false, true] ia_ssa: [0, 400] + +# The parent's 1,805.81 + 244.12 + 50.07 = 2,100.00 is 100 over the one-parent +# allowance; the float32 balances add to 2,100.0002 unless rounded to cents. +# The child's 1,900 plus 100 is exactly the 2,000 limit. +- name: Case 8, a parent's three accounts at the allowance plus 100 deem exactly 100. + period: 2026-01 + absolute_error_margin: 0.01 + input: + people: + person1: + age: + 2026: 40 + person_id: + 2026: 1 + bank_account_assets: + 2026: 1_805.81 + stock_assets: + 2026: 244.12 + bond_assets: + 2026: 50.07 + person2: + age: + 2026: 10 + person_id: + 2026: 2 + parent_1_id: + 2026: 1 + bank_account_assets: + 2026: 1_900 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + marital_units: + person1_unit: + members: [person1] + person2_unit: + members: [person2] + families: + family: + members: [person1, person2] + tax_units: + family: + members: [person1, person2] + spm_units: + unit: + members: [person1, person2] + households: + home: + members: [person1, person2] + state_code: + 2026: IA + output: + ia_ssa_resources_deemed_from_parents: [0, 100] + ia_ssa_eligible: [false, true] + +# The parent's 2,100.01 is 100.01 over the allowance, all deemed to the only +# child, whose 1,899.99 brings the total to exactly 2,000.00. Stored as the +# nearest float32, the share would read back as 100.010002. +- name: Case 9, a whole-cent share that brings a child exactly to the limit leaves them eligible. + period: 2026-01 + absolute_error_margin: 0.01 + input: + people: + person1: + age: + 2026: 40 + person_id: + 2026: 1 + bank_account_assets: + 2026: 2_100.01 + person2: + age: + 2026: 10 + person_id: + 2026: 2 + parent_1_id: + 2026: 1 + bank_account_assets: + 2026: 1_899.99 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + marital_units: + person1_unit: + members: [person1] + person2_unit: + members: [person2] + families: + family: + members: [person1, person2] + tax_units: + family: + members: [person1, person2] + spm_units: + unit: + members: [person1, person2] + households: + home: + members: [person1, person2] + state_code: + 2026: IA + output: + ia_ssa_resources_deemed_from_parents: [0, 100.01] + ia_ssa_eligible: [false, true] + +# The parent's 100 of excess divides among four children as 25 each. The +# first child's 178.57 + 1,522.79 + 273.64 = 1,975.00 plus 25 is 2,000.00, at +# the limit; the float32 balances add to 1,975.0001 unless rounded to cents, +# which would leave the child out and deem every child 33.33. +- name: Case 10, a child whose three accounts and share total exactly the limit stays in the division. + period: 2026-01 + absolute_error_margin: 0.01 + input: + people: + person1: + age: + 2026: 40 + person_id: + 2026: 1 + bank_account_assets: + 2026: 2_100 + person2: + age: + 2026: 8 + person_id: + 2026: 2 + parent_1_id: + 2026: 1 + bank_account_assets: + 2026: 178.57 + stock_assets: + 2026: 1_522.79 + bond_assets: + 2026: 273.64 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + person3: + age: + 2026: 10 + person_id: + 2026: 3 + parent_1_id: + 2026: 1 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + person4: + age: + 2026: 12 + person_id: + 2026: 4 + parent_1_id: + 2026: 1 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + person5: + age: + 2026: 14 + person_id: + 2026: 5 + parent_1_id: + 2026: 1 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + marital_units: + person1_unit: + members: [person1] + person2_unit: + members: [person2] + person3_unit: + members: [person3] + person4_unit: + members: [person4] + person5_unit: + members: [person5] + families: + family: + members: [person1, person2, person3, person4, person5] + tax_units: + family: + members: [person1, person2, person3, person4, person5] + spm_units: + unit: + members: [person1, person2, person3, person4, person5] + households: + home: + members: [person1, person2, person3, person4, person5] + state_code: + 2026: IA + output: + ia_ssa_resources_deemed_from_parents: [0, 25, 25, 25, 25] + ia_ssa_eligible: [false, true, true, true, true] + +# The parent's 48.30 of excess divides among three children as 16.10 each. +# The first child's 1,983.90 plus 16.10 is exactly 2,000.00. In float64, +# 1,983.90 + 48.30 / 3 is 2,000.0000000000002, which would leave the first +# child out of the division. +- name: Case 11, a child whom a share reaches exactly to the limit stays in the division. + period: 2026-01 + absolute_error_margin: 0.01 + input: + people: + person1: + age: + 2026: 40 + person_id: + 2026: 1 + bank_account_assets: + 2026: 2_048.30 + person2: + age: + 2026: 8 + person_id: + 2026: 2 + parent_1_id: + 2026: 1 + bank_account_assets: + 2026: 1_983.90 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + person3: + age: + 2026: 10 + person_id: + 2026: 3 + parent_1_id: + 2026: 1 + bank_account_assets: + 2026: 1_980 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + person4: + age: + 2026: 12 + person_id: + 2026: 4 + parent_1_id: + 2026: 1 + ia_ssa_category: IN_HOME_CARE + ia_ssa_ihhrc_monthly_cost: 400 + is_disabled: + 2026: true + meets_ssi_disability_criteria: + 2026: true + marital_units: + person1_unit: + members: [person1] + person2_unit: + members: [person2] + person3_unit: + members: [person3] + person4_unit: + members: [person4] + families: + family: + members: [person1, person2, person3, person4] + tax_units: + family: + members: [person1, person2, person3, person4] + spm_units: + unit: + members: [person1, person2, person3, person4] + households: + home: + members: [person1, person2, person3, person4] + state_code: + 2026: IA + output: + ia_ssa_resources_deemed_from_parents: [0, 16.10, 16.10, 16.10] + ia_ssa_eligible: [false, true, true, true] diff --git a/policyengine_us/tools/general.py b/policyengine_us/tools/general.py index 5c031eb37ec..d29c1ae921a 100644 --- a/policyengine_us/tools/general.py +++ b/policyengine_us/tools/general.py @@ -28,6 +28,40 @@ def round_to_cents(amount): return np.round(np.asarray(amount, dtype=np.float64), 2) +def meets_limit_with_share(own, excess, divisor, limit): + """Whether own + excess / divisor <= limit, computed exactly. + + own, excess and limit are whole-cent amounts (round summed balances + first); the share excess / divisor need not be. Float64 addition can put + a total at the limit a hair above it (1,983.90 + 48.30 / 3 gives + 2,000.0000000000002), so compare whole cents instead: + divisor x own + excess <= divisor x limit. + """ + own_cents = np.rint(np.asarray(own, dtype=np.float64) * 100).astype(np.int64) + excess_cents = np.rint(np.asarray(excess, dtype=np.float64) * 100).astype(np.int64) + limit_cents = np.rint(np.asarray(limit, dtype=np.float64) * 100).astype(np.int64) + divisor = np.asarray(divisor).astype(np.int64) + return excess_cents <= divisor * (limit_cents - own_cents) + + +def float32_at_most(amount): + """The largest float32 at or below each amount. + + Float variables are stored as float32, and the nearest float32 can lie + above the amount: a share of 100.01 is stored as 100.010002, so own + resources of 1,899.99 plus that share exceed a 2,000 limit that the + exact total meets. Storing the float32 at or below the amount never + fails a total that meets the limit. A total over a whole-cent limit + exceeds it by at least a cent divided by the share's divisor, which is + more than float32's step for any share below 2**11 dollars and divisor + below 80, so there the comparison stays exact both ways. + """ + amount = np.asarray(amount, dtype=np.float64) + nearest = amount.astype(np.float32) + below = np.nextafter(nearest, np.float32(-np.inf)) + return np.where(nearest.astype(np.float64) > amount, below, nearest) + + def has_input_for_period(simulation, variable, period): """Whether the visible array for this exact period was set as an input. diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py index 28334d22c0a..c146f90f560 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py @@ -152,16 +152,22 @@ def formula(person, period, parameters): pool_count = int(np.max(pool, initial=-1)) + 1 for _ in range(rounds): count = np.bincount(pool[active & income_eligible], minlength=pool_count) + divisor = max_(1, count[pool]) # The share is a division, not a sum of balances, so it stays # exact: SI 01330.200 B says to 'equally divide the value of the # deemed resources among those children', and 416.1202(b)(1) sets - # no rule for rounding a child's share. + # no rule for rounding a child's share. Own resources and the + # excess are whole cents, so test own + share in whole cents. # https://secure.ssa.gov/poms.nsf/lnx/0501330200 # https://www.law.cornell.edu/cfr/text/20/416.1202 - share = excess / max_(1, count[pool]) + share = excess / divisor deemed = where(active, share, deemed) - remaining = active & (own_resources + share <= p.individual) + remaining = active & meets_limit_with_share( + own_resources, excess, divisor, p.individual + ) if np.array_equal(active, remaining): break active = remaining - return deemed + # Stored as float32, a share must not round up: own resources plus + # the share read back would then exceed a limit the exact total meets. + return float32_at_most(deemed) diff --git a/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.py b/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.py index 7ffa7cf73c7..312f25dec08 100644 --- a/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.py +++ b/policyengine_us/variables/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.py @@ -53,21 +53,28 @@ def formula(person, period, parameters): person, period, resources ) allowance = where(parent_count > 1, limit.couple, limit.individual) - excess = max_(parental_resources - allowance, 0) + # Balances are float32 inputs, so round the deemors' total and the + # child's own balances to cents, as SSI's deeming does. The share + # stays exact, so own + share is tested in whole cents. + excess = max_(round_to_cents(parental_resources) - allowance, 0) child = person("is_ssi_resource_deeming_child", period) ihhrc = person("ia_ssa_nonfinancial_eligible", period) & ( person("ia_ssa_ihhrc_amount", period) > 0 ) - own = person("ssi_countable_resources", period.this_year) + own = round_to_cents(person("ssi_countable_resources", period.this_year)) eligible = child & (receives_ssi | ihhrc) & (own <= limit.individual) pool_count = int(np.max(pool, initial=-1)) + 1 share = excess # Each round removes at least one child or leaves the result stable. for _ in range(int(np.max(person.household.nb_persons(), initial=0)) + 1): count = np.bincount(pool[eligible], minlength=pool_count) - share = excess / max_(count[pool], 1) - remaining = eligible & (own + share <= limit.individual) + divisor = max_(count[pool], 1) + share = excess / divisor + remaining = eligible & meets_limit_with_share( + own, excess, divisor, limit.individual + ) if np.array_equal(remaining, eligible): break eligible = remaining - return child * share + # Stored as float32, a share must not round up past the exact total. + return float32_at_most(child * share) From 26d99e56a36f5bedd3f900d12dd8d99a395269be Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 05:58:06 +0000 Subject: [PATCH 10/16] Say in the changelog that a parental deeming share is compared exactly Co-Authored-By: Claude Opus 5.5 --- changelog.d/round-summed-limits.fixed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/round-summed-limits.fixed.md b/changelog.d/round-summed-limits.fixed.md index 548cceea1c7..a78a2e3c648 100644 --- a/changelog.d/round-summed-limits.fixed.md +++ b/changelog.d/round-summed-limits.fixed.md @@ -1 +1 @@ -Round summed resources to whole cents before SSI, SNAP, Medicaid, Medicare Savings Program and state asset tests compare them with their dollar limits, so balances that add to exactly a limit pass or fail as the total does. +Round summed resources to whole cents before SSI, SNAP, Medicaid, Medicare Savings Program and state asset tests compare them with their dollar limits, so balances that add to exactly a limit pass or fail as the total does. A child's share of parental resources stays unrounded and is compared exactly. From cc8622208bc221cb82bfea8788d84a2918f7c7e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 06:15:13 +0000 Subject: [PATCH 11/16] Pin the rounding of a child's own balances in the SSI deeming loop The whole-cent comparison converts own resources to cents itself, so no test caught dropping the loop's own-resource rounding. The loop still needs it to decide which children are deemed at all: a child whose balances total exactly $2,000 would add to 2,000.0001, be left out of the deeming, and pass on their own resources. This case expects the child to be deemed the parent's 100 of excess and fail. Co-Authored-By: Claude Opus 5.5 --- ...sources_deemed_from_ineligible_parent.yaml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 347927b3a52..6755de7315b 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -699,6 +699,43 @@ ssi_resources_deemed_from_ineligible_parent: [0, 16.10, 16.10, 16.10] meets_ssi_resource_test: [false, true, true, true] +# 20 CFR 416.1202(b)(1): the child's own 178.57 + 1,547.79 + 273.64 = +# 2,000.00 is at the individual limit, so the child is deemed the parent's +# 100 of excess and fails at 2,100.00. The float32 balances add to +# 2,000.0001 unless rounded to cents, which would leave the child out of the +# deeming and pass them on their own 2,000.00. +- name: A child whose own accounts total exactly the limit is still deemed the parental excess + period: 2026-01 + input: + people: + parent: + age: 40 + is_ssi_aged_blind_disabled: false + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_100 + child: + age: 16 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 178.57 + stock_assets: 1_547.79 + bond_assets: 273.64 + tax_units: + tax_unit: + members: [parent, child] + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + output: + ssi_resources_deemed_from_ineligible_parent: [0, 100] + meets_ssi_resource_test: [false, false] + # POMS SI 01330.340 White example: parent pool1200 <=couple limit3000; child deemed0. - name: POMS White eligible parent leaves no excess resources to deem period: 2024-01 From 122d8fd961580dc5995c79b2f3e3a936f6ab56a3 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 3 Nov 2026 17:46:29 -0500 Subject: [PATCH 12/16] Correct the float64 example in the exact-share comments 1,983.90 + 48.30 / 3 is exactly 2,000.0 in float64. The drift comes from forming the excess as 2,048.30 - 2,000, which gives 48.30000000000018; 1,983.90 plus a third of that gives 2,000.0000000000002. Comments only. Co-Authored-By: Claude Opus 5.5 --- .../deemed/ssi_resources_deemed_from_ineligible_parent.yaml | 5 +++-- .../ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml | 5 +++-- policyengine_us/tools/general.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 6755de7315b..515fd731e6b 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -654,8 +654,9 @@ # SI 01330.200 B: the parent's 2,048.30 is 48.30 over the individual limit, # which divides among three children as 16.10 each. The first child's # 1,983.90 plus 16.10 is exactly 2,000.00, so all three stay in the division -# and pass. In float64, 1,983.90 + 48.30 / 3 is 2,000.0000000000002, which -# would remove the first child and raise the others' shares. +# and pass. In float64, 2,048.30 - 2,000 gives an excess of 48.30000000000018, +# and 1,983.90 plus a third of it gives 2,000.0000000000002, which would +# remove the first child and raise the others' shares. - name: A child whom a share reaches exactly to the limit stays in the division period: 2026-01 input: diff --git a/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml index 48504beceeb..f998bf24a8e 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml @@ -638,8 +638,9 @@ # The parent's 48.30 of excess divides among three children as 16.10 each. # The first child's 1,983.90 plus 16.10 is exactly 2,000.00. In float64, -# 1,983.90 + 48.30 / 3 is 2,000.0000000000002, which would leave the first -# child out of the division. +# 2,048.30 - 2,000 gives an excess of 48.30000000000018, and 1,983.90 plus a +# third of it gives 2,000.0000000000002, which would leave the first child +# out of the division. - name: Case 11, a child whom a share reaches exactly to the limit stays in the division. period: 2026-01 absolute_error_margin: 0.01 diff --git a/policyengine_us/tools/general.py b/policyengine_us/tools/general.py index d29c1ae921a..90d9ad38984 100644 --- a/policyengine_us/tools/general.py +++ b/policyengine_us/tools/general.py @@ -32,8 +32,9 @@ def meets_limit_with_share(own, excess, divisor, limit): """Whether own + excess / divisor <= limit, computed exactly. own, excess and limit are whole-cent amounts (round summed balances - first); the share excess / divisor need not be. Float64 addition can put - a total at the limit a hair above it (1,983.90 + 48.30 / 3 gives + first); the share excess / divisor need not be. Float64 arithmetic can + put a total at the limit a hair above it (2,048.30 - 2,000 gives an + excess of 48.30000000000018, and 1,983.90 plus a third of it gives 2,000.0000000000002), so compare whole cents instead: divisor x own + excess <= divisor x limit. """ From 5f2a15314df2cb24df87117021ebca04f1cb1a64 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 29 Nov 2026 21:40:15 +0000 Subject: [PATCH 13/16] Round county and North Carolina asset totals Round summed cash, property and assessed values before comparing them with asset limits. Keep fractions of a cent from average vehicle values. Use the shared rounding helper in Riverside. Handle infinite SSI resource limits before converting to integer cents. Co-Authored-By: GPT-6.2 Sol --- changelog.d/round-summed-limits.fixed.md | 2 +- ...assistance_personal_property_eligible.yaml | 36 +++++++ ...assistance_personal_property_eligible.yaml | 28 ++++++ ...la_general_relief_cash_asset_eligible.yaml | 86 +++++++++++++++++ ...la_general_relief_home_value_eligible.yaml | 38 ++++++++ ..._general_relief_liquid_asset_eligible.yaml | 20 ++++ ...ral_relief_personal_property_eligible.yaml | 50 ++++++++++ ..._oc_general_relief_resources_eligible.yaml | 18 ++++ ...sbd_general_relief_resources_eligible.yaml | 96 +++++++++++++++++++ ...assistance_personal_property_eligible.yaml | 30 ++++++ ...ca_sf_caap_personal_property_eligible.yaml | 24 +++++ ..._general_assistance_property_eligible.yaml | 48 ++++++++++ .../states/nc/ncdhhs/sa/nc_sa_eligible.yaml | 26 +++++ .../tests/unit/test_meets_limit_with_share.py | 25 +++++ policyengine_us/tools/general.py | 32 +++++-- ...l_assistance_personal_property_eligible.py | 2 +- ...l_assistance_personal_property_eligible.py | 24 +++-- .../la_general_relief_cash_asset_eligible.py | 2 +- .../la_general_relief_home_value_eligible.py | 2 +- ...in_general_relief_liquid_asset_eligible.py | 2 +- ...neral_relief_personal_property_eligible.py | 21 ++-- ...ca_oc_general_relief_resources_eligible.py | 2 +- ...ca_riv_general_relief_property_eligible.py | 2 +- ...a_sbd_general_relief_resources_eligible.py | 8 +- ...l_assistance_personal_property_eligible.py | 24 +++-- .../ca_sf_caap_personal_property_eligible.py | 2 +- ...mc_general_assistance_property_eligible.py | 9 +- .../gov/states/nc/ncdhhs/sa/nc_sa_eligible.py | 2 +- 28 files changed, 612 insertions(+), 49 deletions(-) create mode 100644 policyengine_us/tests/unit/test_meets_limit_with_share.py diff --git a/changelog.d/round-summed-limits.fixed.md b/changelog.d/round-summed-limits.fixed.md index a78a2e3c648..c842f4872bb 100644 --- a/changelog.d/round-summed-limits.fixed.md +++ b/changelog.d/round-summed-limits.fixed.md @@ -1 +1 @@ -Round summed resources to whole cents before SSI, SNAP, Medicaid, Medicare Savings Program and state asset tests compare them with their dollar limits, so balances that add to exactly a limit pass or fail as the total does. A child's share of parental resources stays unrounded and is compared exactly. +Compare summed resources in whole cents for SSI, SNAP, Medicaid, Medicare Savings Programs and state and county asset tests. Keep each child's equal share of parental excess without rounding it to cents. diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/ala/eligibility/ca_ala_general_assistance_personal_property_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/ala/eligibility/ca_ala_general_assistance_personal_property_eligible.yaml index 7121a7acd88..a33fa0b4815 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/ala/eligibility/ca_ala_general_assistance_personal_property_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/ala/eligibility/ca_ala_general_assistance_personal_property_eligible.yaml @@ -13,3 +13,39 @@ in_ala: true output: ca_ala_general_assistance_personal_property_eligible: false + +- name: Two people's property values at the limit pass + period: 2026-01 + input: + people: + person1: + personal_property: 260.1 + person2: + personal_property: 739.9 + households: + home: + members: [person1, person2] + in_ala: true + spm_units: + family: + members: [person1, person2] + output: + ca_ala_general_assistance_personal_property_eligible: true + +- name: Two people's property values a cent over the limit fail + period: 2026-01 + input: + people: + person1: + personal_property: 260.1 + person2: + personal_property: 739.91 + households: + home: + members: [person1, person2] + in_ala: true + spm_units: + family: + members: [person1, person2] + output: + ca_ala_general_assistance_personal_property_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.yaml index f1e9951ca66..73587c73aa0 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.yaml @@ -178,3 +178,31 @@ members: [person1] output: ca_cc_general_assistance_personal_property_eligible: false + +- name: Cash and personal property at the limit pass + period: 2026-01 + input: + in_cc: true + bank_account_assets: 149.24 + personal_property: 350.76 + output: + ca_cc_general_assistance_personal_property_eligible: true + +- name: Cash and personal property a cent over the limit fail + period: 2026-01 + input: + in_cc: true + bank_account_assets: 149.24 + personal_property: 350.77 + output: + ca_cc_general_assistance_personal_property_eligible: false + +- name: Property and vehicle equity above the limit by a fraction of a cent fail + period: 2026-01 + input: + in_cc: true + personal_property: 399.99 + household_vehicles_owned: 3 + household_vehicles_value: 150.02 + output: + ca_cc_general_assistance_personal_property_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/cash/la_general_relief_cash_asset_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/cash/la_general_relief_cash_asset_eligible.yaml index d1e03832490..ec87e11398b 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/cash/la_general_relief_cash_asset_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/cash/la_general_relief_cash_asset_eligible.yaml @@ -15,3 +15,89 @@ la_general_relief_cash_asset_limit: 100 output: la_general_relief_cash_asset_eligible: true + +- name: A single applicant's accounts at the limit pass + period: 2026 + input: + in_la: true + bank_account_assets: 29.54 + stock_assets: 5.73 + bond_assets: 64.73 + output: + la_general_relief_cash_asset_eligible: true + +- name: A single applicant's accounts a cent over the limit fail + period: 2026 + input: + in_la: true + bank_account_assets: 29.54 + stock_assets: 5.73 + bond_assets: 64.74 + output: + la_general_relief_cash_asset_eligible: false + +- name: A married couple's accounts at the limit pass + period: 2026 + input: + people: + person1: + bank_account_assets: 59.08 + stock_assets: 11.46 + bond_assets: 129.46 + is_tax_unit_head: true + person2: + age: 40 + is_tax_unit_spouse: true + households: + home: + members: [person1, person2] + in_la: true + spm_units: + family: + members: [person1, person2] + output: + la_general_relief_cash_asset_eligible: true + +- name: A married couple's accounts a cent over the limit fail + period: 2026 + input: + people: + person1: + bank_account_assets: 59.08 + stock_assets: 11.46 + bond_assets: 129.47 + is_tax_unit_head: true + person2: + age: 40 + is_tax_unit_spouse: true + households: + home: + members: [person1, person2] + in_la: true + spm_units: + family: + members: [person1, person2] + output: + la_general_relief_cash_asset_eligible: false + +- name: A recipient's accounts at the limit pass + period: 2026 + input: + in_la: true + bank_account_assets: 32.56 + stock_assets: 1084.18 + bond_assets: 383.26 + la_general_relief_recipient: true + output: + la_general_relief_cash_asset_eligible: true + +- name: A recipient's accounts a cent over the limit fail + period: 2026 + input: + in_la: true + bank_account_assets: 32.56 + stock_assets: 1084.18 + bond_assets: 383.27 + la_general_relief_recipient: true + output: + la_general_relief_cash_asset_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/la_general_relief_home_value_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/la_general_relief_home_value_eligible.yaml index d6293bafaec..2db130bc864 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/la_general_relief_home_value_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/la/general_relief/eligible/la_general_relief_home_value_eligible.yaml @@ -13,3 +13,41 @@ assessed_property_value: 34_001 output: la_general_relief_home_value_eligible: false + +- name: Two shares of a home's assessed value at the limit pass + period: 2026 + input: + people: + person1: + primary_residence_value: 1754.76 + person2: + primary_residence_value: 32245.24 + households: + home: + members: [person1, person2] + in_la: true + state_code: CA + spm_units: + family: + members: [person1, person2] + output: + la_general_relief_home_value_eligible: true + +- name: Two shares of a home's assessed value a cent over the limit fail + period: 2026 + input: + people: + person1: + primary_residence_value: 1754.76 + person2: + primary_residence_value: 32245.25 + households: + home: + members: [person1, person2] + in_la: true + state_code: CA + spm_units: + family: + members: [person1, person2] + output: + la_general_relief_home_value_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.yaml index bb5a88b23e9..68f11290066 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.yaml @@ -44,3 +44,23 @@ ca_marin_general_relief_liquid_asset_limit: 800 output: ca_marin_general_relief_liquid_asset_eligible: false + +- name: Three accounts at the limit pass + period: 2026-01 + input: + in_marin: true + bank_account_assets: 118.16 + stock_assets: 22.92 + bond_assets: 258.92 + output: + ca_marin_general_relief_liquid_asset_eligible: true + +- name: Three accounts a cent over the limit fail + period: 2026-01 + input: + in_marin: true + bank_account_assets: 118.16 + stock_assets: 22.92 + bond_assets: 258.93 + output: + ca_marin_general_relief_liquid_asset_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.yaml index f7f31b6c968..94aed078729 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.yaml @@ -170,3 +170,53 @@ output: # 101 + 500 = 601 (over the limit). ca_marin_general_relief_personal_property_eligible: false + +- name: A married couple's property values at the limit pass + period: 2026-01 + input: + people: + person1: + personal_property: 1178.9 + is_tax_unit_head: true + person2: + personal_property: 21.1 + is_tax_unit_spouse: true + households: + home: + members: [person1, person2] + in_marin: true + spm_units: + family: + members: [person1, person2] + output: + ca_marin_general_relief_personal_property_eligible: true + +- name: A married couple's property values a cent over the limit fail + period: 2026-01 + input: + people: + person1: + personal_property: 1178.9 + is_tax_unit_head: true + person2: + personal_property: 21.11 + is_tax_unit_spouse: true + households: + home: + members: [person1, person2] + in_marin: true + spm_units: + family: + members: [person1, person2] + output: + ca_marin_general_relief_personal_property_eligible: false + +- name: Property and vehicle equity above the limit by a fraction of a cent fail + period: 2026-01 + input: + in_marin: true + personal_property: 499.99 + household_vehicles_owned: 3 + household_vehicles_value: 150.02 + output: + ca_marin_general_relief_personal_property_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml index eb968ca523d..557f0a6ba9b 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml @@ -32,3 +32,21 @@ in_oc: true output: ca_oc_general_relief_resources_eligible: false + +- name: Cash and countable vehicle equity at the limit pass + period: 2026-01 + input: + in_oc: true + bank_account_assets: 517.05 + household_vehicles_value: 5132.95 + output: + ca_oc_general_relief_resources_eligible: true + +- name: Cash and countable vehicle equity a cent over the limit fail + period: 2026-01 + input: + in_oc: true + bank_account_assets: 517.05 + household_vehicles_value: 5132.96 + output: + ca_oc_general_relief_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.yaml index a9e5f0ca4ea..64fe99a9d66 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.yaml @@ -248,3 +248,99 @@ output: # 50 <= 50 regardless of unit size. ca_sbd_general_relief_resources_eligible: true + +- name: Three accounts at the limit pass + period: 2026-01 + input: + in_sbd: true + bank_account_assets: 38.49 + stock_assets: 0.37 + bond_assets: 11.14 + output: + ca_sbd_general_relief_resources_eligible: true + +- name: Three accounts a cent over the limit fail + period: 2026-01 + input: + in_sbd: true + bank_account_assets: 38.49 + stock_assets: 0.37 + bond_assets: 11.15 + output: + ca_sbd_general_relief_resources_eligible: false + +- name: Cash and personal property at the limit pass + period: 2026-01 + input: + people: + person1: + bank_account_assets: 38.79 + personal_property: 128.82 + person2: + personal_property: 332.39 + households: + home: + members: [person1, person2] + in_sbd: true + spm_units: + family: + members: [person1, person2] + output: + ca_sbd_general_relief_resources_eligible: true + +- name: Cash and personal property a cent over the limit fail + period: 2026-01 + input: + people: + person1: + bank_account_assets: 38.79 + personal_property: 128.82 + person2: + personal_property: 332.4 + households: + home: + members: [person1, person2] + in_sbd: true + spm_units: + family: + members: [person1, person2] + output: + ca_sbd_general_relief_resources_eligible: false + +- name: Two shares of assessed real property at the limit pass + period: 2026-01 + input: + people: + person1: + primary_residence_value: 25763.47 + person2: + primary_residence_value: 6236.53 + households: + home: + members: [person1, person2] + in_sbd: true + state_code: CA + spm_units: + family: + members: [person1, person2] + output: + ca_sbd_general_relief_resources_eligible: true + +- name: Two shares of assessed real property a cent over the limit fail + period: 2026-01 + input: + people: + person1: + primary_residence_value: 25763.47 + person2: + primary_residence_value: 6236.54 + households: + home: + members: [person1, person2] + in_sbd: true + state_code: CA + spm_units: + family: + members: [person1, person2] + output: + ca_sbd_general_relief_resources_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/scc/ga/ca_scc_general_assistance_personal_property_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/scc/ga/ca_scc_general_assistance_personal_property_eligible.yaml index 2a362a6559f..e8bf9c88ef1 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/scc/ga/ca_scc_general_assistance_personal_property_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/scc/ga/ca_scc_general_assistance_personal_property_eligible.yaml @@ -131,3 +131,33 @@ in_scc: true output: ca_scc_general_assistance_personal_property_eligible: false + +- name: Three accounts at the limit pass + period: 2026-01 + input: + in_scc: true + bank_account_assets: 202.47 + stock_assets: 11.89 + bond_assets: 285.64 + output: + ca_scc_general_assistance_personal_property_eligible: true + +- name: Three accounts a cent over the limit fail + period: 2026-01 + input: + in_scc: true + bank_account_assets: 202.47 + stock_assets: 11.89 + bond_assets: 285.65 + output: + ca_scc_general_assistance_personal_property_eligible: false + +- name: Property and vehicle equity above the limit by a fraction of a cent fail + period: 2026-01 + input: + in_scc: true + personal_property: 399.99 + household_vehicles_owned: 3 + household_vehicles_value: 150.02 + output: + ca_scc_general_assistance_personal_property_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.yaml index 88391121f5a..ada4d0ecb44 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.yaml @@ -145,3 +145,27 @@ output: # Budget unit size 2 selects the $3,000 couple limit, so $2,500 is eligible. ca_sf_caap_personal_property_eligible: true + +- name: A single applicant's accounts at the limit pass + period: 2026-01 + input: + county_str: SAN_FRANCISCO_COUNTY_CA + age: 40 + immigration_status: CITIZEN + bank_account_assets: 1157.81 + stock_assets: 285.17 + bond_assets: 557.02 + output: + ca_sf_caap_personal_property_eligible: true + +- name: A single applicant's accounts a cent over the limit fail + period: 2026-01 + input: + county_str: SAN_FRANCISCO_COUNTY_CA + age: 40 + immigration_status: CITIZEN + bank_account_assets: 1157.81 + stock_assets: 285.17 + bond_assets: 557.03 + output: + ca_sf_caap_personal_property_eligible: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml index 39cf7db02f0..2facb6103f7 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml @@ -29,3 +29,51 @@ ca_smc_general_assistance_countable_property: 1_463 output: ca_smc_general_assistance_property_eligible: true + +- name: Two people's accounts at the limit fail + period: 2026 + input: + people: + person1: + bank_account_assets: 259.18 + person2: + bank_account_assets: 1175.69 + stock_assets: 29.13 + households: + home: + members: [person1, person2] + in_smc: true + spm_units: + family: + members: [person1, person2] + output: + ca_smc_general_assistance_property_eligible: false + +- name: Two people's accounts a cent under the limit pass + period: 2026 + input: + people: + person1: + bank_account_assets: 259.18 + person2: + bank_account_assets: 1175.69 + stock_assets: 29.12 + households: + home: + members: [person1, person2] + in_smc: true + spm_units: + family: + members: [person1, person2] + output: + ca_smc_general_assistance_property_eligible: true + +- name: Cash and vehicle equity below the limit by a fraction of a cent pass + period: 2026 + input: + in_smc: true + bank_account_assets: 999.99 + household_vehicles_owned: 3 + household_vehicles_value: 5088.01 + output: + ca_smc_general_assistance_property_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/states/nc/ncdhhs/sa/nc_sa_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/nc/ncdhhs/sa/nc_sa_eligible.yaml index cfcbdb4e257..bda953e00e0 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nc/ncdhhs/sa/nc_sa_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nc/ncdhhs/sa/nc_sa_eligible.yaml @@ -189,3 +189,29 @@ # SSI eligibility when the income would qualify. nc_sa_eligible: [false, false] nc_sa: [0, 0] + +- name: A non-SSI applicant's accounts at the limit pass + period: 2026-01 + input: + state_code: NC + age: 70 + social_security_retirement: 15600 + nc_sa_care_setting: ADULT_CARE_HOME + bank_account_assets: 178.57 + stock_assets: 1547.79 + bond_assets: 273.64 + output: + nc_sa_eligible: true + +- name: A non-SSI applicant's accounts a cent over the limit fail + period: 2026-01 + input: + state_code: NC + age: 70 + social_security_retirement: 15600 + nc_sa_care_setting: ADULT_CARE_HOME + bank_account_assets: 178.57 + stock_assets: 1547.79 + bond_assets: 273.65 + output: + nc_sa_eligible: false diff --git a/policyengine_us/tests/unit/test_meets_limit_with_share.py b/policyengine_us/tests/unit/test_meets_limit_with_share.py new file mode 100644 index 00000000000..34f81aae681 --- /dev/null +++ b/policyengine_us/tests/unit/test_meets_limit_with_share.py @@ -0,0 +1,25 @@ +import numpy as np + +from policyengine_us.tools.general import meets_limit_with_share + + +def test_infinite_individual_limit_keeps_children_in_the_division(): + with np.errstate(invalid="raise"): + actual = meets_limit_with_share( + own=np.array([0, 1_983.90, 1_966.67]), + excess=100, + divisor=3, + limit=np.inf, + ) + np.testing.assert_array_equal(actual, [True, True, True]) + + +def test_exact_share_comparison_with_mixed_limits(): + with np.errstate(invalid="raise"): + actual = meets_limit_with_share( + own=np.array([1_899.99, 1_966.67, 1_966.67, 0, 0]), + excess=np.array([100.01, 100, 100, 0, 0]), + divisor=np.array([1, 3, 3, 1, 1]), + limit=np.array([2_000, 2_000, np.inf, -np.inf, np.nan]), + ) + np.testing.assert_array_equal(actual, [True, False, True, False, False]) diff --git a/policyengine_us/tools/general.py b/policyengine_us/tools/general.py index 506d2f8352d..6c7c79bebb8 100644 --- a/policyengine_us/tools/general.py +++ b/policyengine_us/tools/general.py @@ -28,21 +28,33 @@ def round_to_cents(amount): return np.round(np.asarray(amount, dtype=np.float64), 2) +def has_whole_cents(amount): + """Check whether each stored value represents a whole number of cents.""" + amount = np.asarray(amount) + return amount == round_to_cents(amount).astype(amount.dtype) + + def meets_limit_with_share(own, excess, divisor, limit): - """Whether own + excess / divisor <= limit, computed exactly. - - own, excess and limit are whole-cent amounts (round summed balances - first); the share excess / divisor need not be. Float64 arithmetic can - put a total at the limit a hair above it (2,048.30 - 2,000 gives an - excess of 48.30000000000018, and 1,983.90 plus a third of it gives - 2,000.0000000000002), so compare whole cents instead: - divisor x own + excess <= divisor x limit. + """Compare own resources plus an exact share of parental excess with a limit. + + Own resources, excess and any finite limit use whole cents. The share can + include fractions of a cent. With float64, 2,048.30 minus 2,000 gives + 48.30000000000018. Adding one third of that to 1,983.90 gives + 2,000.0000000000002. Compare divisor × own + excess with divisor × limit + in integer cents. + + Positive infinity accepts every share. Negative infinity and NaN reject + every share. """ own_cents = np.rint(np.asarray(own, dtype=np.float64) * 100).astype(np.int64) excess_cents = np.rint(np.asarray(excess, dtype=np.float64) * 100).astype(np.int64) - limit_cents = np.rint(np.asarray(limit, dtype=np.float64) * 100).astype(np.int64) + limit = np.asarray(limit, dtype=np.float64) + finite = np.isfinite(limit) + finite_limits = np.where(finite, limit, 0) + limit_cents = np.rint(finite_limits * 100).astype(np.int64) divisor = np.asarray(divisor).astype(np.int64) - return excess_cents <= divisor * (limit_cents - own_cents) + within_limit = excess_cents <= divisor * (limit_cents - own_cents) + return np.where(finite, within_limit, np.isposinf(limit)) def float32_at_most(amount): diff --git a/policyengine_us/variables/gov/local/ca/ala/ga/eligibility/ca_ala_general_assistance_personal_property_eligible.py b/policyengine_us/variables/gov/local/ca/ala/ga/eligibility/ca_ala_general_assistance_personal_property_eligible.py index 63130dc355f..40cd9d1a910 100644 --- a/policyengine_us/variables/gov/local/ca/ala/ga/eligibility/ca_ala_general_assistance_personal_property_eligible.py +++ b/policyengine_us/variables/gov/local/ca/ala/ga/eligibility/ca_ala_general_assistance_personal_property_eligible.py @@ -12,4 +12,4 @@ class ca_ala_general_assistance_personal_property_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.local.ca.ala.general_assistance.personal_property personal_property = add(spm_unit, period.this_year, ["personal_property"]) - return personal_property <= p.limit + return round_to_cents(personal_property) <= p.limit diff --git a/policyengine_us/variables/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.py b/policyengine_us/variables/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.py index a889133b06a..380778db53b 100644 --- a/policyengine_us/variables/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.py +++ b/policyengine_us/variables/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.py @@ -21,13 +21,19 @@ def formula(spm_unit, period, parameters): # The brochure exempts only money held for property taxes and amounts # under $50, so cash counts toward the limit; spm_unit_cash_assets # aggregates it, and personal_property covers non-cash items. - countable_property = add( - spm_unit, - period.this_year, - [ - "spm_unit_cash_assets", - "personal_property", - "ca_cc_general_assistance_countable_vehicle_value", - ], + cash_and_property = add( + spm_unit, period.this_year, ["spm_unit_cash_assets", "personal_property"] + ) + vehicle_value = spm_unit( + "ca_cc_general_assistance_countable_vehicle_value", period.this_year + ) + countable_property = cash_and_property + vehicle_value + # Keep fractions of a cent from the average vehicle value. + return ( + where( + has_whole_cents(vehicle_value), + round_to_cents(countable_property), + countable_property, + ) + <= p.limit ) - return countable_property <= p.limit diff --git a/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/cash/la_general_relief_cash_asset_eligible.py b/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/cash/la_general_relief_cash_asset_eligible.py index 5e6856ad15f..1a373432a76 100644 --- a/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/cash/la_general_relief_cash_asset_eligible.py +++ b/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/cash/la_general_relief_cash_asset_eligible.py @@ -13,4 +13,4 @@ class la_general_relief_cash_asset_eligible(Variable): def formula(spm_unit, period, parameters): cash = spm_unit("spm_unit_cash_assets", period) limit = spm_unit("la_general_relief_cash_asset_limit", period) - return cash <= limit + return round_to_cents(cash) <= limit diff --git a/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/la_general_relief_home_value_eligible.py b/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/la_general_relief_home_value_eligible.py index b74c8c27269..1ce0b1767e9 100644 --- a/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/la_general_relief_home_value_eligible.py +++ b/policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/la_general_relief_home_value_eligible.py @@ -13,4 +13,4 @@ class la_general_relief_home_value_eligible(Variable): def formula(spm_unit, period, parameters): home_value = add(spm_unit, period, ["assessed_property_value"]) p = parameters(period).gov.local.ca.la.general_relief.eligibility.limit - return home_value <= p.home_value + return round_to_cents(home_value) <= p.home_value diff --git a/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.py b/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.py index 2d5534debf1..81e859610d7 100644 --- a/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.py +++ b/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.py @@ -15,4 +15,4 @@ def formula(spm_unit, period, parameters): # dividing the balance across months. cash = spm_unit("spm_unit_cash_assets", period.this_year) limit = spm_unit("ca_marin_general_relief_liquid_asset_limit", period) - return cash <= limit + return round_to_cents(cash) <= limit diff --git a/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.py b/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.py index 1c46e60bfd3..e3a277d09da 100644 --- a/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.py +++ b/policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/personal_property/ca_marin_general_relief_personal_property_eligible.py @@ -14,13 +14,18 @@ def formula(spm_unit, period, parameters): # unit at exactly the limit is eligible. Personal property is a # year-defined stock; read it with period.this_year so this month-defined # formula does not divide the balance across months. - countable_property = add( - spm_unit, - period.this_year, - [ - "personal_property", - "ca_marin_general_relief_countable_vehicle_value", - ], + personal_property = add(spm_unit, period.this_year, ["personal_property"]) + vehicle_value = spm_unit( + "ca_marin_general_relief_countable_vehicle_value", period.this_year ) + countable_property = personal_property + vehicle_value limit = spm_unit("ca_marin_general_relief_personal_property_limit", period) - return countable_property <= limit + # Keep fractions of a cent from the average vehicle value. + return ( + where( + has_whole_cents(vehicle_value), + round_to_cents(countable_property), + countable_property, + ) + <= limit + ) diff --git a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.py b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.py index 165082c8831..f7d96329385 100644 --- a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.py +++ b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.py @@ -16,4 +16,4 @@ def formula(spm_unit, period, parameters): countable_property = spm_unit( "ca_oc_general_relief_countable_property", period.this_year ) - return countable_property <= p.property_limit + return round_to_cents(countable_property) <= p.property_limit diff --git a/policyengine_us/variables/gov/local/ca/riv/general_relief/eligibility/ca_riv_general_relief_property_eligible.py b/policyengine_us/variables/gov/local/ca/riv/general_relief/eligibility/ca_riv_general_relief_property_eligible.py index f0d23358da0..d752b3bf45b 100644 --- a/policyengine_us/variables/gov/local/ca/riv/general_relief/eligibility/ca_riv_general_relief_property_eligible.py +++ b/policyengine_us/variables/gov/local/ca/riv/general_relief/eligibility/ca_riv_general_relief_property_eligible.py @@ -17,4 +17,4 @@ def formula(spm_unit, period, parameters): # The fact sheet's property bullet says the total cannot exceed the # limit, so a unit holding exactly the limit is eligible. # Inputs are stored as float32, so compare whole cents with the limit. - return np.round(total_property_value, 2) <= p.limit + return round_to_cents(total_property_value) <= p.limit diff --git a/policyengine_us/variables/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.py b/policyengine_us/variables/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.py index b39e9a0df29..fb8cf0683f3 100644 --- a/policyengine_us/variables/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.py +++ b/policyengine_us/variables/gov/local/ca/sbd/general_relief/eligibility/ca_sbd_general_relief_resources_eligible.py @@ -18,15 +18,17 @@ def formula(spm_unit, period, parameters): # principal residence under this limit is not modeled — vehicles # are always evaluated under the personal property test. real_property = add(spm_unit, period.this_year, ["assessed_property_value"]) - real_property_eligible = real_property <= p.real_property_limit + real_property_eligible = round_to_cents(real_property) <= p.real_property_limit countable_resources = spm_unit( "ca_sbd_general_relief_countable_resources", period.this_year ) - personal_property_eligible = countable_resources <= p.personal_property_limit + personal_property_eligible = ( + round_to_cents(countable_resources) <= p.personal_property_limit + ) # Liquid assets (cash, bank accounts, stocks, and bonds) may not # exceed the limit, modeled as a flat per-assistance-unit amount. liquid_assets = spm_unit("spm_unit_cash_assets", period.this_year) - liquid_asset_eligible = liquid_assets <= p.liquid_asset_limit + liquid_asset_eligible = round_to_cents(liquid_assets) <= p.liquid_asset_limit return ( real_property_eligible & personal_property_eligible & liquid_asset_eligible ) diff --git a/policyengine_us/variables/gov/local/ca/scc/ga/eligibility/ca_scc_general_assistance_personal_property_eligible.py b/policyengine_us/variables/gov/local/ca/scc/ga/eligibility/ca_scc_general_assistance_personal_property_eligible.py index d7190857a09..e00302fef72 100644 --- a/policyengine_us/variables/gov/local/ca/scc/ga/eligibility/ca_scc_general_assistance_personal_property_eligible.py +++ b/policyengine_us/variables/gov/local/ca/scc/ga/eligibility/ca_scc_general_assistance_personal_property_eligible.py @@ -17,13 +17,19 @@ def formula(spm_unit, period, parameters): # The handbook counts cash on hand, bank accounts, and securities as # personal property, which spm_unit_cash_assets aggregates; # personal_property covers the remaining non-cash items. - countable_property = add( - spm_unit, - period.this_year, - [ - "spm_unit_cash_assets", - "personal_property", - "ca_scc_general_assistance_countable_vehicle_value", - ], + cash_and_property = add( + spm_unit, period.this_year, ["spm_unit_cash_assets", "personal_property"] + ) + vehicle_value = spm_unit( + "ca_scc_general_assistance_countable_vehicle_value", period.this_year + ) + countable_property = cash_and_property + vehicle_value + # Keep fractions of a cent from the average vehicle value. + return ( + where( + has_whole_cents(vehicle_value), + round_to_cents(countable_property), + countable_property, + ) + <= p.limit ) - return countable_property <= p.limit diff --git a/policyengine_us/variables/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.py b/policyengine_us/variables/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.py index f9507d7c6f9..6944e00c4bb 100644 --- a/policyengine_us/variables/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.py +++ b/policyengine_us/variables/gov/local/ca/sf/caap/eligibility/ca_sf_caap_personal_property_eligible.py @@ -21,4 +21,4 @@ def formula(spm_unit, period, parameters): # reserves; units of 3+ apply the 2-person limit. Title 22 Section 50420 # scales further for larger units, but we don't track that at the moment. limit = where(budget_unit_size >= 2, p.couple, p.single) - return cash_assets <= limit + return round_to_cents(cash_assets) <= limit diff --git a/policyengine_us/variables/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.py b/policyengine_us/variables/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.py index 38de916cf1b..111fc9579a7 100644 --- a/policyengine_us/variables/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.py +++ b/policyengine_us/variables/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.py @@ -16,4 +16,11 @@ class ca_smc_general_assistance_property_eligible(Variable): def formula(spm_unit, period, parameters): p = parameters(period).gov.local.ca.smc.general_assistance.property countable = spm_unit("ca_smc_general_assistance_countable_property", period) - return countable < p.limit + vehicle_value = spm_unit( + "ca_smc_general_assistance_countable_vehicle_value", period + ) + # Keep fractions of a cent from the average vehicle value. + return ( + where(has_whole_cents(vehicle_value), round_to_cents(countable), countable) + < p.limit + ) diff --git a/policyengine_us/variables/gov/states/nc/ncdhhs/sa/nc_sa_eligible.py b/policyengine_us/variables/gov/states/nc/ncdhhs/sa/nc_sa_eligible.py index d7e56816df5..12da67e0bf2 100644 --- a/policyengine_us/variables/gov/states/nc/ncdhhs/sa/nc_sa_eligible.py +++ b/policyengine_us/variables/gov/states/nc/ncdhhs/sa/nc_sa_eligible.py @@ -59,7 +59,7 @@ def formula(person, period, parameters): over_income_for_ssi & aged_blind_disabled & immigration_eligible - & (resources <= resource_limit) + & (round_to_cents(resources) <= resource_limit) ) # "If an individual's SA payment when rounded to the nearest lower # whole dollar is $0.00, the individual is not eligible" (SA-3220 From 676bf3020d17694ceddedcff67aba2d3308fed5a Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 30 Nov 2026 15:13:15 +0000 Subject: [PATCH 14/16] Correct resource eligibility at asset boundaries Keep fractional parental shares through SSI and medically needy Medicaid eligibility. Recover countable cents for San Mateo vehicles and California Medicare Savings Programs. Apply the Orange County vehicle exemption, count Colorado spouses together, and end Idaho non-cash categorical eligibility in July 2026. Co-Authored-By: GPT-6.2 Sol --- changelog.d/round-summed-limits.fixed.md | 2 +- .../gov/hhs/tanf/non_cash/asset_limit.yaml | 5 + .../is_medically_needy_for_medicaid.yaml | 58 +++++++ .../eligibility/msp_asset_eligible.yaml | 36 +++++ .../meets_tanf_non_cash_asset_test.yaml | 15 +- ...eneral_relief_countable_vehicle_value.yaml | 8 +- ..._oc_general_relief_resources_eligible.yaml | 36 +++-- ..._general_assistance_property_eligible.yaml | 28 +++- .../resources/meets_ssi_resource_test.yaml | 151 ++++++++++++++++++ .../states/co/ssa/oap/co_oap_eligible.yaml | 30 ++++ policyengine_us/tools/general.py | 14 ++ .../is_medically_needy_for_medicaid.py | 8 +- .../eligibility/msp_asset_eligible.py | 32 +++- ..._general_relief_countable_vehicle_value.py | 8 +- ...eral_assistance_countable_vehicle_value.py | 7 +- ...resources_deemed_from_ineligible_parent.py | 12 +- .../resources/meets_ssi_resource_test.py | 14 +- .../gov/states/co/ssa/oap/co_oap_eligible.py | 18 ++- 18 files changed, 435 insertions(+), 47 deletions(-) diff --git a/changelog.d/round-summed-limits.fixed.md b/changelog.d/round-summed-limits.fixed.md index c842f4872bb..af7ff14dbc1 100644 --- a/changelog.d/round-summed-limits.fixed.md +++ b/changelog.d/round-summed-limits.fixed.md @@ -1 +1 @@ -Compare summed resources in whole cents for SSI, SNAP, Medicaid, Medicare Savings Programs and state and county asset tests. Keep each child's equal share of parental excess without rounding it to cents. +Compare summed resources in whole cents for SSI, SNAP, Medicaid, Medicare Savings Programs and state and county asset tests. Preserve fractional parental shares in SSI and medically needy Medicaid. Apply Orange County’s full vehicle exemption only to qualifying vehicles and retain San Mateo’s fractional vehicle equity. Count spouses’ combined resources for Colorado Old Age Pension and end Idaho’s non-cash SNAP categorical eligibility in July 2026. diff --git a/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml b/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml index cb99243772a..8dcf53a99da 100644 --- a/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml +++ b/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml @@ -49,6 +49,7 @@ HI: 2015-10-01: .inf ID: 2015-10-01: 5_000 + 2026-07-01: -.inf # H730 ends non-cash categorical eligibility. IL: # * 2015-10-01: .inf IN: @@ -140,6 +141,10 @@ metadata: href: https://arkleg.state.ar.us/Home/FTPDocument?path=/Assembly/Meeting+Attachments/045/27347/Exhibit+B.01+-+DHS+DCO+Emergency+Rule+-+Supplemental+Nutrition+Assistance+Program+updates+pursuant+to+Act+675+of+2023+3.31.2025.pdf#page=12 - title: "Arkansas SNAP Certification Manual, Appendix D (resource limits) and Appendix AA (Broad Based Categorical Eligibility) #page 42,80" href: https://humanservices.arkansas.gov/wp-content/uploads/SNAP-Appendices-10.01.2026.pdf#page=42 + - title: Idaho SNAP resource limit, IDAPA 16.03.04.305 + href: https://adminrules.idaho.gov/rules/current/16/160304.pdf#page=37 + - title: Idaho H730, sections 1 and 3 + href: https://legislature.idaho.gov/wp-content/uploads/sessioninfo/2026/legislation/H0730.pdf#page=2 - title: USDA BBCE States Chart, June 2026 href: https://www.fns.usda.gov/sites/default/files/resource-files/BBCE-States-Chart-June2026.pdf#page=1 - title: USDA Broad-based Categorical Eligibility diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml index b49e36f3e0c..476a1b7869f 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.yaml @@ -1821,3 +1821,61 @@ ssi_resources_deemed_from_ineligible_parent: 2026-01: [0, 100.01] is_medically_needy_for_medicaid: [false, true] + +# (101,114.01 - 2,000) / 3 = 33,038.00333..., above the 33,038 cap. +# The first child fails the SSI income test and receives the same share. +- name: New York counts a parental share fractionally above the asset limit + period: 2026 + input: + people: + parent: + age: 40 + is_tax_unit_head: true + is_parent: true + employment_income_before_lsr: 80_000 + bank_account_assets: 101_114.01 + child1: + age: 8 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 21_358 + medicaid_medically_needy_medical_expenses: 16_000 + is_optional_senior_or_disabled_for_medicaid: false + child2: + age: 10 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + child3: + age: 12 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + child4: + age: 14 + is_tax_unit_dependent: true + is_ssi_disabled: true + ssi_countable_income: 0 + is_optional_senior_or_disabled_for_medicaid: false + tax_units: + tax_unit: + members: [parent, child1, child2, child3, child4] + marital_units: + parent_unit: + members: [parent] + child1_unit: + members: [child1] + child2_unit: + members: [child2] + child3_unit: + members: [child3] + child4_unit: + members: [child4] + households: + household: + members: [parent, child1, child2, child3, child4] + state_code: NY + output: + is_medically_needy_for_medicaid: [false, false, false, false, false] diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml index e932d51a68d..92fd3ef720b 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml @@ -464,3 +464,39 @@ state_code: TX output: msp_asset_eligible: false + + +# 38,164.84 + 87,274.17 + 4,560.99 = 130,000.00, the California limit. +- name: California MSP accepts split balances at the January 2026 limit + period: 2026-01 + input: + age: 70 + state_code: CA + bank_account_assets: 38_164.84 + stock_assets: 87_274.17 + bond_assets: 4_560.99 + output: + msp_asset_eligible: true + +# 87,908.16 + 14,020.12 + 28,071.73 = 130,000.01, one cent over. +- name: California MSP rejects split balances a cent over the January 2026 limit + period: 2026-01 + input: + age: 70 + state_code: CA + bank_account_assets: 87_908.16 + stock_assets: 14_020.12 + bond_assets: 28_071.73 + output: + msp_asset_eligible: false + +# The supplied SSI total of 130,000 overrides the 200,000 account balance. +- name: California MSP uses an explicitly supplied SSI resource total + period: 2026-01 + input: + age: 70 + state_code: CA + bank_account_assets: 200_000 + ssi_countable_resources: 130_000 + output: + msp_asset_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml index d6c5832cec7..0ba8f5b1c21 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml @@ -140,7 +140,8 @@ # Idaho's 5,000 BBCE asset limit: 4,338.99 + 609.03 + 51.98 = 5,000.00. # The float32 balances add to 5,000.0005 unless rounded to cents. -- name: Three accounts that total exactly the Idaho limit pass +# Idaho ends non-cash categorical eligibility on July 1, 2026. +- name: Idaho households at the resource limit pass in June but fail in July period: 2026 input: state_code_str: ID @@ -148,10 +149,15 @@ stock_assets: 609.03 bond_assets: 51.98 output: - meets_tanf_non_cash_asset_test: true + meets_tanf_non_cash_asset_test: + 2026-06: true + 2026-07: false + is_tanf_non_cash_eligible: + 2026-06: true + 2026-07: false # 4,338.99 + 609.03 + 51.99 = 5,000.01, a cent over the limit. -- name: Three accounts a cent over the Idaho limit fail +- name: Three accounts a cent over the Idaho limit fail in June period: 2026 input: state_code_str: ID @@ -159,4 +165,5 @@ stock_assets: 609.03 bond_assets: 51.99 output: - meets_tanf_non_cash_asset_test: false + meets_tanf_non_cash_asset_test: + 2026-06: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml index e54f5fe65e9..d90328d5bc8 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml @@ -1,4 +1,4 @@ -- name: Vehicle value below the exclusion has no countable value. +- name: A vehicle at the exemption threshold is fully excluded. period: 2026 input: household_vehicles_value: 4_650 @@ -6,11 +6,11 @@ output: ca_oc_general_relief_countable_vehicle_value: 0 -- name: Vehicle value above the exclusion counts the excess. +- name: A vehicle above the exemption threshold counts in full. period: 2026 input: household_vehicles_value: 4_800 in_oc: true output: - # 4,800 - 4,650 exclusion = 150. - ca_oc_general_relief_countable_vehicle_value: 150 + # 4,800 > 4,650, so all 4,800 is countable. + ca_oc_general_relief_countable_vehicle_value: 4_800 diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml index 557f0a6ba9b..ecdcca002bf 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml @@ -1,10 +1,10 @@ # Resource check (Sec 60.2.a): countable personal property -- cash plus vehicle -# value above the $4,650 exclusion (Sec 60.4.c) -- must not exceed $1,000. +# value if the vehicle exceeds $4,650 (Sec 60.4.c) -- must not exceed $1,000. - name: Cash at the limit with a fully excluded vehicle passes. period: 2026-01 input: spm_unit_cash_assets: 1_000 - household_vehicles_value: 4_650 # 4,650 - 4,650 = 0 countable + household_vehicles_value: 4_650 # 4,650 is fully exempt in_oc: true output: ca_oc_general_relief_resources_eligible: true @@ -17,32 +17,34 @@ output: ca_oc_general_relief_resources_eligible: false -- name: A vehicle a little over the exclusion still passes. +- name: A $5,000 vehicle is fully countable and fails. period: 2026-01 input: - household_vehicles_value: 5_000 # 5,000 - 4,650 = 350 countable <= 1,000 + household_vehicles_value: 5_000 # 5,000 countable > 1,000 in_oc: true output: - ca_oc_general_relief_resources_eligible: true + ca_oc_general_relief_resources_eligible: false -- name: A vehicle whose value over the exclusion exceeds the limit fails. +- name: A $6,000 vehicle is fully countable and fails. period: 2026-01 input: - household_vehicles_value: 6_000 # 6,000 - 4,650 = 1,350 countable > 1,000 + household_vehicles_value: 6_000 # 6,000 countable > 1,000 in_oc: true output: ca_oc_general_relief_resources_eligible: false -- name: Cash and countable vehicle equity at the limit pass +# 517.05 + 5,132.95 = 5,650.00 because the vehicle exceeds 4,650. +- name: Cash and a vehicle above the exemption exceed the limit period: 2026-01 input: in_oc: true bank_account_assets: 517.05 household_vehicles_value: 5132.95 output: - ca_oc_general_relief_resources_eligible: true + ca_oc_general_relief_resources_eligible: false -- name: Cash and countable vehicle equity a cent over the limit fail +# 517.05 + 5,132.96 = 5,650.01 of countable property. +- name: A one-cent increase in nonexempt vehicle equity still fails period: 2026-01 input: in_oc: true @@ -50,3 +52,17 @@ household_vehicles_value: 5132.96 output: ca_oc_general_relief_resources_eligible: false + + +# 8.87 + 693.71 + 297.42 = 1,000.00. The 4,650 vehicle is fully exempt. +- name: Split cash at the limit with a fully exempt vehicle passes + period: 2026-01 + input: + in_oc: true + bank_account_assets: 8.87 + stock_assets: 693.71 + bond_assets: 297.42 + household_vehicles_owned: 1 + household_vehicles_value: 4_650 + output: + ca_oc_general_relief_resources_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml index 2facb6103f7..57387bd8788 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/smc/general_assistance/eligibility/ca_smc_general_assistance_property_eligible.yaml @@ -68,7 +68,9 @@ output: ca_smc_general_assistance_property_eligible: true -- name: Cash and vehicle equity below the limit by a fraction of a cent pass +# This case assumes the model's average-value proxy and deduction. +# 999.99 + (5,088.01 x 2/3 - 2,928) = 1,463.99666..., below 1,464. +- name: Cash and modeled vehicle equity below the limit by a fraction of a cent pass period: 2026 input: in_smc: true @@ -77,3 +79,27 @@ household_vehicles_value: 5088.01 output: ca_smc_general_assistance_property_eligible: true + + +# These cases use the model's combined-equity deduction. +# 1,463.87 + (5,856.26 / 2 - 2,928) = 1,464.00. The limit is strict. +- name: Cash and modeled vehicle equity at the strict property limit fail + period: 2026 + input: + in_smc: true + bank_account_assets: 1_463.87 + household_vehicles_owned: 2 + household_vehicles_value: 5_856.26 + output: + ca_smc_general_assistance_property_eligible: false + +# 1,463.86 + (5,856.26 / 2 - 2,928) = 1,463.99. +- name: Cash and modeled vehicle equity one cent below the property limit pass + period: 2026 + input: + in_smc: true + bank_account_assets: 1_463.86 + household_vehicles_owned: 2 + household_vehicles_value: 5_856.26 + output: + ca_smc_general_assistance_property_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml index f5de5317bf4..33e69abdcc4 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml @@ -485,3 +485,154 @@ output: ssi_claim_is_joint: [true, true] meets_ssi_resource_test: [false, false] + + +# (104,400.01 - 2,000) / 100 = 1,024.0001. The first child's 976 +# makes 2,000.0001, so they fail and the other 99 divide the excess. +- name: A child with resources a fraction of a cent over the limit fails + period: 2026-01 + input: + people: + parent: + age: 40 + is_parent: true + is_tax_unit_head: true + bank_account_assets: 104_400.01 + child00: + <<: &child + age: 10 + is_ssi_disabled: true + is_tax_unit_dependent: true + ssi_countable_income_monthly: 0 + bank_account_assets: 976 + child01: *child + child02: *child + child03: *child + child04: *child + child05: *child + child06: *child + child07: *child + child08: *child + child09: *child + child10: *child + child11: *child + child12: *child + child13: *child + child14: *child + child15: *child + child16: *child + child17: *child + child18: *child + child19: *child + child20: *child + child21: *child + child22: *child + child23: *child + child24: *child + child25: *child + child26: *child + child27: *child + child28: *child + child29: *child + child30: *child + child31: *child + child32: *child + child33: *child + child34: *child + child35: *child + child36: *child + child37: *child + child38: *child + child39: *child + child40: *child + child41: *child + child42: *child + child43: *child + child44: *child + child45: *child + child46: *child + child47: *child + child48: *child + child49: *child + child50: *child + child51: *child + child52: *child + child53: *child + child54: *child + child55: *child + child56: *child + child57: *child + child58: *child + child59: *child + child60: *child + child61: *child + child62: *child + child63: *child + child64: *child + child65: *child + child66: *child + child67: *child + child68: *child + child69: *child + child70: *child + child71: *child + child72: *child + child73: *child + child74: *child + child75: *child + child76: *child + child77: *child + child78: *child + child79: *child + child80: *child + child81: *child + child82: *child + child83: *child + child84: *child + child85: *child + child86: *child + child87: *child + child88: *child + child89: *child + child90: *child + child91: *child + child92: *child + child93: *child + child94: *child + child95: *child + child96: *child + child97: *child + child98: *child + child99: *child + households: + home: + members: &members [ + parent, child00, child01, child02, child03, child04, child05, child06, + child07, child08, child09, child10, child11, child12, child13, child14, + child15, child16, child17, child18, child19, child20, child21, child22, + child23, child24, child25, child26, child27, child28, child29, child30, + child31, child32, child33, child34, child35, child36, child37, child38, + child39, child40, child41, child42, child43, child44, child45, child46, + child47, child48, child49, child50, child51, child52, child53, child54, + child55, child56, child57, child58, child59, child60, child61, child62, + child63, child64, child65, child66, child67, child68, child69, child70, + child71, child72, child73, child74, child75, child76, child77, child78, + child79, child80, child81, child82, child83, child84, child85, child86, + child87, child88, child89, child90, child91, child92, child93, child94, + child95, child96, child97, child98, child99 + ] + tax_units: + unit: + members: *members + output: + meets_ssi_resource_test: [ + false, false, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true + ] diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml index af164364611..7754f8130a2 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml @@ -76,3 +76,33 @@ state_code: CO output: co_oap_eligible: false + + +# 2,607.87 + 29.87 + 362.26 + 1,000 = 4,000, above the 3,000 married limit. +- name: Spouses with combined resources above the married limit both fail + period: 2026 + input: + people: + head: + age: 70 + is_tax_unit_head: true + bank_account_assets: 2_607.87 + stock_assets: 29.87 + bond_assets: 362.26 + spouse: + age: 70 + is_tax_unit_spouse: true + bank_account_assets: 1_000 + marital_units: + couple: + members: [head, spouse] + tax_units: + couple: + members: [head, spouse] + tax_unit_is_joint: true + households: + home: + members: [head, spouse] + state_code: CO + output: + co_oap_eligible: [false, false] diff --git a/policyengine_us/tools/general.py b/policyengine_us/tools/general.py index 6c7c79bebb8..b7a07e1797f 100644 --- a/policyengine_us/tools/general.py +++ b/policyengine_us/tools/general.py @@ -57,6 +57,20 @@ def meets_limit_with_share(own, excess, divisor, limit): return np.where(finite, within_limit, np.isposinf(limit)) +def meets_limit_after_deeming(own, deemed, limit): + """Compare an unrounded parental share with the remaining whole-cent limit.""" + with np.errstate(invalid="ignore"): + remaining = limit - own + remaining = np.where( + has_whole_cents(limit), round_to_cents(remaining), remaining + ) + return np.where( + np.isfinite(own) & np.isfinite(limit), + deemed <= remaining, + own + deemed <= limit, + ) + + def float32_at_most(amount): """The largest float32 at or below each amount. diff --git a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py index d5ce748738a..4bc82f760fb 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py +++ b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/medically_needy/is_medically_needy_for_medicaid.py @@ -79,9 +79,9 @@ def formula(person, period, parameters): ) # Balances are float32 inputs, so round their sum to cents. The SSI # parental share is an equal division with no rounding rule (SI - # 01330.200 B, 416.1202(b)(1)), so it is added unrounded. + # 01330.200 B, 416.1202(b)(1)), so compare it with the remaining limit. own_assets = round_to_cents(marital_unit.sum(personal_assets)) - assets = own_assets + marital_unit.sum(deemed_assets) + parental_share = marital_unit.sum(deemed_assets) ma = parameters(period).gov.hhs.medicaid mn = ma.eligibility.categories.medically_needy is_joint = marital_unit.nb_persons() == 2 @@ -92,7 +92,9 @@ def formula(person, period, parameters): mn.limit.assets.couple[state], mn.limit.assets.individual[state], ) - under_limits = (income <= income_limit) & (assets <= asset_limit) + under_limits = (income <= income_limit) & meets_limit_after_deeming( + own_assets, parental_share, asset_limit + ) other_categories = [ category for category in ma.eligibility.categories.covered diff --git a/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py b/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py index c0fa8859dd2..b19479ad4ef 100644 --- a/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py +++ b/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py @@ -20,10 +20,36 @@ def formula(person, period, parameters): p = parameters(period).gov.hhs.medicare.savings_programs.eligibility state_code = person.household("state_code_str", period) # Check if asset test applies (some states have eliminated it) - asset_test_applies = p.asset.applies[state_code] + asset_test_applies = p.asset.applies[state_code].astype(bool) # If asset test doesn't apply, everyone is asset-eligible - personal_resources = person("ssi_countable_resources", period.this_year) - married = person.spm_unit("spm_unit_is_married", period.this_year) + year = period.this_year + personal_resources = person("ssi_countable_resources", year) + california = state_code == "CA" + if np.any(california & asset_test_applies): + simulation = person.simulation + resources = simulation.tax_benefit_system.variables[ + "ssi_countable_resources" + ] + if ( + resources.adds == "gov.ssa.ssi.eligibility.resources.countable" + and resources.get_formula(year) is None + and resources.subtracts is None + and not resources.is_neutralized + and not has_input_for_period( + simulation, "ssi_countable_resources", year + ) + ): + # California's higher limits can expose a full cent of + # drift in the stored sum. Recover cents before summing. + precise_resources = np.zeros(person.count) + for source in parameters( + year + ).gov.ssa.ssi.eligibility.resources.countable: + precise_resources += round_to_cents(person(source, year)) + personal_resources = where( + california, precise_resources, personal_resources + ) + married = person.spm_unit("spm_unit_is_married", year) # Inputs are stored as float32, so compare whole cents with the limit. countable_resources = round_to_cents( where( diff --git a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py index 47716a2fecb..ff5e422b01f 100644 --- a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py +++ b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py @@ -12,9 +12,9 @@ class ca_oc_general_relief_countable_vehicle_value(Variable): reference = "https://www.ssa.ocgov.com/sites/ssa/files/2023-04/GR%20Reg%20SECTION%2060%20-%20Approved%20-%20March%202023_0.pdf#page=2" def formula(spm_unit, period, parameters): - # The exclusion amount comes off the vehicle value; the rest counts - # (Sec 60.4.c). We use total household vehicle value as a proxy for the - # one-vehicle rule. + # Section 60.4.c excludes one vehicle only if its net value is + # within the threshold. Use the household's reported vehicle value + # as a proxy when individual vehicle values are unavailable. p = parameters(period).gov.local.ca.oc.general_relief.resources vehicle_value = spm_unit.household("household_vehicles_value", period) - return max_(vehicle_value - p.vehicle_exclusion, 0) + return where(vehicle_value <= p.vehicle_exclusion, 0, vehicle_value) diff --git a/policyengine_us/variables/gov/local/ca/smc/general_assistance/property/ca_smc_general_assistance_countable_vehicle_value.py b/policyengine_us/variables/gov/local/ca/smc/general_assistance/property/ca_smc_general_assistance_countable_vehicle_value.py index dd371f4cd10..d8fac7d4452 100644 --- a/policyengine_us/variables/gov/local/ca/smc/general_assistance/property/ca_smc_general_assistance_countable_vehicle_value.py +++ b/policyengine_us/variables/gov/local/ca/smc/general_assistance/property/ca_smc_general_assistance_countable_vehicle_value.py @@ -17,14 +17,17 @@ def formula(spm_unit, period, parameters): p = parameters(period).gov.local.ca.smc.general_assistance.property household = spm_unit.household vehicle_count = household("household_vehicles_owned", period) - vehicle_value = household("household_vehicles_value", period) + # Recover whole cents before dividing and deducting the exemption. + vehicle_value = round_to_cents(household("household_vehicles_value", period)) average_vehicle_value = where( vehicle_count > 0, - vehicle_value / vehicle_count, + vehicle_value / max_(vehicle_count, 1), 0, ) additional_vehicle_count = max_(vehicle_count - 1, 0) additional_vehicle_equity = average_vehicle_value * additional_vehicle_count + # Approximate countable equity by deducting the combined exemption + # threshold from the estimated equity of the additional vehicles. return max_( additional_vehicle_equity - p.additional_vehicle_combined_equity_limit, 0, diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py index 48063d14a71..f79f25832ca 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py @@ -109,6 +109,11 @@ class ssi_resources_deemed_from_ineligible_parent(Variable): "https://secure.ssa.gov/poms.nsf/lnx/0501330340", ) + def __init__(self, baseline_variable=None): + super().__init__(baseline_variable) + # Eligibility thresholds can distinguish shares that float32 merges. + self.dtype = np.dtype(np.float64) + def formula(person, period, parameters): p = parameters(period).gov.ssa.ssi.eligibility.resources.limit # Under 416.1167 a temporarily absent person should be entered in @@ -124,6 +129,7 @@ def formula(person, period, parameters): # the deemors' totals, so the sum can land a fraction of a cent off # the total it represents: round it to cents before the limit comes off. excess = max_(0, round_to_cents(parental_resources) - allowance) + excess_cents = np.rint(excess * 100) # Do not discard ABD parents. SI 01330.310 B-C says zero if parent(s) # meets resource eligibility, usual deeming if not. The Ryder example # (.340) has an ABD mother failing the couple limit: 3100-3000=100. @@ -160,7 +166,7 @@ def formula(person, period, parameters): # excess are whole cents, so test own + share in whole cents. # https://secure.ssa.gov/poms.nsf/lnx/0501330200 # https://www.ecfr.gov/current/title-20/section-416.1202 - share = excess / divisor + share = excess_cents / (100 * divisor) deemed = where(active, share, deemed) remaining = active & meets_limit_with_share( own_resources, excess, divisor, p.individual @@ -168,6 +174,4 @@ def formula(person, period, parameters): if np.array_equal(active, remaining): break active = remaining - # Stored as float32, a share must not round up: own resources plus - # the share read back would then exceed a limit the exact total meets. - return float32_at_most(deemed) + return deemed diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py index 3a1349c3406..ada0ef05202 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py @@ -24,14 +24,14 @@ def formula(person, period, parameters): spouse_resources = person("ssi_resources_deemed_from_ineligible_spouse", period) parent_resources = person("ssi_resources_deemed_from_ineligible_parent", period) # Count the two spouses' resources for an eligible couple (20 CFR 416.1205(b)). - # Round summed balances to cents. Add the exact share of parental excess - # separately (SI 01330.200 B). + # Compare parental excess separately from whole-cent own and spouse balances. spouse = np.maximum(_ssi_spouse_index(person, period), 0) - countable_resources = where( - _ssi_resource_couple(person, period), - round_to_cents(personal_resources + personal_resources[spouse]), - round_to_cents(personal_resources + spouse_resources) + parent_resources, + combines_spouses = _ssi_resource_couple(person, period) + own_and_spouse = round_to_cents( + personal_resources + + where(combines_spouses, personal_resources[spouse], spouse_resources) ) + parental_share = where(combines_spouses, 0, parent_resources) # 416.1205(a): an individual living with an ineligible spouse counts # 'including the resources of the spouse' against the spouse limit. # This applies even when no income is deemed or the spouse owns zero. @@ -40,4 +40,4 @@ def formula(person, period, parameters): p.eligibility.resources.limit.couple, p.eligibility.resources.limit.individual, ) - return countable_resources <= resource_limit + return meets_limit_after_deeming(own_and_spouse, parental_share, resource_limit) diff --git a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py index 9eb4dbcb247..2b35df60110 100644 --- a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py +++ b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py @@ -1,4 +1,8 @@ from policyengine_us.model_api import * +from policyengine_us.variables.gov.states.co.ssa.oap._spouses import ( + co_oap_couple_total, + co_oap_is_married, +) class co_oap_eligible(Variable): @@ -7,13 +11,19 @@ class co_oap_eligible(Variable): label = "Colorado Old Age Pension Eligible" definition_period = YEAR defined_for = StateCode.CO + reference = ( + "https://www.coloradosos.gov/CCR/GenerateRulePdf.do?ruleVersionId=10694#page=35" + ) def formula(person, period, parameters): - # Inputs are stored as float32, so compare whole cents with the limit. - assets = round_to_cents(person("ssi_countable_resources", period)) - joint_claim = person("ssi_claim_is_joint", period) + # Section 3.520.72 applies a married limit to both spouses' resources. + own_assets = person("ssi_countable_resources", period) + assets = round_to_cents(co_oap_couple_total(person, period, own_assets)) + married = co_oap_is_married(person, period) | person( + "ssi_claim_is_joint", period + ) p = parameters(period).gov.states.co.ssa.oap - asset_limit = where(joint_claim, p.resources.couple, p.resources.single) + asset_limit = where(married, p.resources.couple, p.resources.single) below_asset_limit = assets <= asset_limit age = person("age", period) in_age_range = p.age_range.calc(age) From 8ef42721ae081cd0f653b74407d64dedbaee46b1 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 30 Nov 2026 23:09:54 +0000 Subject: [PATCH 15/16] Correct vehicle, spouse and parental resource tests Co-Authored-By: GPT-6.2 Sol --- changelog.d/round-summed-limits.fixed.md | 2 +- .../eligibility/msp_asset_eligible.yaml | 52 +++++++- ...eneral_relief_countable_vehicle_value.yaml | 22 ++++ ..._oc_general_relief_resources_eligible.yaml | 97 +++++++++++++++ ...sources_deemed_from_ineligible_parent.yaml | 35 ++++++ .../states/co/ssa/oap/co_oap_eligible.yaml | 112 +++++++++++++++++- .../baseline/gov/usda/snap/integration.yaml | 55 +++++++++ .../eligibility/msp_asset_eligible.py | 2 +- ..._general_relief_countable_vehicle_value.py | 26 +++- ...oc_general_relief_exempt_vehicle_equity.py | 19 +++ ...resources_deemed_from_ineligible_parent.py | 22 ++-- .../gov/states/co/ssa/oap/co_oap_eligible.py | 15 ++- .../household/assets/bank_account_assets.py | 5 + .../variables/household/assets/bond_assets.py | 5 + .../household/assets/stock_assets.py | 5 + .../marital_unit/is_separated_under_decree.py | 6 +- 16 files changed, 450 insertions(+), 30 deletions(-) create mode 100644 policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_exempt_vehicle_equity.py diff --git a/changelog.d/round-summed-limits.fixed.md b/changelog.d/round-summed-limits.fixed.md index af7ff14dbc1..66d6aaa45ca 100644 --- a/changelog.d/round-summed-limits.fixed.md +++ b/changelog.d/round-summed-limits.fixed.md @@ -1 +1 @@ -Compare summed resources in whole cents for SSI, SNAP, Medicaid, Medicare Savings Programs and state and county asset tests. Preserve fractional parental shares in SSI and medically needy Medicaid. Apply Orange County’s full vehicle exemption only to qualifying vehicles and retain San Mateo’s fractional vehicle equity. Count spouses’ combined resources for Colorado Old Age Pension and end Idaho’s non-cash SNAP categorical eligibility in July 2026. +Compare summed resources in whole cents for SSI, SNAP, Medicaid, Medicare Savings Programs and state and county asset tests. Preserve fractional parental shares and reform allowances in SSI and medically needy Medicaid. Exempt one qualifying vehicle's net equity in Orange County and retain fractional vehicle equity in San Mateo. Apply Colorado Old Age Pension's strict married resource limit and count both spouses' resources in intact marriages. End Idaho's non-cash SNAP categorical eligibility in July 2026. diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml index 92fd3ef720b..fe65548cf33 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.yaml @@ -439,7 +439,7 @@ 2027-07: [true, true] # 42 U.S.C. 1396d(p)(1)(C): 2,885.40 + 5,798.41 + 976.19 = 9,660.00, at the -# 2025 individual limit. The float32 balances add to 9,660.001 unless rounded. +# 2025 individual limit. - name: Three accounts that total exactly the individual limit pass period: 2025-01 input: @@ -500,3 +500,53 @@ ssi_countable_resources: 130_000 output: msp_asset_eligible: true + +# 150,000.01 + 44,999.99 = 195,000.00, at the California couple limit. +- name: California MSP accepts uneven balances at the January 2026 couple limit + period: 2026-01 + input: + people: + first: + age: 70 + bank_account_assets: 150_000.01 + second: + age: 68 + bank_account_assets: 44_999.99 + marital_units: + couple: + members: [first, second] + spm_units: + unit: + members: [first, second] + spm_unit_is_married: true + households: + home: + members: [first, second] + state_code: CA + output: + msp_asset_eligible: [true, true] + +# 150,000.02 + 44,999.99 = 195,000.01. The first balance differs by one cent. +- name: California MSP rejects uneven balances one cent above the couple limit + period: 2026-01 + input: + people: + first: + age: 70 + bank_account_assets: 150_000.02 + second: + age: 68 + bank_account_assets: 44_999.99 + marital_units: + couple: + members: [first, second] + spm_units: + unit: + members: [first, second] + spm_unit_is_married: true + households: + home: + members: [first, second] + state_code: CA + output: + msp_asset_eligible: [false, false] diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml index d90328d5bc8..17727677115 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml @@ -14,3 +14,25 @@ output: # 4,800 > 4,650, so all 4,800 is countable. ca_oc_general_relief_countable_vehicle_value: 4_800 + +# With two vehicles and only 4,650 in aggregate equity, the amount of +# equity in the one excluded vehicle is unknown. Count all 4,650. +- name: A multi-vehicle aggregate alone does not identify exempt equity + period: 2026 + input: + household_vehicles_owned: 2 + household_vehicles_value: 4_650 + in_oc: true + output: + ca_oc_general_relief_countable_vehicle_value: 4_650 + +# 4,700 in gross value minus 4,700 in secured debt leaves no net equity. +- name: A fully encumbered vehicle has no countable equity + period: 2026 + input: + household_vehicles_owned: 1 + household_vehicles_value: 4_700 + household_vehicles_debt: 4_700 + in_oc: true + output: + ca_oc_general_relief_countable_vehicle_value: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml index ecdcca002bf..614e6af1a07 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml @@ -66,3 +66,100 @@ household_vehicles_value: 4_650 output: ca_oc_general_relief_resources_eligible: true + +# Exclude the 4,650 vehicle. 100 + 900 = 1,000. +- name: One of two vehicles is exempt at the property limit + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_750 + ca_oc_general_relief_exempt_vehicle_equity: 4_650 + spm_unit_cash_assets: 900 + output: + ca_oc_general_relief_resources_eligible: true + +# Exclude the 4,650 vehicle. 100 + 900.01 = 1,000.01. +- name: One of two vehicles is exempt just above the property limit + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_750 + ca_oc_general_relief_exempt_vehicle_equity: 4_650 + spm_unit_cash_assets: 900.01 + output: + ca_oc_general_relief_resources_eligible: false + +# Exclude the 4,550 vehicle. 100 + 900 = 1,000. +- name: The second vehicle counts at the limit when both vehicles qualify + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_650 + ca_oc_general_relief_exempt_vehicle_equity: 4_550 + spm_unit_cash_assets: 900 + output: + ca_oc_general_relief_resources_eligible: true + +# Exclude the 4,550 vehicle. 100 + 900.01 = 1,000.01. +- name: The second vehicle counts when both vehicles qualify for the exemption + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_650 + ca_oc_general_relief_exempt_vehicle_equity: 4_550 + spm_unit_cash_assets: 900.01 + output: + ca_oc_general_relief_resources_eligible: false + +# 4,650 + 0.01 = 4,650.01. After the exemption, 0.01 + 999.99 = 1,000. +- name: A second vehicle with one cent of equity leaves property at the limit + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_650.01 + ca_oc_general_relief_exempt_vehicle_equity: 4_650 + spm_unit_cash_assets: 999.99 + output: + ca_oc_general_relief_resources_eligible: true + +# 4,650 + 0.01 = 4,650.01. After the exemption, 0.01 + 1,000 = 1,000.01. +- name: A second vehicle with one cent of equity takes property above the limit + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_650.01 + ca_oc_general_relief_exempt_vehicle_equity: 4_650 + spm_unit_cash_assets: 1_000 + output: + ca_oc_general_relief_resources_eligible: false + +# 2,325 + 2,325.01 = 4,650.01 too. After the exemption, 2,325 + 999.99 = 3,324.99. +- name: The same total vehicle equity can leave more countable property + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_650.01 + ca_oc_general_relief_exempt_vehicle_equity: 2_325.01 + spm_unit_cash_assets: 999.99 + output: + ca_oc_general_relief_resources_eligible: false + +# 4,650.01 - 0.01 of secured debt = 4,650 in exempt equity. +- name: A financed vehicle at the net equity threshold is exempt + period: 2026-01 + input: + in_oc: true + household_vehicles_owned: 1 + household_vehicles_value: 4_650.01 + household_vehicles_debt: 0.01 + household_vehicles_equity: 4_650 + spm_unit_cash_assets: 1_000 + output: + ca_oc_general_relief_resources_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 0dffa16ce05..54a98b7394c 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -2654,3 +2654,38 @@ ssi_resources_deemed_from_ineligible_parent: 2024-01: [0, 4_000, 4_000] 2024-12: [0, 2_000, 2_000] + +# 2,500 + 2,500 - 2,999.996 = 2,000.004 for the only child, above 2,000. +- name: A fractional-cent reformed parental allowance keeps its precision + period: 2026-01 + absolute_error_margin: 0.000001 + input: + people: + parent: + age: 40 + bank_account_assets: 2_500 + is_parent: true + spouse: + age: 40 + bank_account_assets: 2_500 + is_parent: true + child: + age: 12 + is_ssi_disabled: true + tax_units: + unit: + members: [parent, spouse, child] + tax_unit_is_joint: true + marital_units: + parents: + members: [parent, spouse] + child: + members: [child] + households: + home: + members: [parent, spouse, child] + state_code: CA + gov.ssa.ssi.eligibility.resources.limit.couple: 2_999.996 + output: + ssi_resources_deemed_from_ineligible_parent: [0, 0, 2_000.004] + meets_ssi_resource_test: [false, false, false] diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml index 7754f8130a2..542bab37722 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml @@ -38,7 +38,7 @@ output: co_oap_eligible: true -- name: Eligible couple +- name: A couple at the $3,000 limit fails period: 2023 input: age: 60 @@ -46,10 +46,9 @@ ssi_claim_is_joint: true state_code: CO output: - co_oap_eligible: true + co_oap_eligible: false -# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the limit. -# The float32 balances add to a fraction of a cent above 2,000 unless rounded to cents. +# 1,157.81 + 285.17 + 557.02 = 2,000.00, at the single limit. - name: Three accounts that total exactly the resource limit pass period: 2025 input: @@ -106,3 +105,108 @@ state_code: CO output: co_oap_eligible: [false, false] + +# 1,157.81 + 285.17 + 557.01 = 1,999.99, below the 2,000 single limit. +- name: Three accounts one cent below the single limit pass + period: 2025 + input: + age: 70 + bank_account_assets: 1_157.81 + stock_assets: 285.17 + bond_assets: 557.01 + state_code: CO + output: + co_oap_eligible: true + +# 2,499.99 + 500 = 2,999.99, below the 3,000 married limit. +- name: Intact separately filing spouses living apart pass just below the limit + period: 2026 + input: + people: + applicant: + age: 70 + bank_account_assets: 2_499.99 + spouse: + age: 55 + bank_account_assets: 500 + marital_units: + couple: + members: [applicant, spouse] + tax_units: + first: + members: [applicant] + filing_status: SEPARATE + second: + members: [spouse] + filing_status: SEPARATE + households: + first: + members: [applicant] + state_code: CO + second: + members: [spouse] + state_code: CO + output: + co_oap_eligible: [true, false] + +# 2,500 + 500 = 3,000, which equals the strict married limit. +- name: Intact separately filing spouses at the married limit fail + period: 2026 + input: + people: + applicant: + age: 70 + bank_account_assets: 2_500 + spouse: + age: 55 + bank_account_assets: 500 + marital_units: + couple: + members: [applicant, spouse] + tax_units: + first: + members: [applicant] + filing_status: SEPARATE + second: + members: [spouse] + filing_status: SEPARATE + households: + home: + members: [applicant, spouse] + state_code: CO + output: + co_oap_eligible: [false, false] + +# The applicant's 1,500 is below the 2,000 single limit. +# The legally separated spouse's 2,000 is separately owned. +- name: Legal separation excludes the nonrecipient spouse's resources + period: 2026 + input: + people: + applicant: + age: 70 + bank_account_assets: 1_500 + is_separated_under_decree: true + spouse: + age: 55 + bank_account_assets: 2_000 + is_separated_under_decree: true + marital_units: + couple: + members: [applicant, spouse] + tax_units: + first: + members: [applicant] + filing_status: SEPARATE + second: + members: [spouse] + filing_status: SEPARATE + households: + first: + members: [applicant] + state_code: CO + second: + members: [spouse] + state_code: CO + output: + co_oap_eligible: [true, false] diff --git a/policyengine_us/tests/policy/baseline/gov/usda/snap/integration.yaml b/policyengine_us/tests/policy/baseline/gov/usda/snap/integration.yaml index b1caf9afbc3..8ed0cff7930 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/snap/integration.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/snap/integration.yaml @@ -156,6 +156,61 @@ is_snap_eligible: false snap: 0 +# 4,338.99 + 609.03 + 51.98 = 5,000. The ordinary 3,000 cap applies in July. +- name: Idaho household at the BBCE resource limit loses SNAP eligibility in July + period: 2026 + input: + state_code: ID + age: 30 + is_snap_excluded_member: + 2026-06: false + 2026-07: false + bank_account_assets: 4_338.99 + stock_assets: 609.03 + bond_assets: 51.98 + output: + is_tanf_non_cash_eligible: + 2026-06: true + 2026-07: false + meets_snap_asset_test: + 2026-06: false + 2026-07: false + is_snap_eligible: + 2026-06: true + 2026-07: false + +# 3,000.00 equals the ordinary SNAP limit after Idaho ends BBCE. +- name: Idaho household at the ordinary resource limit qualifies in July + period: 2026-07 + input: + state_code: + 2026: ID + age: + 2026: 30 + is_snap_excluded_member: false + bank_account_assets: + 2026: 3_000 + output: + is_tanf_non_cash_eligible: false + meets_snap_asset_test: true + is_snap_eligible: true + +# 3,000.01 exceeds the ordinary SNAP limit after Idaho ends BBCE. +- name: Idaho household a cent above the ordinary resource limit fails in July + period: 2026-07 + input: + state_code: + 2026: ID + age: + 2026: 30 + is_snap_excluded_member: false + bank_account_assets: + 2026: 3_000.01 + output: + is_tanf_non_cash_eligible: false + meets_snap_asset_test: false + is_snap_eligible: false + - name: Colorado person aged 70 under 200% of the poverty level with net income above the limit is eligible in January 2024. period: 2024-01 input: diff --git a/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py b/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py index b19479ad4ef..099189df194 100644 --- a/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py +++ b/policyengine_us/variables/gov/hhs/medicare/savings_programs/eligibility/msp_asset_eligible.py @@ -50,7 +50,7 @@ def formula(person, period, parameters): california, precise_resources, personal_resources ) married = person.spm_unit("spm_unit_is_married", year) - # Inputs are stored as float32, so compare whole cents with the limit. + # Compare whole cents after combining both spouses' resources. countable_resources = round_to_cents( where( married, diff --git a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py index ff5e422b01f..0218db52f3e 100644 --- a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py +++ b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py @@ -12,9 +12,25 @@ class ca_oc_general_relief_countable_vehicle_value(Variable): reference = "https://www.ssa.ocgov.com/sites/ssa/files/2023-04/GR%20Reg%20SECTION%2060%20-%20Approved%20-%20March%202023_0.pdf#page=2" def formula(spm_unit, period, parameters): - # Section 60.4.c excludes one vehicle only if its net value is - # within the threshold. Use the household's reported vehicle value - # as a proxy when individual vehicle values are unavailable. p = parameters(period).gov.local.ca.oc.general_relief.resources - vehicle_value = spm_unit.household("household_vehicles_value", period) - return where(vehicle_value <= p.vehicle_exclusion, 0, vehicle_value) + household = spm_unit.household + gross = round_to_cents(household("household_vehicles_value", period)) + debt = round_to_cents(household("household_vehicles_debt", period)) + reported_equity = household("household_vehicles_equity", period) + equity = max_( + 0, + where(reported_equity != 0, round_to_cents(reported_equity), gross - debt), + ) + exempt_equity = round_to_cents( + spm_unit("ca_oc_general_relief_exempt_vehicle_equity", period) + ) + # With only an aggregate, infer the net value of a single vehicle. + # An aggregate for multiple vehicles cannot establish an exemption. + vehicle_count = household("household_vehicles_owned", period) + exempt_equity = where( + exempt_equity >= 0, exempt_equity, where(vehicle_count <= 1, equity, 0) + ) + exemption = where( + exempt_equity <= p.vehicle_exclusion, min_(exempt_equity, equity), 0 + ) + return round_to_cents(equity - exemption) diff --git a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_exempt_vehicle_equity.py b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_exempt_vehicle_equity.py new file mode 100644 index 00000000000..5b7b8d190bc --- /dev/null +++ b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_exempt_vehicle_equity.py @@ -0,0 +1,19 @@ +from policyengine_us.model_api import * + + +class ca_oc_general_relief_exempt_vehicle_equity(Variable): + value_type = float + entity = SPMUnit + label = "Equity of the exempt Orange County General Relief vehicle" + documentation = ( + "The largest individual net vehicle value within the exemption limit. " + "Supply zero if no vehicle qualifies. This input identifies the one " + "vehicle to exclude from total vehicle equity. A value of -1 means " + "the exempt vehicle equity is unknown." + ) + unit = USD + quantity_type = STOCK + definition_period = YEAR + defined_for = "in_oc" + default_value = -1 + reference = "https://www.ssa.ocgov.com/sites/ssa/files/2023-04/GR%20Reg%20SECTION%2060%20-%20Approved%20-%20March%202023_0.pdf#page=2" diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py index f79f25832ca..d11d756db9f 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py @@ -130,6 +130,8 @@ def formula(person, period, parameters): # the total it represents: round it to cents before the limit comes off. excess = max_(0, round_to_cents(parental_resources) - allowance) excess_cents = np.rint(excess * 100) + whole_cent_allowance = has_whole_cents(allowance) + whole_cent_limit = has_whole_cents(p.individual) # Do not discard ABD parents. SI 01330.310 B-C says zero if parent(s) # meets resource eligibility, usual deeming if not. The Ryder example # (.340) has an ABD mother failing the couple limit: 3100-3000=100. @@ -159,18 +161,18 @@ def formula(person, period, parameters): for _ in range(rounds): count = np.bincount(pool[active & income_eligible], minlength=pool_count) divisor = max_(1, count[pool]) - # The share is a division, not a sum of balances, so it stays - # exact: SI 01330.200 B says to 'equally divide the value of the - # deemed resources among those children', and 416.1202(b)(1) sets - # no rule for rounding a child's share. Own resources and the - # excess are whole cents, so test own + share in whole cents. - # https://secure.ssa.gov/poms.nsf/lnx/0501330200 - # https://www.ecfr.gov/current/title-20/section-416.1202 - share = excess_cents / (100 * divisor) + # SI 01330.200 B divides the excess equally. Compute the + # baseline share from whole cents and keep any reform precision. + share = where( + whole_cent_allowance, excess_cents / (100 * divisor), excess / divisor + ) deemed = where(active, share, deemed) - remaining = active & meets_limit_with_share( - own_resources, excess, divisor, p.individual + within_limit = where( + whole_cent_allowance & whole_cent_limit, + meets_limit_with_share(own_resources, excess, divisor, p.individual), + meets_limit_after_deeming(own_resources, share, p.individual), ) + remaining = active & within_limit if np.array_equal(active, remaining): break active = remaining diff --git a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py index 2b35df60110..58237336da4 100644 --- a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py +++ b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py @@ -16,15 +16,20 @@ class co_oap_eligible(Variable): ) def formula(person, period, parameters): - # Section 3.520.72 applies a married limit to both spouses' resources. + # Sections 3.520.63(D) and 3.520.72(C) exclude a legally separated + # spouse's sole property. Either spouse can report the decree. + separated = person("is_separated_under_decree", period) + couple_separated = co_oap_couple_total(person, period, separated) > 0 own_assets = person("ssi_countable_resources", period) - assets = round_to_cents(co_oap_couple_total(person, period, own_assets)) - married = co_oap_is_married(person, period) | person( - "ssi_claim_is_joint", period + couple_assets = co_oap_couple_total(person, period, own_assets) + assets = round_to_cents(where(couple_separated, own_assets, couple_assets)) + married = ~couple_separated & ( + co_oap_is_married(person, period) | person("ssi_claim_is_joint", period) ) p = parameters(period).gov.states.co.ssa.oap asset_limit = where(married, p.resources.couple, p.resources.single) - below_asset_limit = assets <= asset_limit + # Apply the strict married limit in Section 3.520.71(A)(1). + below_asset_limit = where(married, assets < asset_limit, assets <= asset_limit) age = person("age", period) in_age_range = p.age_range.calc(age) return below_asset_limit & in_age_range diff --git a/policyengine_us/variables/household/assets/bank_account_assets.py b/policyengine_us/variables/household/assets/bank_account_assets.py index 9d96085b69c..365820c8a6a 100644 --- a/policyengine_us/variables/household/assets/bank_account_assets.py +++ b/policyengine_us/variables/household/assets/bank_account_assets.py @@ -14,3 +14,8 @@ class bank_account_assets(Variable): definition_period = YEAR uprating = "gov.bls.cpi.cpi_u" reference = "https://secure.ssa.gov/poms.nsf/lnx/0501140200" + + def __init__(self, baseline_variable=None): + super().__init__(baseline_variable) + # Higher resource limits can distinguish cents lost in float32. + self.dtype = np.dtype(np.float64) diff --git a/policyengine_us/variables/household/assets/bond_assets.py b/policyengine_us/variables/household/assets/bond_assets.py index 7644bbc5d0f..21db071afa5 100644 --- a/policyengine_us/variables/household/assets/bond_assets.py +++ b/policyengine_us/variables/household/assets/bond_assets.py @@ -16,3 +16,8 @@ class bond_assets(Variable): "https://secure.ssa.gov/poms.nsf/lnx/0501140240", "https://secure.ssa.gov/poms.nsf/lnx/0501140250", ) + + def __init__(self, baseline_variable=None): + super().__init__(baseline_variable) + # Higher resource limits can distinguish cents lost in float32. + self.dtype = np.dtype(np.float64) diff --git a/policyengine_us/variables/household/assets/stock_assets.py b/policyengine_us/variables/household/assets/stock_assets.py index 1f96b09b357..62989d88555 100644 --- a/policyengine_us/variables/household/assets/stock_assets.py +++ b/policyengine_us/variables/household/assets/stock_assets.py @@ -11,3 +11,8 @@ class stock_assets(Variable): definition_period = YEAR uprating = "gov.bls.cpi.cpi_u" reference = "https://secure.ssa.gov/poms.nsf/lnx/0501140220" + + def __init__(self, baseline_variable=None): + super().__init__(baseline_variable) + # Higher resource limits can distinguish cents lost in float32. + self.dtype = np.dtype(np.float64) diff --git a/policyengine_us/variables/household/demographic/marital_unit/is_separated_under_decree.py b/policyengine_us/variables/household/demographic/marital_unit/is_separated_under_decree.py index d33d39b026a..ff2ad5c61ee 100644 --- a/policyengine_us/variables/household/demographic/marital_unit/is_separated_under_decree.py +++ b/policyengine_us/variables/household/demographic/marital_unit/is_separated_under_decree.py @@ -12,9 +12,9 @@ class is_separated_under_decree(Variable): does not count. Defaults to false because survey data cannot tell a decree from an informal separation, so is_separated alone keeps the married reading - for the EITC. Only the EITC marital test (IRC 32(d)) and New Jersey's - separate-filer rule read this input, and the federal test reads it only - from 2021. Filing status and other rules do not read it yet. + for the EITC. The EITC marital test (IRC 32(d)) reads this input from + 2021. New Jersey's separate-filer rule and Colorado's Old Age Pension + resource test also read it. """ definition_period = YEAR default_value = False From 871d058bc2f93bfa971153bf9b25fbb4054111a7 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 1 Dec 2026 11:43:27 +0000 Subject: [PATCH 16/16] Preserve exact resource eligibility and vehicle equity Restore Orange County's aggregate vehicle exemption and honor reported zero equity. Apply Colorado's strict resource cap and stop income deeming after legal separation. Preserve fractional SSI limits and cover float32 drift in SNAP and SSI totals. Co-Authored-By: GPT-6.2 Sol --- changelog.d/round-summed-limits.fixed.md | 2 +- .../gov/hhs/tanf/non_cash/asset_limit.yaml | 2 + .../meets_tanf_non_cash_asset_test.yaml | 13 ++- ...eneral_relief_countable_vehicle_value.yaml | 8 +- ..._oc_general_relief_resources_eligible.yaml | 44 ++++++++++ ...sources_deemed_from_ineligible_parent.yaml | 83 +++++++++++++++++++ .../resources/meets_ssi_resource_test.yaml | 32 ++++++- .../co/ssa/oap/co_oap_deemed_income.yaml | 38 +++++++++ .../states/co/ssa/oap/co_oap_eligible.yaml | 34 ++++++++ policyengine_us/tools/general.py | 34 +++++--- ..._general_relief_countable_vehicle_value.py | 15 ++-- ...resources_deemed_from_ineligible_parent.py | 20 ++++- .../gov/states/co/ssa/oap/_spouses.py | 6 ++ .../states/co/ssa/oap/co_oap_deemed_income.py | 7 +- .../gov/states/co/ssa/oap/co_oap_eligible.py | 10 ++- .../assets/household_vehicles_equity.py | 6 +- 16 files changed, 321 insertions(+), 33 deletions(-) diff --git a/changelog.d/round-summed-limits.fixed.md b/changelog.d/round-summed-limits.fixed.md index 66d6aaa45ca..e97e95c5393 100644 --- a/changelog.d/round-summed-limits.fixed.md +++ b/changelog.d/round-summed-limits.fixed.md @@ -1 +1 @@ -Compare summed resources in whole cents for SSI, SNAP, Medicaid, Medicare Savings Programs and state and county asset tests. Preserve fractional parental shares and reform allowances in SSI and medically needy Medicaid. Exempt one qualifying vehicle's net equity in Orange County and retain fractional vehicle equity in San Mateo. Apply Colorado Old Age Pension's strict married resource limit and count both spouses' resources in intact marriages. End Idaho's non-cash SNAP categorical eligibility in July 2026. +Compare summed resources in whole cents for SSI, SNAP, Medicaid, Medicare Savings Programs and state and county asset tests. Preserve fractional parental shares and reform limits in SSI and medically needy Medicaid. Exempt one qualifying vehicle's net equity in Orange County, honor reported zero equity, and retain fractional vehicle equity in San Mateo. Apply Colorado Old Age Pension's strict resource limit for married and legally separated applicants, and exclude legally separated spouses' resources and income. End Idaho's non-cash SNAP categorical eligibility in July 2026. diff --git a/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml b/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml index d3a53f7674e..039c370637f 100644 --- a/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml +++ b/policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml @@ -141,6 +141,8 @@ metadata: unit: currency-USD period: year reference: + - title: Idaho SNAP resource limit, IDAPA 16.03.04.305 + href: https://adminrules.idaho.gov/rules/current/16/160304.pdf#page=37 - title: "Idaho Code 56-205A(6) and (7), added by House Bill 730 (2026)" href: https://legislature.idaho.gov/statutesrules/idstat/title56/t56ch2/sect56-205a/ - title: "Idaho House Bill 730 (2026), engrossed, Section 3 (effective July 1, 2026)" diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml index 90af0df1c37..b8a42a19c32 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/tanf/non_cash/meets_tanf_non_cash_asset_test.yaml @@ -161,7 +161,6 @@ 2026-07: false # Idaho's 5,000 BBCE asset limit: 4,338.99 + 609.03 + 51.98 = 5,000.00. -# The float32 balances add to 5,000.0005 unless rounded to cents. # Idaho ends non-cash categorical eligibility on July 1, 2026. - name: Idaho households at the resource limit pass in June but fail in July period: 2026 @@ -189,3 +188,15 @@ output: meets_tanf_non_cash_asset_test: 2026-06: false + +# A float32 sum of 4,338.99 + 609.03 + 51.98 can store 5,000.00048828125. +# The underlying 5,000.00 meets the June limit. July has no BBCE asset path. +- name: An Idaho SNAP asset total with float32 drift passes at the June limit + period: 2026 + input: + state_code_str: ID + snap_assets: 5_000.00048828125 + output: + meets_tanf_non_cash_asset_test: + 2026-06: true + 2026-07: false diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml index 17727677115..cc88f101b75 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.yaml @@ -15,16 +15,16 @@ # 4,800 > 4,650, so all 4,800 is countable. ca_oc_general_relief_countable_vehicle_value: 4_800 -# With two vehicles and only 4,650 in aggregate equity, the amount of -# equity in the one excluded vehicle is unknown. Count all 4,650. -- name: A multi-vehicle aggregate alone does not identify exempt equity +# With only aggregate equity, model one vehicle worth 4,650. It is +# at the exemption threshold, so 4,650 - 4,650 = 0 is countable. +- name: A multi-vehicle total uses the aggregate exemption fallback period: 2026 input: household_vehicles_owned: 2 household_vehicles_value: 4_650 in_oc: true output: - ca_oc_general_relief_countable_vehicle_value: 4_650 + ca_oc_general_relief_countable_vehicle_value: 0 # 4,700 in gross value minus 4,700 in secured debt leaves no net equity. - name: A fully encumbered vehicle has no countable equity diff --git a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml index 614e6af1a07..b68b7332877 100644 --- a/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.yaml @@ -163,3 +163,47 @@ spm_unit_cash_assets: 1_000 output: ca_oc_general_relief_resources_eligible: true + +# Without individual vehicle values, the 4,650 total stands in for one vehicle. +# The fallback exempts all 4,650, leaving 900 in modeled countable property. +- name: Aggregate vehicle equity at the exemption qualifies without a breakdown + period: 2026 + input: + in_oc: true + household_vehicles_owned: 2 + household_vehicles_value: 4_650 + spm_unit_cash_assets: 900 + output: + ca_oc_general_relief_resources_eligible: true + ca_oc_general_relief_countable_property: 900 + +# Reported zero equity leaves 1,000 of countable cash in the first household. +# Without net equity or debt, the other household has 5,000 + 1,000 = 6,000. +- name: Reported zero net equity is distinct from omitted equity + period: 2026 + input: + people: + first: {} + second: {} + households: + first: + members: [first] + in_oc: true + household_vehicles_owned: 1 + household_vehicles_value: 5_000 + household_vehicles_equity: 0 + second: + members: [second] + in_oc: true + household_vehicles_owned: 1 + household_vehicles_value: 5_000 + spm_units: + first: + members: [first] + spm_unit_cash_assets: 1_000 + second: + members: [second] + spm_unit_cash_assets: 1_000 + output: + ca_oc_general_relief_resources_eligible: [true, false] + ca_oc_general_relief_countable_property: [1_000, 6_000] diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml index 54a98b7394c..b3a09ddbd29 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml @@ -2689,3 +2689,86 @@ output: ssi_resources_deemed_from_ineligible_parent: [0, 0, 2_000.004] meets_ssi_resource_test: [false, false, false] + +# 2,500 + 2,500 - 2,999.9999 = 2,000.0001, exactly the child's reformed limit. +- name: Resources exactly at a fractional-cent reformed limit pass + period: 2026-01 + absolute_error_margin: 0.000001 + input: + people: + parent: + age: 40 + bank_account_assets: 2_500 + is_parent: true + spouse: + age: 40 + bank_account_assets: 2_500 + is_parent: true + child: + age: 12 + is_ssi_disabled: true + tax_units: + unit: + members: [parent, spouse, child] + tax_unit_is_joint: true + marital_units: + parents: + members: [parent, spouse] + child: + members: [child] + households: + home: + members: [parent, spouse, child] + state_code: CA + gov.ssa.ssi.eligibility.resources.limit.couple: 2_999.9999 + gov.ssa.ssi.eligibility.resources.limit.individual: 2_000.0001 + output: + ssi_resources_deemed_from_ineligible_parent: [0, 0, 2_000.0001] + meets_ssi_resource_test: [false, false, true] + +# (2,048.31 - 2,000.0025) / 3 = 16.1025 per child. +# 1,983.90 + 16.1025 = 2,000.0025, so all three stay in the division. +- name: Three children at a fractional-cent limit keep their equal shares + period: 2026-01 + absolute_error_margin: 0.000001 + input: + people: + parent: + age: 40 + is_tax_unit_head: true + is_parent: true + bank_account_assets: 2_048.31 + child1: + age: 8 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_983.90 + child2: + age: 10 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_983.90 + child3: + age: 12 + is_ssi_aged_blind_disabled: true + is_tax_unit_dependent: true + bank_account_assets: 1_983.90 + tax_units: + unit: + members: [parent, child1, child2, child3] + marital_units: + parent: + members: [parent] + child1: + members: [child1] + child2: + members: [child2] + child3: + members: [child3] + households: + home: + members: [parent, child1, child2, child3] + gov.ssa.ssi.eligibility.resources.limit.individual: 2_000.0025 + output: + ssi_resources_deemed_from_ineligible_parent: [0, 16.1025, 16.1025, 16.1025] + meets_ssi_resource_test: [false, true, true, true] diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml index 33e69abdcc4..2155cebbc0c 100644 --- a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.yaml @@ -354,7 +354,7 @@ # 20 CFR 416.1202(a), 416.1205: the claimant's and the ineligible spouse's # 575.52 + 570.57 + 353.91 = 1,500.00 each add to 3,000.00, at the couple -# limit. The float32 balances add to 3,000.0002 unless rounded to cents. +# limit. - name: Spousal accounts that total exactly the couple limit pass period: 2026-01 input: @@ -421,7 +421,6 @@ meets_ssi_resource_test: [false, true] # Each spouse holds 575.52 + 570.57 + 353.91 = 1,500.00. -# The model adds the two float32 totals and gets 3,000.0002 before rounding. - name: Joint claim accounts that total exactly the couple limit pass period: 2026-01 input: @@ -636,3 +635,32 @@ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true ] + +# The float32 sum of 575.52 + 570.57 + 353.91 can store 1,500.0001220703125. +# The two underlying 1,500.00 balances add to the 3,000.00 joint limit. +- name: Joint claim totals with float32 drift pass at the couple limit + period: 2026-01 + input: + people: + claimant: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_head: true + ssi_countable_resources: 1_500.0001220703125 + spouse: + age: 40 + is_ssi_aged_blind_disabled: true + is_tax_unit_spouse: true + ssi_countable_resources: 1_500.0001220703125 + tax_units: + family: + members: [claimant, spouse] + marital_units: + family_couple_0: + members: [claimant, spouse] + households: + family: + members: [claimant, spouse] + output: + ssi_claim_is_joint: [true, true] + meets_ssi_resource_test: [true, true] diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_deemed_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_deemed_income.yaml index 33a76e95643..b47e078a14f 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_deemed_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_deemed_income.yaml @@ -682,3 +682,41 @@ state_code: NV output: co_oap_deemed_income: [319, 0] + +# The applicant's own 1,500 is below 2,000. The decree excludes the spouse's +# 2,000 of resources and 36,000 / 12 = 3,000 in monthly wages. With zero deemed +# and own income, the applicant receives 1,032 x 12 = 12,384 for 2026. +- name: A decree reported by the nonapplicant stops spousal income deeming + period: 2026 + input: + people: + applicant: + age: 60 + bank_account_assets: 1_500 + spouse: + age: 55 + bank_account_assets: 2_000 + employment_income: 36_000 + is_separated_under_decree: true + marital_units: + couple: + members: [applicant, spouse] + tax_units: + first: + members: [applicant] + filing_status: SEPARATE + second: + members: [spouse] + filing_status: SEPARATE + households: + first: + members: [applicant] + state_code: CO + second: + members: [spouse] + state_code: CO + output: + co_oap_eligible: [true, false] + co_oap_deemed_income: + 2026-01: [0, 0] + co_oap: [12_384, 0] diff --git a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml index 542bab37722..9366e9833a8 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml @@ -210,3 +210,37 @@ state_code: CO output: co_oap_eligible: [true, false] + +# Count only the applicant's 2,000 after legal separation. That equals the +# strict unmarried limit, so neither person receives a grant. +- name: Legally separated applicant at the strict unmarried limit fails + period: 2026 + input: + people: + applicant: + age: 60 + bank_account_assets: 2_000 + is_separated_under_decree: true + spouse: + age: 55 + bank_account_assets: 2_000 + marital_units: + couple: + members: [applicant, spouse] + tax_units: + first: + members: [applicant] + filing_status: SEPARATE + second: + members: [spouse] + filing_status: SEPARATE + households: + first: + members: [applicant] + state_code: CO + second: + members: [spouse] + state_code: CO + output: + co_oap_eligible: [false, false] + co_oap: [0, 0] diff --git a/policyengine_us/tools/general.py b/policyengine_us/tools/general.py index b7a07e1797f..a2ee840092f 100644 --- a/policyengine_us/tools/general.py +++ b/policyengine_us/tools/general.py @@ -8,6 +8,7 @@ get_override_branch, ) from pathlib import Path +from fractions import Fraction import pandas as pd from policyengine_us.typing import Formula @@ -57,18 +58,31 @@ def meets_limit_with_share(own, excess, divisor, limit): return np.where(finite, within_limit, np.isposinf(limit)) +def decimal_resource_difference(amount, deducted): + """Subtract decimal amounts exactly for fractional-cent resource reforms.""" + return np.array( + [ + Fraction(str(left)) - Fraction(str(right)) + for left, right in zip(amount, deducted) + ], + dtype=object, + ) + + def meets_limit_after_deeming(own, deemed, limit): - """Compare an unrounded parental share with the remaining whole-cent limit.""" + """Compare an unrounded parental share with the remaining resource limit.""" with np.errstate(invalid="ignore"): - remaining = limit - own - remaining = np.where( - has_whole_cents(limit), round_to_cents(remaining), remaining - ) - return np.where( - np.isfinite(own) & np.isfinite(limit), - deemed <= remaining, - own + deemed <= limit, - ) + own, limit = np.broadcast_arrays(own, limit) + finite = np.isfinite(own) & np.isfinite(limit) + whole_cent_limit = has_whole_cents(limit) + difference = limit - own + remaining = np.where(whole_cent_limit, round_to_cents(difference), difference) + fractional = finite & ~whole_cent_limit + if np.any(fractional): + remaining[fractional] = decimal_resource_difference( + limit[fractional], own[fractional] + ) + return np.where(finite, deemed <= remaining, own + deemed <= limit) def float32_at_most(amount): diff --git a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py index 0218db52f3e..cfb08182a88 100644 --- a/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py +++ b/policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_countable_vehicle_value.py @@ -19,17 +19,18 @@ def formula(spm_unit, period, parameters): reported_equity = household("household_vehicles_equity", period) equity = max_( 0, - where(reported_equity != 0, round_to_cents(reported_equity), gross - debt), + where( + np.isneginf(reported_equity), + gross - debt, + round_to_cents(reported_equity), + ), ) exempt_equity = round_to_cents( spm_unit("ca_oc_general_relief_exempt_vehicle_equity", period) ) - # With only an aggregate, infer the net value of a single vehicle. - # An aggregate for multiple vehicles cannot establish an exemption. - vehicle_count = household("household_vehicles_owned", period) - exempt_equity = where( - exempt_equity >= 0, exempt_equity, where(vehicle_count <= 1, equity, 0) - ) + # Use the aggregate as a proxy for one vehicle when individual + # vehicle values are unavailable. + exempt_equity = where(exempt_equity >= 0, exempt_equity, equity) exemption = where( exempt_equity <= p.vehicle_exclusion, min_(exempt_equity, equity), 0 ) diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py index d11d756db9f..336486d0ca4 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py @@ -128,10 +128,24 @@ def formula(person, period, parameters): # Balances are float32 inputs. Each deemor's are added together, then # the deemors' totals, so the sum can land a fraction of a cent off # the total it represents: round it to cents before the limit comes off. - excess = max_(0, round_to_cents(parental_resources) - allowance) + parental_resources = round_to_cents(parental_resources) + excess = max_(0, parental_resources - allowance) excess_cents = np.rint(excess * 100) whole_cent_allowance = has_whole_cents(allowance) whole_cent_limit = has_whole_cents(p.individual) + fractional = ( + ~whole_cent_allowance + & np.isfinite(allowance) + & np.isfinite(parental_resources) + ) + # Subtract and divide decimal reform amounts before converting the + # share to float64. Binary cancellation can put equality over the limit. + fractional_excess = max_( + 0, + decimal_resource_difference( + parental_resources[fractional], allowance[fractional] + ), + ) # Do not discard ABD parents. SI 01330.310 B-C says zero if parent(s) # meets resource eligibility, usual deeming if not. The Ryder example # (.340) has an ABD mother failing the couple limit: 3100-3000=100. @@ -166,6 +180,10 @@ def formula(person, period, parameters): share = where( whole_cent_allowance, excess_cents / (100 * divisor), excess / divisor ) + if fractional_excess.size: + share[fractional] = fractional_excess / divisor[fractional].astype( + object + ) deemed = where(active, share, deemed) within_limit = where( whole_cent_allowance & whole_cent_limit, diff --git a/policyengine_us/variables/gov/states/co/ssa/oap/_spouses.py b/policyengine_us/variables/gov/states/co/ssa/oap/_spouses.py index d518191f4ec..846612abd64 100644 --- a/policyengine_us/variables/gov/states/co/ssa/oap/_spouses.py +++ b/policyengine_us/variables/gov/states/co/ssa/oap/_spouses.py @@ -17,3 +17,9 @@ def co_oap_couple_total(person, year, values): def co_oap_is_married(person, year): """Marriage for OAP's shared $20 disregard (3.533(A)(2)(c)).""" return state_is_married(person, year) + + +def co_oap_has_separation_decree(person, year): + """Recognize a decree reported by either spouse (9 CCR 2503-5 3.520.63).""" + separated = person("is_separated_under_decree", year) + return co_oap_couple_total(person, year, separated) > 0 diff --git a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_deemed_income.py b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_deemed_income.py index ca6eeb4bedd..b698a142af2 100644 --- a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_deemed_income.py +++ b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_deemed_income.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.variables.gov.states.co.ssa.oap._spouses import ( co_oap_couple_total, + co_oap_has_separation_decree, ) from policyengine_us.variables.gov.states.co.ssa.oap._precision import ( cents, @@ -22,7 +23,10 @@ def formula(person, period, parameters): p = parameters(period).gov.states.co.ssa.oap # 3.534(C): no income is deemed from a spouse who receives Adult # Financial, SSI or Medicaid with income within the OAP limit. - deemable = ~person("co_oap_deeming_exempt", period) + year = period.this_year + # Section 3.520.63(D) treats legally separated clients as unmarried. + separated = co_oap_has_separation_decree(person, year) + deemable = ~(person("co_oap_deeming_exempt", period) | separated) # Monthly amounts in cents, SSI as SSA pays it (see _precision.py). ssi = ssi_paid(person("ssi", period)) earned = cents(person("ssi_earned_income", period)) * deemable @@ -53,7 +57,6 @@ def formula(person, period, parameters): # 3.520.786's exemptions apply to the client, spouse and sponsor, not # the child, so the child's gross income counts, child support and SSI # included, with no source below zero. - year = period.this_year tanf_age = parameters(period).gov.hhs.tanf.cash.eligibility.age_limit age_limit = where( person("is_in_secondary_school", year), diff --git a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py index 58237336da4..9f3afd957aa 100644 --- a/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py +++ b/policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.variables.gov.states.co.ssa.oap._spouses import ( co_oap_couple_total, + co_oap_has_separation_decree, co_oap_is_married, ) @@ -18,8 +19,7 @@ class co_oap_eligible(Variable): def formula(person, period, parameters): # Sections 3.520.63(D) and 3.520.72(C) exclude a legally separated # spouse's sole property. Either spouse can report the decree. - separated = person("is_separated_under_decree", period) - couple_separated = co_oap_couple_total(person, period, separated) > 0 + couple_separated = co_oap_has_separation_decree(person, period) own_assets = person("ssi_countable_resources", period) couple_assets = co_oap_couple_total(person, period, own_assets) assets = round_to_cents(where(couple_separated, own_assets, couple_assets)) @@ -28,8 +28,10 @@ def formula(person, period, parameters): ) p = parameters(period).gov.states.co.ssa.oap asset_limit = where(married, p.resources.couple, p.resources.single) - # Apply the strict married limit in Section 3.520.71(A)(1). - below_asset_limit = where(married, assets < asset_limit, assets <= asset_limit) + # Section 3.520.71(A)(1) requires resources below the limit. + below_asset_limit = where( + married | couple_separated, assets < asset_limit, assets <= asset_limit + ) age = person("age", period) in_age_range = p.age_range.calc(age) return below_asset_limit & in_age_range diff --git a/policyengine_us/variables/household/assets/household_vehicles_equity.py b/policyengine_us/variables/household/assets/household_vehicles_equity.py index c3226ccb086..9bb020130e3 100644 --- a/policyengine_us/variables/household/assets/household_vehicles_equity.py +++ b/policyengine_us/variables/household/assets/household_vehicles_equity.py @@ -5,8 +5,12 @@ class household_vehicles_equity(Variable): value_type = float entity = Household label = "Vehicle equity" - documentation = "Net equity in household vehicles after secured vehicle debt." + documentation = ( + "Net equity in household vehicles after secured vehicle debt. " + "Negative infinity indicates missing equity." + ) unit = USD quantity_type = STOCK definition_period = YEAR + default_value = -np.inf uprating = "gov.bls.cpi.cpi_u"