Skip to content

Commit 20356f6

Browse files
committed
Format CTC follow-up files for lint
1 parent 2798e79 commit 20356f6

3 files changed

Lines changed: 36 additions & 100 deletions

File tree

policyengine_us_data/calibration/ctc_diagnostics.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ def _build_child_age_table(work: pd.DataFrame) -> pd.DataFrame | None:
126126
weights = work["tax_unit_weight"].astype(float).to_numpy()
127127
ctc_positive = work["ctc"].astype(float).to_numpy() > 0
128128
refundable_positive = work["refundable_ctc"].astype(float).to_numpy() > 0
129-
non_refundable_positive = (
130-
work["non_refundable_ctc"].astype(float).to_numpy() > 0
131-
)
129+
non_refundable_positive = work["non_refundable_ctc"].astype(float).to_numpy() > 0
132130

133131
rows = []
134132
for label, child_counts in (
@@ -151,9 +149,7 @@ def _build_child_age_table(work: pd.DataFrame) -> pd.DataFrame | None:
151149
((ctc_positive & has_children).astype(float) * weights).sum()
152150
),
153151
"refundable_ctc_recipient_count": float(
154-
(
155-
(refundable_positive & has_children).astype(float) * weights
156-
).sum()
152+
((refundable_positive & has_children).astype(float) * weights).sum()
157153
),
158154
"non_refundable_ctc_recipient_count": float(
159155
(

policyengine_us_data/calibration/validate_national_h5.py

Lines changed: 33 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -79,99 +79,43 @@
7979
]
8080

8181
CANONICAL_CTC_REFORM_DICT = {
82-
"gov.irs.credits.eitc.max[0].amount": {
83-
"2025-01-01.2100-12-31": 2_000
84-
},
85-
"gov.irs.credits.eitc.max[1].amount": {
86-
"2025-01-01.2100-12-31": 2_000
87-
},
88-
"gov.irs.credits.eitc.max[2].amount": {
89-
"2025-01-01.2100-12-31": 2_000
90-
},
91-
"gov.irs.credits.eitc.max[3].amount": {
92-
"2025-01-01.2100-12-31": 2_000
93-
},
94-
"gov.irs.credits.ctc.phase_out.amount": {
95-
"2025-01-01.2100-12-31": 25
96-
},
97-
"gov.irs.credits.ctc.amount.arpa[0].amount": {
98-
"2025-01-01.2100-12-31": 4_800
99-
},
100-
"gov.irs.credits.ctc.amount.arpa[1].amount": {
101-
"2025-01-01.2100-12-31": 4_800
102-
},
103-
"gov.irs.credits.ctc.phase_out.arpa.amount": {
104-
"2025-01-01.2100-12-31": 25
105-
},
106-
"gov.contrib.ctc.minimum_refundable.in_effect": {
107-
"2025-01-01.2100-12-31": True
108-
},
109-
"gov.contrib.ctc.per_child_phase_in.in_effect": {
110-
"2025-01-01.2100-12-31": True
111-
},
112-
"gov.irs.credits.ctc.phase_out.arpa.in_effect": {
113-
"2025-01-01.2100-12-31": True
114-
},
115-
"gov.irs.credits.ctc.refundable.phase_in.rate": {
116-
"2025-01-01.2100-12-31": 0.2
117-
},
118-
"gov.irs.credits.eitc.phase_in_rate[0].amount": {
119-
"2025-01-01.2100-12-31": 0.2
120-
},
121-
"gov.irs.credits.eitc.phase_in_rate[1].amount": {
122-
"2025-01-01.2100-12-31": 0.2
123-
},
124-
"gov.irs.credits.eitc.phase_in_rate[2].amount": {
125-
"2025-01-01.2100-12-31": 0.2
126-
},
127-
"gov.irs.credits.eitc.phase_in_rate[3].amount": {
128-
"2025-01-01.2100-12-31": 0.2
129-
},
130-
"gov.contrib.ctc.per_child_phase_out.in_effect": {
131-
"2025-01-01.2100-12-31": True
132-
},
133-
"gov.irs.credits.ctc.phase_out.threshold.JOINT": {
134-
"2025-01-01.2100-12-31": 200_000
135-
},
136-
"gov.irs.credits.ctc.refundable.individual_max": {
137-
"2025-01-01.2100-12-31": 4_800
138-
},
139-
"gov.irs.credits.eitc.phase_out.rate[0].amount": {
140-
"2025-01-01.2100-12-31": 0.1
141-
},
142-
"gov.irs.credits.eitc.phase_out.rate[1].amount": {
143-
"2025-01-01.2100-12-31": 0.1
144-
},
145-
"gov.irs.credits.eitc.phase_out.rate[2].amount": {
146-
"2025-01-01.2100-12-31": 0.1
147-
},
148-
"gov.irs.credits.eitc.phase_out.rate[3].amount": {
149-
"2025-01-01.2100-12-31": 0.1
150-
},
82+
"gov.irs.credits.eitc.max[0].amount": {"2025-01-01.2100-12-31": 2_000},
83+
"gov.irs.credits.eitc.max[1].amount": {"2025-01-01.2100-12-31": 2_000},
84+
"gov.irs.credits.eitc.max[2].amount": {"2025-01-01.2100-12-31": 2_000},
85+
"gov.irs.credits.eitc.max[3].amount": {"2025-01-01.2100-12-31": 2_000},
86+
"gov.irs.credits.ctc.phase_out.amount": {"2025-01-01.2100-12-31": 25},
87+
"gov.irs.credits.ctc.amount.arpa[0].amount": {"2025-01-01.2100-12-31": 4_800},
88+
"gov.irs.credits.ctc.amount.arpa[1].amount": {"2025-01-01.2100-12-31": 4_800},
89+
"gov.irs.credits.ctc.phase_out.arpa.amount": {"2025-01-01.2100-12-31": 25},
90+
"gov.contrib.ctc.minimum_refundable.in_effect": {"2025-01-01.2100-12-31": True},
91+
"gov.contrib.ctc.per_child_phase_in.in_effect": {"2025-01-01.2100-12-31": True},
92+
"gov.irs.credits.ctc.phase_out.arpa.in_effect": {"2025-01-01.2100-12-31": True},
93+
"gov.irs.credits.ctc.refundable.phase_in.rate": {"2025-01-01.2100-12-31": 0.2},
94+
"gov.irs.credits.eitc.phase_in_rate[0].amount": {"2025-01-01.2100-12-31": 0.2},
95+
"gov.irs.credits.eitc.phase_in_rate[1].amount": {"2025-01-01.2100-12-31": 0.2},
96+
"gov.irs.credits.eitc.phase_in_rate[2].amount": {"2025-01-01.2100-12-31": 0.2},
97+
"gov.irs.credits.eitc.phase_in_rate[3].amount": {"2025-01-01.2100-12-31": 0.2},
98+
"gov.contrib.ctc.per_child_phase_out.in_effect": {"2025-01-01.2100-12-31": True},
99+
"gov.irs.credits.ctc.phase_out.threshold.JOINT": {"2025-01-01.2100-12-31": 200_000},
100+
"gov.irs.credits.ctc.refundable.individual_max": {"2025-01-01.2100-12-31": 4_800},
101+
"gov.irs.credits.eitc.phase_out.rate[0].amount": {"2025-01-01.2100-12-31": 0.1},
102+
"gov.irs.credits.eitc.phase_out.rate[1].amount": {"2025-01-01.2100-12-31": 0.1},
103+
"gov.irs.credits.eitc.phase_out.rate[2].amount": {"2025-01-01.2100-12-31": 0.1},
104+
"gov.irs.credits.eitc.phase_out.rate[3].amount": {"2025-01-01.2100-12-31": 0.1},
151105
"gov.irs.credits.ctc.phase_out.threshold.SINGLE": {
152106
"2025-01-01.2100-12-31": 100_000
153107
},
154-
"gov.irs.credits.eitc.phase_out.start[0].amount": {
155-
"2025-01-01.2100-12-31": 20_000
156-
},
157-
"gov.irs.credits.eitc.phase_out.start[1].amount": {
158-
"2025-01-01.2100-12-31": 20_000
159-
},
160-
"gov.irs.credits.eitc.phase_out.start[2].amount": {
161-
"2025-01-01.2100-12-31": 20_000
162-
},
163-
"gov.irs.credits.eitc.phase_out.start[3].amount": {
164-
"2025-01-01.2100-12-31": 20_000
165-
},
108+
"gov.irs.credits.eitc.phase_out.start[0].amount": {"2025-01-01.2100-12-31": 20_000},
109+
"gov.irs.credits.eitc.phase_out.start[1].amount": {"2025-01-01.2100-12-31": 20_000},
110+
"gov.irs.credits.eitc.phase_out.start[2].amount": {"2025-01-01.2100-12-31": 20_000},
111+
"gov.irs.credits.eitc.phase_out.start[3].amount": {"2025-01-01.2100-12-31": 20_000},
166112
"gov.irs.credits.ctc.phase_out.threshold.SEPARATE": {
167113
"2025-01-01.2100-12-31": 100_000
168114
},
169115
"gov.contrib.ctc.per_child_phase_out.avoid_overlap": {
170116
"2025-01-01.2100-12-31": True
171117
},
172-
"gov.irs.credits.ctc.refundable.phase_in.threshold": {
173-
"2025-01-01.2100-12-31": 0
174-
},
118+
"gov.irs.credits.ctc.refundable.phase_in.threshold": {"2025-01-01.2100-12-31": 0},
175119
"gov.irs.credits.ctc.phase_out.arpa.threshold.JOINT": {
176120
"2025-01-01.2100-12-31": 35_000
177121
},
@@ -273,9 +217,7 @@ def build_canonical_ctc_reform_summary(
273217
def _format_canonical_ctc_reform_summary(table: pd.DataFrame) -> str:
274218
display = table.copy()
275219
for column in ("baseline", "reformed", "delta"):
276-
display[column] = display[column].map(
277-
lambda value: f"${value / 1e9:,.1f}B"
278-
)
220+
display[column] = display[column].map(lambda value: f"${value / 1e9:,.1f}B")
279221
return display.to_string(index=False)
280222

281223

@@ -296,7 +238,9 @@ def _subtract_diagnostic_tables(
296238
and pd.api.types.is_numeric_dtype(reformed[column])
297239
]
298240
id_columns = [
299-
column for column in baseline.columns if column in reformed.columns and column not in numeric_columns
241+
column
242+
for column in baseline.columns
243+
if column in reformed.columns and column not in numeric_columns
300244
]
301245
merged = baseline.merge(
302246
reformed,
@@ -305,9 +249,7 @@ def _subtract_diagnostic_tables(
305249
)
306250
delta = merged[id_columns].copy()
307251
for column in numeric_columns:
308-
delta[column] = (
309-
merged[f"{column}_reformed"] - merged[f"{column}_baseline"]
310-
)
252+
delta[column] = merged[f"{column}_reformed"] - merged[f"{column}_baseline"]
311253
delta_tables[name] = delta
312254
return delta_tables
313255

policyengine_us_data/db/etl_irs_soi.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,7 @@ def get_national_geography_soi_agi_targets(
453453
) -> list[dict]:
454454
"""Return national AGI-band count and amount targets from the geography file."""
455455
geography_year = get_geography_soi_year(dataset_year, lag=lag)
456-
return _get_national_geography_soi_agi_targets_from_year(
457-
variable, geography_year
458-
)
456+
return _get_national_geography_soi_agi_targets_from_year(variable, geography_year)
459457

460458

461459
def _upsert_target(

0 commit comments

Comments
 (0)