Skip to content

Commit 8db7257

Browse files
committed
Map Arch SOI alimony facts
1 parent 666cc72 commit 8db7257

5 files changed

Lines changed: 139 additions & 20 deletions

File tree

src/microplex_us/policyengine/target_profiles.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -770,15 +770,6 @@ def _target_cell_key(cell: PolicyEngineUSTargetCell) -> PolicyEngineUSTargetCell
770770
"Loaded SOI state AGI sources provide return counts and AGI amounts, "
771771
"not filer-person counts by AGI band."
772772
),
773-
(
774-
"alimony_expense",
775-
"national",
776-
None,
777-
None,
778-
): (
779-
"No accepted primary source mapping is encoded for this "
780-
"survey/model-input expense variable."
781-
),
782773
(
783774
"child_support_expense",
784775
"national",

src/microplex_us/targets/arch.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"taxable_interest_amount": "taxable_interest_income",
9393
"tax_exempt_interest_amount": "tax_exempt_interest_income",
9494
"alimony_received_amount": "alimony_income",
95+
"alimony_paid_amount": "alimony_expense",
9596
"personal_dividend_income_amount": "dividend_income",
9697
"ordinary_dividends_amount": "dividend_income",
9798
"qualified_dividends_amount": "qualified_dividend_income",
@@ -275,6 +276,16 @@
275276
),
276277
"tanf_family_count": ("spm_unit_count", EntityType.SPM_UNIT, "tanf"),
277278
"tanf_recipient_count": ("person_count", EntityType.PERSON, "tanf"),
279+
"alimony_received_returns": (
280+
"tax_unit_count",
281+
EntityType.TAX_UNIT,
282+
"alimony_income",
283+
),
284+
"alimony_paid_returns": (
285+
"tax_unit_count",
286+
EntityType.TAX_UNIT,
287+
"alimony_expense",
288+
),
278289
}
279290

280291
ARCH_FACT_CONCEPT_TO_TARGET = {
@@ -300,6 +311,16 @@
300311
"taxable_social_security_returns",
301312
"COUNT",
302313
),
314+
"irs_soi.returns_with_alimony_received": (
315+
"alimony_received_returns",
316+
"COUNT",
317+
),
318+
"irs_soi.alimony_received": ("alimony_received_amount", "AMOUNT"),
319+
"irs_soi.returns_with_alimony_paid": (
320+
"alimony_paid_returns",
321+
"COUNT",
322+
),
323+
"irs_soi.alimony_paid": ("alimony_paid_amount", "AMOUNT"),
303324
"irs_soi.returns_with_income_tax_after_credits": (
304325
"income_tax_liability_returns",
305326
"COUNT",
@@ -1067,7 +1088,6 @@
10671088

10681089
ARCH_DEPRIORITIZED_SURVEY_OR_MODEL_GAP_VARIABLES = frozenset(
10691090
{
1070-
"alimony_expense",
10711091
"child_support_expense",
10721092
"child_support_received",
10731093
"health_insurance_premiums_without_medicare_part_b",

tests/policyengine/test_target_profiles.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ def test_source_backed_profile_excludes_only_documented_non_source_cells() -> No
370370
}
371371

372372
assert len(broad_cells) == 189
373-
assert len(exclusion_reasons) == 23
373+
assert len(exclusion_reasons) == 22
374374
assert all(reason for reason in exclusion_reasons.values())
375375
assert set(exclusion_reasons) <= broad_cells
376-
assert len(source_backed_cells) == 166
376+
assert len(source_backed_cells) == 167
377377
assert source_backed_cells == broad_cells - set(exclusion_reasons)
378378
assert (
379379
"childcare_expenses",
@@ -417,6 +417,18 @@ def test_source_backed_profile_excludes_only_documented_non_source_cells() -> No
417417
None,
418418
None,
419419
) in source_backed_cells
420+
assert (
421+
"alimony_expense",
422+
"national",
423+
None,
424+
None,
425+
) in source_backed_cells
426+
assert (
427+
"alimony_income",
428+
"national",
429+
None,
430+
None,
431+
) in source_backed_cells
420432
assert (
421433
"medicare_part_b_premiums",
422434
"national",

tests/targets/test_arch.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,19 @@ def test_arch_provider_matches_current_profile_aliases(tmp_path):
907907
(
908908
9,
909909
2,
910+
"alimony_paid_amount",
911+
2023,
912+
25.0,
913+
"AMOUNT",
914+
None,
915+
"IRS_SOI",
916+
"SOI",
917+
None,
918+
None,
919+
),
920+
(
921+
10,
922+
2,
910923
"schedule_c_income_amount",
911924
2023,
912925
30.0,
@@ -918,7 +931,7 @@ def test_arch_provider_matches_current_profile_aliases(tmp_path):
918931
None,
919932
),
920933
(
921-
10,
934+
11,
922935
1,
923936
"medicaid_total_enrollment",
924937
2024,
@@ -931,7 +944,7 @@ def test_arch_provider_matches_current_profile_aliases(tmp_path):
931944
None,
932945
),
933946
(
934-
11,
947+
12,
935948
2,
936949
"wages_salaries_amount",
937950
2023,
@@ -944,7 +957,7 @@ def test_arch_provider_matches_current_profile_aliases(tmp_path):
944957
None,
945958
),
946959
(
947-
12,
960+
13,
948961
2,
949962
"wages_salaries_returns",
950963
2023,
@@ -957,7 +970,7 @@ def test_arch_provider_matches_current_profile_aliases(tmp_path):
957970
None,
958971
),
959972
(
960-
13,
973+
14,
961974
2,
962975
"schedule_c_income_returns",
963976
2023,
@@ -985,6 +998,11 @@ def test_arch_provider_matches_current_profile_aliases(tmp_path):
985998
"geo_level": "national",
986999
"domain_variable": None,
9871000
},
1001+
{
1002+
"variable": "alimony_expense",
1003+
"geo_level": "national",
1004+
"domain_variable": None,
1005+
},
9881006
{
9891007
"variable": "self_employment_income",
9901008
"geo_level": "national",
@@ -1027,18 +1045,20 @@ def test_arch_provider_matches_current_profile_aliases(tmp_path):
10271045
11,
10281046
12,
10291047
13,
1048+
14,
10301049
}
10311050
variables_by_id = {
10321051
target.metadata["target_id"]: target.metadata["variable"]
10331052
for target in target_set.targets
10341053
}
10351054
assert variables_by_id == {
10361055
8: "alimony_income",
1037-
9: "self_employment_income",
1038-
10: "person_count",
1039-
11: "employment_income",
1056+
9: "alimony_expense",
1057+
10: "self_employment_income",
1058+
11: "person_count",
10401059
12: "employment_income",
1041-
13: "self_employment_income",
1060+
13: "employment_income",
1061+
14: "self_employment_income",
10421062
}
10431063

10441064

tests/targets/test_arch_facts.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,82 @@ def test_arch_consumer_fact_jsonl_provider_maps_state_broad_soi_concepts(
17121712
)
17131713

17141714

1715+
def test_arch_consumer_fact_jsonl_provider_maps_soi_alimony_concepts(
1716+
tmp_path: Path,
1717+
) -> None:
1718+
consumer_jsonl = tmp_path / "consumer_facts.jsonl"
1719+
rows = [
1720+
_consumer_fact(
1721+
"soi-alimony-received-returns",
1722+
concept="irs_soi.returns_with_alimony_received",
1723+
domain="all_individual_income_tax_returns",
1724+
source_name="irs_soi",
1725+
source_table="Publication 1304 Table 1.4",
1726+
period={"type": "tax_year", "value": 2023},
1727+
value=183_582,
1728+
),
1729+
_consumer_fact(
1730+
"soi-alimony-received-amount",
1731+
concept="irs_soi.alimony_received",
1732+
domain="all_individual_income_tax_returns",
1733+
source_name="irs_soi",
1734+
source_table="Publication 1304 Table 1.4",
1735+
period={"type": "tax_year", "value": 2023},
1736+
value=6_686_429_000,
1737+
unit="usd",
1738+
),
1739+
_consumer_fact(
1740+
"soi-alimony-paid-returns",
1741+
concept="irs_soi.returns_with_alimony_paid",
1742+
domain="all_individual_income_tax_returns",
1743+
source_name="irs_soi",
1744+
source_table="Publication 1304 Table 1.4",
1745+
period={"type": "tax_year", "value": 2023},
1746+
value=278_541,
1747+
),
1748+
_consumer_fact(
1749+
"soi-alimony-paid-amount",
1750+
concept="irs_soi.alimony_paid",
1751+
domain="all_individual_income_tax_returns",
1752+
source_name="irs_soi",
1753+
source_table="Publication 1304 Table 1.4",
1754+
period={"type": "tax_year", "value": 2023},
1755+
value=7_497_135_000,
1756+
unit="usd",
1757+
),
1758+
]
1759+
consumer_jsonl.write_text(
1760+
"\n".join(json.dumps(row, sort_keys=True) for row in rows) + "\n"
1761+
)
1762+
1763+
target_set = ArchConsumerFactJSONLTargetProvider(consumer_jsonl).load_target_set(
1764+
TargetQuery(period=2023)
1765+
)
1766+
targets_by_arch_variable = {
1767+
target.metadata["arch_variable"]: target for target in target_set.targets
1768+
}
1769+
1770+
received_amount = targets_by_arch_variable["alimony_received_amount"]
1771+
assert received_amount.metadata["variable"] == "alimony_income"
1772+
assert received_amount.measure == "alimony_income"
1773+
1774+
received_returns = targets_by_arch_variable["alimony_received_returns"]
1775+
assert received_returns.metadata["variable"] == "tax_unit_count"
1776+
assert received_returns.aggregation.value == "count"
1777+
assert ("alimony_income", ">", "0") in _target_filter_tuples(
1778+
received_returns
1779+
)
1780+
1781+
paid_amount = targets_by_arch_variable["alimony_paid_amount"]
1782+
assert paid_amount.metadata["variable"] == "alimony_expense"
1783+
assert paid_amount.measure == "alimony_expense"
1784+
1785+
paid_returns = targets_by_arch_variable["alimony_paid_returns"]
1786+
assert paid_returns.metadata["variable"] == "tax_unit_count"
1787+
assert paid_returns.aggregation.value == "count"
1788+
assert ("alimony_expense", ">", "0") in _target_filter_tuples(paid_returns)
1789+
1790+
17151791
def test_arch_consumer_fact_jsonl_provider_maps_eitc_by_agi_and_children(
17161792
tmp_path: Path,
17171793
) -> None:

0 commit comments

Comments
 (0)