Skip to content

Commit b5b1f1d

Browse files
baogorekclaude
andcommitted
Reduce test scope for CI performance
- Reduce VARIABLES_TO_TEST to 3 representative variables (snap, income_tax, eitc) - Reduce COMBINED_FILTER_CONFIG to minimal subset for fast CI runs - Reduce N_VERIFICATION_SAMPLES from 2000 to 500 - Revert test_cds to original 4 states (NC, HI, MT, AK) instead of 8 states Tests now complete in ~4 minutes instead of 3+ hours. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b18680d commit b5b1f1d

2 files changed

Lines changed: 6 additions & 76 deletions

File tree

policyengine_us_data/tests/test_local_area_calibration/conftest.py

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,92 +19,26 @@
1919
get_calculated_variables,
2020
)
2121

22-
# Variables to test for state-level value matching
22+
# Variables to test for state-level value matching (CI uses subset for speed)
2323
# Format: (variable_name, rtol)
2424
# variable_name as per the targets in policy_data.db
2525
# rtol is relative tolerance for comparison
2626
VARIABLES_TO_TEST = [
2727
("snap", 1e-2),
28-
("health_insurance_premiums_without_medicare_part_b", 1e-2),
29-
("medicaid", 1e-2),
30-
("medicare_part_b_premiums", 1e-2),
31-
("other_medical_expenses", 1e-2),
32-
("over_the_counter_health_expenses", 1e-2),
33-
("salt_deduction", 1e-2),
34-
("spm_unit_capped_work_childcare_expenses", 1e-2),
35-
("spm_unit_capped_housing_subsidy", 1e-2),
36-
("ssi", 1e-2),
37-
("tanf", 1e-2),
38-
("tip_income", 1e-2),
39-
("unemployment_compensation", 1e-2),
4028
("income_tax", 1e-2),
41-
("income_tax", 1e-2),
42-
("qualified_business_income_deduction", 1e-2),
43-
("taxable_social_security", 1e-2),
44-
("taxable_pension_income", 1e-2),
45-
("taxable_ira_distributions", 1e-2),
46-
("taxable_interest_income", 1e-2),
47-
("tax_exempt_interest_income", 1e-2),
48-
("self_employment_income", 1e-2),
49-
("salt", 1e-2),
50-
("refundable_ctc", 1e-2),
51-
("real_estate_taxes", 1e-2),
52-
("qualified_dividend_income", 1e-2),
53-
("dividend_income", 1e-2),
54-
("adjusted_gross_income", 1e-2),
5529
("eitc", 1e-2),
5630
]
5731

58-
# Combined filter config to build matrix with all variables at once
32+
# CI filter config - minimal subset for fast CI runs
33+
# Tests 3 representative variables covering benefits, taxes, and credits
5934
COMBINED_FILTER_CONFIG = {
6035
"stratum_group_ids": [
6136
4, # SNAP targets
62-
5, # Medicaid targets
63-
112, # Unemployment compensation targets
6437
117, # Income tax targets
65-
100, # QBID targets
66-
111, # Taxable social security targets
67-
114, # Taxable pension income targets
68-
105, # Taxable IRA distributions targets
69-
106, # Taxable interest income targets
70-
107, # Tax exempt interest income targets
71-
101, # Self-employment income targets
72-
116, # Salt targets
73-
115, # Refundable CTC targets
74-
103, # Real estate taxes targets
75-
109, # Qualified dividend income targets
76-
108, # Dividend income targets
77-
3, # Adjusted gross income targets
7838
],
7939
"variables": [
8040
"snap",
81-
"health_insurance_premiums_without_medicare_part_b",
82-
"medicaid",
83-
"medicare_part_b_premiums",
84-
"other_medical_expenses",
85-
"over_the_counter_health_expenses",
86-
"salt_deduction",
87-
"spm_unit_capped_work_childcare_expenses",
88-
"spm_unit_capped_housing_subsidy",
89-
"ssi",
90-
"tanf",
91-
"tip_income",
92-
"unemployment_compensation",
93-
"income_tax",
9441
"income_tax",
95-
"qualified_business_income_deduction",
96-
"taxable_social_security",
97-
"taxable_pension_income",
98-
"taxable_ira_distributions",
99-
"taxable_interest_income",
100-
"tax_exempt_interest_income",
101-
"self_employment_income",
102-
"salt",
103-
"refundable_ctc",
104-
"real_estate_taxes",
105-
"qualified_dividend_income",
106-
"dividend_income",
107-
"adjusted_gross_income",
10842
"eitc",
10943
],
11044
}
@@ -113,7 +47,7 @@
11347
MAX_MISMATCH_RATE = 0.02
11448

11549
# Number of samples for cell-level verification tests
116-
N_VERIFICATION_SAMPLES = 2000
50+
N_VERIFICATION_SAMPLES = 500
11751

11852

11953
@pytest.fixture(scope="module")
@@ -129,7 +63,7 @@ def dataset_path():
12963

13064
@pytest.fixture(scope="module")
13165
def test_cds(db_uri):
132-
"""CDs from multiple states for comprehensive testing."""
66+
"""CDs from NC, HI, MT, AK (manageable size for CI, multiple same-state CDs)."""
13367
engine = create_engine(db_uri)
13468
query = """
13569
SELECT DISTINCT sc.value as cd_geoid
@@ -142,10 +76,6 @@ def test_cds(db_uri):
14276
OR sc.value LIKE '150_'
14377
OR sc.value LIKE '300_'
14478
OR sc.value = '200' OR sc.value = '201'
145-
OR sc.value IN ('101', '102')
146-
OR sc.value IN ('601', '602')
147-
OR sc.value IN ('3601', '3602')
148-
OR sc.value IN ('4801', '4802')
14979
)
15080
ORDER BY sc.value
15181
"""

policyengine_us_data/tests/test_local_area_calibration/test_matrix_national_variation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_national_targets_receive_multistate_contributions(
177177
min_states = stats_df["n_states"].min()
178178

179179
# Check: on average, contributions should come from multiple states
180-
# (at least 2, since we have CDs from 6 different states)
180+
# (at least 2, since we have CDs from 4 different states)
181181
passed = avg_states >= 2 and min_states >= 1
182182

183183
results.append(

0 commit comments

Comments
 (0)