policyengine-us 1.382.0__py3-none-any.whl → 1.384.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of policyengine-us might be problematic. Click here for more details.
- policyengine_us/parameters/gov/states/il/dhs/tanf/payment_level/rate.yaml +3 -3
- policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_fpg.yaml +4 -4
- policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf.yaml +56 -24
- policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf_payment_level_for_grant_calculation.yaml +8 -8
- policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf_payment_level_for_initial_eligibility.yaml +3 -6
- policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/deductions/il_tanf_initial_employment_deduction_person.yaml +2 -10
- policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_earned_income_for_initial_eligibility.yaml +4 -4
- policyengine_us/variables/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_fpg.py +10 -3
- policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf_payment_level_for_initial_eligibility.py +1 -1
- policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf_spm_unit_fpg.py +24 -0
- policyengine_us/variables/gov/states/il/dhs/tanf/income/deductions/il_tanf_initial_employment_deduction_person.py +1 -1
- policyengine_us/variables/input/geography.py +24 -0
- {policyengine_us-1.382.0.dist-info → policyengine_us-1.384.0.dist-info}/METADATA +1 -1
- {policyengine_us-1.382.0.dist-info → policyengine_us-1.384.0.dist-info}/RECORD +17 -20
- policyengine_us/tests/utilities/test_ucgid_hierarchical.py +0 -121
- policyengine_us/variables/household/demographic/geographic/ucgid/ucgid.py +0 -94
- policyengine_us/variables/household/demographic/geographic/ucgid/ucgid_enum.py +0 -551
- policyengine_us/variables/household/demographic/geographic/ucgid/ucgid_str.py +0 -29
- {policyengine_us-1.382.0.dist-info → policyengine_us-1.384.0.dist-info}/WHEEL +0 -0
- {policyengine_us-1.382.0.dist-info → policyengine_us-1.384.0.dist-info}/entry_points.txt +0 -0
- {policyengine_us-1.382.0.dist-info → policyengine_us-1.384.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,7 +2,7 @@ description: Illinois applies this percentage of federal poverty level as paymen
|
|
|
2
2
|
|
|
3
3
|
values:
|
|
4
4
|
2020-10-01: 0.3
|
|
5
|
-
|
|
5
|
+
2023-10-01: 0.35
|
|
6
6
|
|
|
7
7
|
metadata:
|
|
8
8
|
unit: /1
|
|
@@ -11,5 +11,5 @@ metadata:
|
|
|
11
11
|
reference:
|
|
12
12
|
- title: Ill. Admin. Code tit. 89, § 112.251 - Payment Levels
|
|
13
13
|
href: https://www.law.cornell.edu/regulations/illinois/Ill-Admin-Code-tit-89-SS-112.251
|
|
14
|
-
- title: TANF Payment Level
|
|
15
|
-
href: https://www.dhs.state.il.us/page.aspx?item=
|
|
14
|
+
- title: MR 23.30 TANF Payment Level Increase/IED Levels
|
|
15
|
+
href: https://www.dhs.state.il.us/page.aspx?item=149890
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
il_tanf_assistance_unit_size: 1
|
|
6
6
|
state_code: IL
|
|
7
7
|
output:
|
|
8
|
-
il_tanf_assistance_unit_fpg:
|
|
8
|
+
il_tanf_assistance_unit_fpg: 13_837.5
|
|
9
9
|
|
|
10
10
|
- name: Case 2, assistance unit size 3 in 2023.
|
|
11
11
|
period: 2023
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
il_tanf_assistance_unit_size: 3
|
|
15
15
|
state_code: IL
|
|
16
16
|
output:
|
|
17
|
-
il_tanf_assistance_unit_fpg:
|
|
17
|
+
il_tanf_assistance_unit_fpg: 23_487.5
|
|
18
18
|
|
|
19
19
|
- name: Case 3, assistance unit size 1 in 2023-01.
|
|
20
20
|
period: 2023-01
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
il_tanf_assistance_unit_size: 1
|
|
24
24
|
state_code: IL
|
|
25
25
|
output:
|
|
26
|
-
il_tanf_assistance_unit_fpg:
|
|
26
|
+
il_tanf_assistance_unit_fpg: 1_132.5
|
|
27
27
|
|
|
28
28
|
- name: Case 4, assistance unit size 3 in 2023-01.
|
|
29
29
|
period: 2023-01
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
il_tanf_assistance_unit_size: 3
|
|
33
33
|
state_code: IL
|
|
34
34
|
output:
|
|
35
|
-
il_tanf_assistance_unit_fpg:
|
|
35
|
+
il_tanf_assistance_unit_fpg: 1_919.17
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
state_code: IL
|
|
66
66
|
output:
|
|
67
67
|
il_tanf_childcare_deduction: 375
|
|
68
|
-
|
|
69
|
-
il_tanf_payment_level_for_initial_eligibility:
|
|
70
|
-
il_tanf_initial_employment_deduction_person: [
|
|
71
|
-
il_tanf_countable_income_for_initial_eligibility:
|
|
68
|
+
il_tanf_spm_unit_fpg: 1_919.17
|
|
69
|
+
il_tanf_payment_level_for_initial_eligibility: 575.75
|
|
70
|
+
il_tanf_initial_employment_deduction_person: [383.83, 0, 0]
|
|
71
|
+
il_tanf_countable_income_for_initial_eligibility: 41.17
|
|
72
72
|
il_tanf_eligible: true
|
|
73
|
-
il_tanf_assistance_unit_fpg:
|
|
74
|
-
il_tanf_payment_level_for_grant_calculation:
|
|
75
|
-
il_tanf_countable_income_for_grant_calculation: 106.25
|
|
76
|
-
il_tanf:
|
|
73
|
+
il_tanf_assistance_unit_fpg: 1_919.17
|
|
74
|
+
il_tanf_payment_level_for_grant_calculation: 575.75
|
|
75
|
+
il_tanf_countable_income_for_grant_calculation: 106.25
|
|
76
|
+
il_tanf: 469.5
|
|
77
77
|
|
|
78
78
|
- name: Integration test 2, only children eligible for payment.
|
|
79
79
|
period: 2023-01
|
|
@@ -112,15 +112,15 @@
|
|
|
112
112
|
state_code: IL
|
|
113
113
|
output:
|
|
114
114
|
il_tanf_childcare_deduction: 375
|
|
115
|
-
|
|
116
|
-
il_tanf_payment_level_for_initial_eligibility:
|
|
117
|
-
il_tanf_initial_employment_deduction_person: [
|
|
118
|
-
il_tanf_countable_income_for_initial_eligibility:
|
|
115
|
+
il_tanf_spm_unit_fpg: 1_919.17
|
|
116
|
+
il_tanf_payment_level_for_initial_eligibility: 575.75
|
|
117
|
+
il_tanf_initial_employment_deduction_person: [383.83, 0, 0]
|
|
118
|
+
il_tanf_countable_income_for_initial_eligibility: 41.17
|
|
119
119
|
il_tanf_eligible: true
|
|
120
|
-
il_tanf_assistance_unit_fpg:
|
|
121
|
-
il_tanf_payment_level_for_grant_calculation:
|
|
122
|
-
il_tanf_countable_income_for_grant_calculation: 106.25
|
|
123
|
-
il_tanf:
|
|
120
|
+
il_tanf_assistance_unit_fpg: 1_525.83
|
|
121
|
+
il_tanf_payment_level_for_grant_calculation: 343.31
|
|
122
|
+
il_tanf_countable_income_for_grant_calculation: 106.25
|
|
123
|
+
il_tanf: 237.06
|
|
124
124
|
|
|
125
125
|
- name: Integration test 3, only parent eligible for payment.
|
|
126
126
|
period: 2023-01
|
|
@@ -159,12 +159,44 @@
|
|
|
159
159
|
state_code: IL
|
|
160
160
|
output:
|
|
161
161
|
il_tanf_childcare_deduction: 375
|
|
162
|
-
|
|
163
|
-
il_tanf_payment_level_for_initial_eligibility:
|
|
164
|
-
il_tanf_initial_employment_deduction_person: [
|
|
165
|
-
il_tanf_countable_income_for_initial_eligibility:
|
|
162
|
+
il_tanf_spm_unit_fpg: 1_919.17
|
|
163
|
+
il_tanf_payment_level_for_initial_eligibility: 575.75
|
|
164
|
+
il_tanf_initial_employment_deduction_person: [383.83, 0, 0]
|
|
165
|
+
il_tanf_countable_income_for_initial_eligibility: 41.17
|
|
166
166
|
il_tanf_eligible: true
|
|
167
|
-
il_tanf_assistance_unit_fpg:
|
|
168
|
-
il_tanf_payment_level_for_grant_calculation:
|
|
169
|
-
il_tanf_countable_income_for_grant_calculation: 106.25
|
|
170
|
-
il_tanf: 0
|
|
167
|
+
il_tanf_assistance_unit_fpg: 1_132.5
|
|
168
|
+
il_tanf_payment_level_for_grant_calculation: 84.94
|
|
169
|
+
il_tanf_countable_income_for_grant_calculation: 106.25
|
|
170
|
+
il_tanf: 0
|
|
171
|
+
|
|
172
|
+
- name: taxsim_record_277465_2021.yaml
|
|
173
|
+
absolute_error_margin: 0.3
|
|
174
|
+
period: 2025-01
|
|
175
|
+
input:
|
|
176
|
+
people:
|
|
177
|
+
person1:
|
|
178
|
+
age: 23
|
|
179
|
+
employment_income: 3600
|
|
180
|
+
il_aabd_gross_unearned_income: 0
|
|
181
|
+
social_security: 0
|
|
182
|
+
is_pregnant: true
|
|
183
|
+
tax_units:
|
|
184
|
+
tax_unit:
|
|
185
|
+
members: [person1]
|
|
186
|
+
premium_tax_credit: 0
|
|
187
|
+
local_income_tax: 0
|
|
188
|
+
state_sales_tax: 0
|
|
189
|
+
spm_units:
|
|
190
|
+
spm_unit:
|
|
191
|
+
members: [person1]
|
|
192
|
+
broadband_cost: 500
|
|
193
|
+
il_tanf_countable_unearned_income: 0
|
|
194
|
+
households:
|
|
195
|
+
household:
|
|
196
|
+
members: [person1]
|
|
197
|
+
state_code: IL
|
|
198
|
+
output:
|
|
199
|
+
il_tanf_eligible: true
|
|
200
|
+
il_tanf_payment_level_for_initial_eligibility: 439.25
|
|
201
|
+
il_tanf_payment_level_for_grant_calculation: 109.81
|
|
202
|
+
il_tanf: 35
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
members: [person1, person2, person3]
|
|
21
21
|
state_code: IL
|
|
22
22
|
output:
|
|
23
|
-
il_tanf_assistance_unit_fpg:
|
|
24
|
-
il_tanf_payment_level_for_grant_calculation:
|
|
23
|
+
il_tanf_assistance_unit_fpg: 1_919.17
|
|
24
|
+
il_tanf_payment_level_for_grant_calculation: 575.75
|
|
25
25
|
|
|
26
26
|
- name: Case 2, one parent and one child eligible for payment.
|
|
27
27
|
period: 2023-01
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
members: [person1, person2, person3]
|
|
46
46
|
state_code: IL
|
|
47
47
|
output:
|
|
48
|
-
il_tanf_assistance_unit_fpg:
|
|
49
|
-
il_tanf_payment_level_for_grant_calculation:
|
|
48
|
+
il_tanf_assistance_unit_fpg: 1_525.83
|
|
49
|
+
il_tanf_payment_level_for_grant_calculation: 457.75
|
|
50
50
|
|
|
51
51
|
- name: Case 3, only child eligible for payment.
|
|
52
52
|
period: 2023-01
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
members: [person1, person2, person3]
|
|
71
71
|
state_code: IL
|
|
72
72
|
output:
|
|
73
|
-
il_tanf_assistance_unit_fpg:
|
|
74
|
-
il_tanf_payment_level_for_grant_calculation:
|
|
73
|
+
il_tanf_assistance_unit_fpg: 1_132.5
|
|
74
|
+
il_tanf_payment_level_for_grant_calculation: 254.81
|
|
75
75
|
|
|
76
76
|
- name: Case 4, only parent eligible for payment.
|
|
77
77
|
period: 2023-01
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
members: [person1, person2, person3]
|
|
96
96
|
state_code: IL
|
|
97
97
|
output:
|
|
98
|
-
il_tanf_assistance_unit_fpg:
|
|
99
|
-
il_tanf_payment_level_for_grant_calculation:
|
|
98
|
+
il_tanf_assistance_unit_fpg: 1_132.5
|
|
99
|
+
il_tanf_payment_level_for_grant_calculation: 84.94
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
spm_unit_size: 1
|
|
5
5
|
state_code: IL
|
|
6
6
|
output:
|
|
7
|
-
|
|
8
|
-
il_tanf_payment_level_for_initial_eligibility: 4_374
|
|
7
|
+
il_tanf_payment_level_for_initial_eligibility: 4_333.5
|
|
9
8
|
|
|
10
9
|
- name: Size of 2.
|
|
11
10
|
period: 2023
|
|
@@ -13,8 +12,7 @@
|
|
|
13
12
|
spm_unit_size: 2
|
|
14
13
|
state_code: IL
|
|
15
14
|
output:
|
|
16
|
-
|
|
17
|
-
il_tanf_payment_level_for_initial_eligibility: 5_916
|
|
15
|
+
il_tanf_payment_level_for_initial_eligibility: 5_845.25
|
|
18
16
|
|
|
19
17
|
- name: Size of 3.
|
|
20
18
|
period: 2023
|
|
@@ -22,5 +20,4 @@
|
|
|
22
20
|
spm_unit_size: 3
|
|
23
21
|
state_code: IL
|
|
24
22
|
output:
|
|
25
|
-
|
|
26
|
-
il_tanf_payment_level_for_initial_eligibility: 7_458
|
|
23
|
+
il_tanf_payment_level_for_initial_eligibility: 7_357
|
|
@@ -6,12 +6,7 @@
|
|
|
6
6
|
is_tax_unit_head_or_spouse: true
|
|
7
7
|
state_code: IL
|
|
8
8
|
output:
|
|
9
|
-
|
|
10
|
-
il_tanf_payment_level_for_initial_eligibility: 4_374
|
|
11
|
-
il_tanf_initial_employment_deduction_person: 2_916
|
|
12
|
-
# fpg: 14_580
|
|
13
|
-
# payment level: 4_374
|
|
14
|
-
# 0.5 * 14_580 - 4_374 = 2_916
|
|
9
|
+
il_tanf_initial_employment_deduction_person: 2_585.25
|
|
15
10
|
|
|
16
11
|
- name: Case 2, household size of 2 with $10000 earned income.
|
|
17
12
|
period: 2023
|
|
@@ -21,10 +16,7 @@
|
|
|
21
16
|
is_tax_unit_head_or_spouse: true
|
|
22
17
|
state_code: IL
|
|
23
18
|
output:
|
|
24
|
-
il_tanf_initial_employment_deduction_person:
|
|
25
|
-
# fpg: 19_720
|
|
26
|
-
# payment level: 5_916
|
|
27
|
-
# 0.5 * 19_720 - 5_916 = 3_944
|
|
19
|
+
il_tanf_initial_employment_deduction_person: 3_486
|
|
28
20
|
|
|
29
21
|
- name: Case 3, household size of 1 with $10000 earned income, but not head or spouse.
|
|
30
22
|
period: 2023
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
state_code: IL
|
|
57
57
|
output:
|
|
58
58
|
il_tanf_childcare_deduction: 375
|
|
59
|
-
|
|
60
|
-
il_tanf_payment_level_for_initial_eligibility:
|
|
61
|
-
il_tanf_initial_employment_deduction_person: [
|
|
62
|
-
il_tanf_countable_earned_income_for_initial_eligibility:
|
|
59
|
+
il_tanf_spm_unit_fpg: 1_919.17
|
|
60
|
+
il_tanf_payment_level_for_initial_eligibility: 575.75
|
|
61
|
+
il_tanf_initial_employment_deduction_person: [383.83, 0, 0]
|
|
62
|
+
il_tanf_countable_earned_income_for_initial_eligibility: 41.17
|
policyengine_us/variables/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_fpg.py
CHANGED
|
@@ -12,6 +12,13 @@ class il_tanf_assistance_unit_fpg(Variable):
|
|
|
12
12
|
n = spm_unit("il_tanf_assistance_unit_size", period)
|
|
13
13
|
state_group = spm_unit.household("state_group_str", period)
|
|
14
14
|
p_fpg = parameters(period).gov.hhs.fpg
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
year = period.start.year
|
|
16
|
+
month = period.start.month
|
|
17
|
+
if month >= 10:
|
|
18
|
+
instant_str = f"{year}-10-01"
|
|
19
|
+
else:
|
|
20
|
+
instant_str = f"{year - 1}-10-01"
|
|
21
|
+
p_fpg = parameters(instant_str).gov.hhs.fpg
|
|
22
|
+
p1 = p_fpg.first_person[state_group]
|
|
23
|
+
pn = p_fpg.additional_person[state_group]
|
|
24
|
+
return (p1 + pn * (n - 1)) / MONTHS_IN_YEAR
|
policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf_payment_level_for_initial_eligibility.py
CHANGED
|
@@ -12,6 +12,6 @@ class il_tanf_payment_level_for_initial_eligibility(Variable):
|
|
|
12
12
|
|
|
13
13
|
def formula(spm_unit, period, parameters):
|
|
14
14
|
p = parameters(period).gov.states.il.dhs.tanf.payment_level
|
|
15
|
-
fpg = spm_unit("
|
|
15
|
+
fpg = spm_unit("il_tanf_spm_unit_fpg", period)
|
|
16
16
|
|
|
17
17
|
return p.rate * fpg
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from policyengine_us.model_api import *
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class il_tanf_spm_unit_fpg(Variable):
|
|
5
|
+
value_type = float
|
|
6
|
+
entity = SPMUnit
|
|
7
|
+
label = "Illinois TANF spm unit's federal poverty guideline"
|
|
8
|
+
definition_period = MONTH
|
|
9
|
+
defined_for = StateCode.IL
|
|
10
|
+
|
|
11
|
+
def formula(spm_unit, period, parameters):
|
|
12
|
+
n = spm_unit("spm_unit_size", period)
|
|
13
|
+
state_group = spm_unit.household("state_group_str", period)
|
|
14
|
+
p_fpg = parameters(period).gov.hhs.fpg
|
|
15
|
+
year = period.start.year
|
|
16
|
+
month = period.start.month
|
|
17
|
+
if month >= 10:
|
|
18
|
+
instant_str = f"{year}-10-01"
|
|
19
|
+
else:
|
|
20
|
+
instant_str = f"{year - 1}-10-01"
|
|
21
|
+
p_fpg = parameters(instant_str).gov.hhs.fpg
|
|
22
|
+
p1 = p_fpg.first_person[state_group]
|
|
23
|
+
pn = p_fpg.additional_person[state_group]
|
|
24
|
+
return (p1 + pn * (n - 1)) / MONTHS_IN_YEAR
|
|
@@ -16,7 +16,7 @@ class il_tanf_initial_employment_deduction_person(Variable):
|
|
|
16
16
|
).gov.states.il.dhs.tanf.income.initial_employment_deduction
|
|
17
17
|
|
|
18
18
|
gross_earned_income = person("il_tanf_gross_earned_income", period)
|
|
19
|
-
fpg = person.spm_unit("
|
|
19
|
+
fpg = person.spm_unit("il_tanf_spm_unit_fpg", period)
|
|
20
20
|
payment_level = person.spm_unit(
|
|
21
21
|
"il_tanf_payment_level_for_initial_eligibility", period
|
|
22
22
|
)
|
|
@@ -142,3 +142,27 @@ class state_fips(Variable):
|
|
|
142
142
|
definition_period = YEAR
|
|
143
143
|
documentation = "State FIPS code"
|
|
144
144
|
default_value = 6
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class congressional_district_geoid(Variable):
|
|
148
|
+
value_type = int
|
|
149
|
+
label = "Congressional district GEOID"
|
|
150
|
+
entity = Household
|
|
151
|
+
definition_period = YEAR
|
|
152
|
+
documentation = """Congressional district geographic identifier stored as an integer.
|
|
153
|
+
|
|
154
|
+
Format: SSDD where SS is the 2-digit state FIPS code and DD is the 2-digit district number.
|
|
155
|
+
|
|
156
|
+
Examples:
|
|
157
|
+
- Alabama (FIPS 01) district 01 is stored as 101
|
|
158
|
+
- Alabama (FIPS 01) district 07 is stored as 107
|
|
159
|
+
- North Carolina (FIPS 37) district 01 is stored as 3701
|
|
160
|
+
- California (FIPS 06) district 52 is stored as 652
|
|
161
|
+
|
|
162
|
+
To extract components:
|
|
163
|
+
- State FIPS: geoid // 100
|
|
164
|
+
- District number: geoid % 100
|
|
165
|
+
|
|
166
|
+
Note: Leading zeros are not preserved in the integer storage (e.g., 0101 becomes 101),
|
|
167
|
+
but the value remains unique and unambiguous since the format is always interpreted as SSDD."""
|
|
168
|
+
default_value = 0
|
|
@@ -1617,7 +1617,7 @@ policyengine_us/parameters/gov/states/il/dhs/tanf/income/sources/earned.yaml,sha
|
|
|
1617
1617
|
policyengine_us/parameters/gov/states/il/dhs/tanf/income/sources/unearned.yaml,sha256=dBVN4KUGiMEoDReCF94cVzONBaUizGVMR3bWcG5MJY0,1272
|
|
1618
1618
|
policyengine_us/parameters/gov/states/il/dhs/tanf/payment_level/child_only_rate.yaml,sha256=ti4PYRhHBOELwhk6fGOnKID7nuoE5kLxt_H558gAcvM,443
|
|
1619
1619
|
policyengine_us/parameters/gov/states/il/dhs/tanf/payment_level/parent_only_rate.yaml,sha256=JDMIwZgVyqZTBrRaPCZfMXEtUnB2n8umgnVRoqLax90,445
|
|
1620
|
-
policyengine_us/parameters/gov/states/il/dhs/tanf/payment_level/rate.yaml,sha256=
|
|
1620
|
+
policyengine_us/parameters/gov/states/il/dhs/tanf/payment_level/rate.yaml,sha256=lco8TfixAPTxm_P74tlb_8aQzXLrmwITaprxMkpnews,574
|
|
1621
1621
|
policyengine_us/parameters/gov/states/il/idoa/README.md,sha256=dSkp_E5HfWVdCBlFS5BdtAqNFOAGSBgTF7E3I9vJ8PU,38
|
|
1622
1622
|
policyengine_us/parameters/gov/states/il/idoa/bap/README.md,sha256=ooC8UJHcRygwWKLRncZu-a0gW69M7euqkUIb3tMPZAk,25
|
|
1623
1623
|
policyengine_us/parameters/gov/states/il/idoa/bap/disabled.yaml,sha256=fls1LRh7w5iQR2T9fuEV6GdKDs0Q19QZKtR3WlMBQvg,594
|
|
@@ -4057,10 +4057,10 @@ policyengine_us/tests/policy/baseline/gov/states/il/dhs/ccap/il_ccap_eligible_ch
|
|
|
4057
4057
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/ccap/il_ccap_immigration_status_eligible_person.yaml,sha256=3pp8P8FsjjdwJP-CYMOJ6g2yQVWZNbaHe0UZj2GilJ4,673
|
|
4058
4058
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/ccap/il_ccap_income_eligible.yaml,sha256=reLYko4lN6Fch7dFHsb3DI-WKxS5oH5QCJJ6clRBNnQ,1610
|
|
4059
4059
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/ccap/il_ccap_parent_meets_working_requirements.yaml,sha256=x9LNMNeQs6CuOnwiHKLoq9HJLMerlecaZ9huxzm0XnM,2298
|
|
4060
|
-
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf.yaml,sha256=
|
|
4061
|
-
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf_payment_level_for_grant_calculation.yaml,sha256=
|
|
4062
|
-
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf_payment_level_for_initial_eligibility.yaml,sha256=
|
|
4063
|
-
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_fpg.yaml,sha256=
|
|
4060
|
+
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf.yaml,sha256=4osqjitxetVD2cngclhjs_h9utFowkvWgXDm0Ae6tUE,5746
|
|
4061
|
+
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf_payment_level_for_grant_calculation.yaml,sha256=rA2-oM0WFxsRlEbI9rYiXz2B-9ZPY6K0HAazhZDzR88,2666
|
|
4062
|
+
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/il_tanf_payment_level_for_initial_eligibility.yaml,sha256=rY1c-obHyNgQSTVBKY0FonMgSOgl3m_rjhTfteddr-E,459
|
|
4063
|
+
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_fpg.yaml,sha256=OeRapbtz-c2zWofKRr9WrQN87hCfX5Dj3EmFi7DgSOI,846
|
|
4064
4064
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_size.yaml,sha256=zkqiYMNA_Chb2s-FgkUQrOZWPmrmty-2Wr5AhCUKgV0,1731
|
|
4065
4065
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/assistance_unit/il_tanf_payment_eligible_child.yaml,sha256=OpvQsqFHCiagWOrrQctlrOuA5zo0WgD9tflPTm9gWpA,1040
|
|
4066
4066
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/assistance_unit/il_tanf_payment_eligible_parent.yaml,sha256=47UWlDNP9TCXkpfM3j_V-UrvnbFuCIvZSDSDc71oYII,1070
|
|
@@ -4072,9 +4072,9 @@ policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/eligibility/il_tanf
|
|
|
4072
4072
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/eligibility/il_tanf_immigration_status_eligible_person.yaml,sha256=jAF1EZ6Oclky26BZJNOy6YCxcSH-4srjsTfQN9345Rw,714
|
|
4073
4073
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/eligibility/il_tanf_non_financial_eligible.yaml,sha256=DptqeBfabhX9IscKm7rkcP3y9_9s-QkSIgihp5JUQoA,733
|
|
4074
4074
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/deductions/il_tanf_childcare_deduction.yaml,sha256=IjvDPB8O0lAuOlUDHfPw7pGMPQkxJJaTclaevAhrrL8,906
|
|
4075
|
-
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/deductions/il_tanf_initial_employment_deduction_person.yaml,sha256=
|
|
4075
|
+
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/deductions/il_tanf_initial_employment_deduction_person.yaml,sha256=Jqwafl5vM_sH6wn4GKsQqcn6Uk9PBG9_FmZzt5MdX1U,1105
|
|
4076
4076
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_earned_income_for_grant_calculation.yaml,sha256=_Z1lVh7L9QXQf21pX65DRZHfUDWmY3cU0H31CsEu9oQ,1617
|
|
4077
|
-
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_earned_income_for_initial_eligibility.yaml,sha256=
|
|
4077
|
+
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_earned_income_for_initial_eligibility.yaml,sha256=fRlSh5wXfG3_YU-vO_pxI0CQvDjB4Mm309h4zoTMOKI,1946
|
|
4078
4078
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_gross_earned_income.yaml,sha256=3RihYL4CTmtqnAYwZXsLsc1SJXOSYQWuiuC10s-Nf4w,416
|
|
4079
4079
|
policyengine_us/tests/policy/baseline/gov/states/il/dhs/tanf/income/unearned/il_tanf_countable_unearned_income.yaml,sha256=Tk_aO8C0jVW1ateWv8U66-_QUXLajf6lsbZDPlOTPkQ,412
|
|
4080
4080
|
policyengine_us/tests/policy/baseline/gov/states/il/idoa/bap/il_bap_eligible.yaml,sha256=bxAIxI1GYL6I-htJnFPMEbbbq4yo0QZ2_b4V9jfboQc,1115
|
|
@@ -5186,7 +5186,6 @@ policyengine_us/tests/policy/contrib/ubi_center/flat_tax.yaml,sha256=O6krfJ2rovW
|
|
|
5186
5186
|
policyengine_us/tests/policy/reform/ctc_expansion.yaml,sha256=soq-LqWwbb7fNQJFphx_1gSc8uDGOhtr-5P93oY2Mpg,1596
|
|
5187
5187
|
policyengine_us/tests/policy/reform/winship.yaml,sha256=OPfsoZ0NrlPU25hJadZXycrYLaM0wPUGXjBrn6_8gR4,1706
|
|
5188
5188
|
policyengine_us/tests/utilities/test_load_county_fips_dataset.py,sha256=QAURDL6IMN5gafUOcTri1PUet6khLNZ_Bov6NdW_pMM,4397
|
|
5189
|
-
policyengine_us/tests/utilities/test_ucgid_hierarchical.py,sha256=WZYqWHw6-QQAv0Wd3bGgAcgPgZ0ILhOxpC-kgo4HRkU,4532
|
|
5190
5189
|
policyengine_us/tests/variables/gov/states/vt/tax/income/vt_eitc.yaml,sha256=gE-ZtclGqoFKs87k9VUgKEoVO2iZkFBq4k-ixGtde14,2341
|
|
5191
5190
|
policyengine_us/tests/variables/gov/states/vt/tax/income/adjusted_gross_income/subtractions/retirement_income_exemption/vt_military_retirement_income_based_exemption.yaml,sha256=b5I5ekAoDCrojCLwEZMoBEDdUX9zDw1bM-4iQLmyTng,3267
|
|
5192
5191
|
policyengine_us/tests/variables/gov/states/vt/tax/income/credits/vt_veteran_tax_credit.yaml,sha256=51NtThz2bNwVD7o-2VXZqplDjKUAYzIiIzyL1PfXK94,3244
|
|
@@ -6498,8 +6497,9 @@ policyengine_us/variables/gov/states/il/dhs/ccap/eligibility/il_ccap_income_elig
|
|
|
6498
6497
|
policyengine_us/variables/gov/states/il/dhs/ccap/eligibility/il_ccap_parent_meets_working_requirements.py,sha256=4joQ0ujXb1ZVxOuRd2RhNBYPIdpKK9yYS0cwdRvfHXo,938
|
|
6499
6498
|
policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf.py,sha256=QM4fibE08qvX0e53uDO-Ue5K39v7jkIfDDr2QypNUEU,694
|
|
6500
6499
|
policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf_payment_level_for_grant_application.py,sha256=s8nEYbkiOa5QfGVpkpgHwbegdR3bP1r7e79e99EMxj8,1606
|
|
6501
|
-
policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf_payment_level_for_initial_eligibility.py,sha256=
|
|
6502
|
-
policyengine_us/variables/gov/states/il/dhs/tanf/
|
|
6500
|
+
policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf_payment_level_for_initial_eligibility.py,sha256=tiTWVdvEGzaZ9bJ51z_Fn8nogA7XXtwkfuu7KpR5IK4,633
|
|
6501
|
+
policyengine_us/variables/gov/states/il/dhs/tanf/il_tanf_spm_unit_fpg.py,sha256=ficXvkwTHNMNOiFKLMdXkFOG8hj7nsYwUB4hd7UeNEE,852
|
|
6502
|
+
policyengine_us/variables/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_fpg.py,sha256=sOSLU08dwOTYcwF__lh9jLkzxKkn3-H3QR0RgCaQewc,881
|
|
6503
6503
|
policyengine_us/variables/gov/states/il/dhs/tanf/assistance_unit/il_tanf_assistance_unit_size.py,sha256=xYdABo62EPA9optuG2PRGz__ZLaoyd9HKhYSyKNuBOM,487
|
|
6504
6504
|
policyengine_us/variables/gov/states/il/dhs/tanf/assistance_unit/il_tanf_payment_eligible_child.py,sha256=KTifkd0vUkyKMDttstqHm9JctYVFrlKKOYyd_DmO3mE,666
|
|
6505
6505
|
policyengine_us/variables/gov/states/il/dhs/tanf/assistance_unit/il_tanf_payment_eligible_parent.py,sha256=p38LrcVwVhwogEzoEv-iO50mTYqyNyJL0nQ0JmPwMHg,679
|
|
@@ -6513,7 +6513,7 @@ policyengine_us/variables/gov/states/il/dhs/tanf/eligibility/il_tanf_non_financi
|
|
|
6513
6513
|
policyengine_us/variables/gov/states/il/dhs/tanf/income/il_tanf_countable_income_for_grant_calculation.py,sha256=baWtisrhHtX91nqZf7aReoIsn6OxxxfWsx7YKL00JWo,565
|
|
6514
6514
|
policyengine_us/variables/gov/states/il/dhs/tanf/income/il_tanf_countable_income_for_initial_eligibility.py,sha256=72lnW9HwgASOyOYdVx-I-M5mNneJB1L_WrJNVaufDns,562
|
|
6515
6515
|
policyengine_us/variables/gov/states/il/dhs/tanf/income/deductions/il_tanf_childcare_deduction.py,sha256=Gi8hVZAR3GSremvczW4fXOK2HtbPbwjaULN4S2XC5u0,973
|
|
6516
|
-
policyengine_us/variables/gov/states/il/dhs/tanf/income/deductions/il_tanf_initial_employment_deduction_person.py,sha256=
|
|
6516
|
+
policyengine_us/variables/gov/states/il/dhs/tanf/income/deductions/il_tanf_initial_employment_deduction_person.py,sha256=wltrTLqWvEOGZEn2V8juzZMtMVF7xxefIWkTe-dTkYQ,1227
|
|
6517
6517
|
policyengine_us/variables/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_earned_income_for_grant_calculation.py,sha256=aqgwBMvDctb-YuDQ-8ApDW8z-713HCoOQ0tncPnEXVY,1029
|
|
6518
6518
|
policyengine_us/variables/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_earned_income_for_initial_eligibility.py,sha256=d1Zukl9bocUSaCkHTBARkUamyKfE7MP148rZr3PzK1A,992
|
|
6519
6519
|
policyengine_us/variables/gov/states/il/dhs/tanf/income/earned/il_tanf_countable_gross_earned_income.py,sha256=o4L9NFEi1cjMcocrpup-sG0oHqS4tuzbh4krgnglA_E,617
|
|
@@ -7855,9 +7855,6 @@ policyengine_us/variables/household/demographic/geographic/county/county_str.py,
|
|
|
7855
7855
|
policyengine_us/variables/household/demographic/geographic/county/first_county_in_state.py,sha256=yXCj-LVjxPeILIg42ijefTmi_j4NxJwX0kMtoE47xic,1578
|
|
7856
7856
|
policyengine_us/variables/household/demographic/geographic/state/average_home_energy_use_in_state.py,sha256=aaGYAXLU7tsx-A9NW4nyLij5J5mp0WTRXsyObngekvY,319
|
|
7857
7857
|
policyengine_us/variables/household/demographic/geographic/state/in_state.py,sha256=o3ksZCOHtlJ1JGHIXAPlqcs5-rVbTgOCcDdN1-fYqmA,551
|
|
7858
|
-
policyengine_us/variables/household/demographic/geographic/ucgid/ucgid.py,sha256=SwONHVRvHmUFHvPZQMYY7Y9e7gz74kisLjJICpHdyKg,2874
|
|
7859
|
-
policyengine_us/variables/household/demographic/geographic/ucgid/ucgid_enum.py,sha256=dkeusTBI1j4xAGmRFkfSsyT3Hq5gHZwRUkSeISeNbx0,15636
|
|
7860
|
-
policyengine_us/variables/household/demographic/geographic/ucgid/ucgid_str.py,sha256=GnIRg2tc0376YazPX7wm7YQgMQaYPm2Au47vc1E5JcM,914
|
|
7861
7858
|
policyengine_us/variables/household/demographic/geographic/zip_code/three_digit_zip_code.py,sha256=7q0FQRahTOINiK2vlAyHEa5xIKowM5Kgl60-kR3ZuWU,426
|
|
7862
7859
|
policyengine_us/variables/household/demographic/geographic/zip_code/zip_code.py,sha256=3J8RfnIIsmw4_5gF5yZHmATt2cNskyKQR0lncCvOQx0,1691
|
|
7863
7860
|
policyengine_us/variables/household/demographic/household/bedrooms.py,sha256=4ltdIRLdmeuTKAskn4pdgxZuxEE-4rz0ffPnIKobc-o,164
|
|
@@ -8305,11 +8302,11 @@ policyengine_us/variables/household/income/tax_unit/us_govt_interest.py,sha256=L
|
|
|
8305
8302
|
policyengine_us/variables/input/employment_income.py,sha256=f85M5Jy8kHmkDId0j9lCE30R6htNQ-Hg74ko9cLupmI,505
|
|
8306
8303
|
policyengine_us/variables/input/employment_income_before_lsr.py,sha256=X4PBfylDs40hw6jwHPL_B0JcBkqrKCFU-beQEDFoJTE,364
|
|
8307
8304
|
policyengine_us/variables/input/farm_income.py,sha256=BEKxYmHNNnWJAAvULl5qZJigy58ap_bmQB6iHdXLGuo,427
|
|
8308
|
-
policyengine_us/variables/input/geography.py,sha256=
|
|
8305
|
+
policyengine_us/variables/input/geography.py,sha256=Ux0ueAf0rhZaflyEqz81UuXP3xKCKBDvoO3CrKhiQEc,5421
|
|
8309
8306
|
policyengine_us/variables/input/self_employment_income.py,sha256=PwsGz8R4lRikKWUYOhsC0qosNNLXq4f5SQmfw4S3mk8,511
|
|
8310
8307
|
policyengine_us/variables/input/self_employment_income_before_lsr.py,sha256=E8fcX9Nlyqz8dziHhQv_euutdmoIwFMMWePUwbbwv_w,379
|
|
8311
|
-
policyengine_us-1.
|
|
8312
|
-
policyengine_us-1.
|
|
8313
|
-
policyengine_us-1.
|
|
8314
|
-
policyengine_us-1.
|
|
8315
|
-
policyengine_us-1.
|
|
8308
|
+
policyengine_us-1.384.0.dist-info/METADATA,sha256=aJ-vrb45HKRVPA6s-tgMapY3darf6FzQdUqGIwnKe6g,1649
|
|
8309
|
+
policyengine_us-1.384.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8310
|
+
policyengine_us-1.384.0.dist-info/entry_points.txt,sha256=MLaqNyNTbReALyKNkde85VkuFFpdPWAcy8VRG1mjczc,57
|
|
8311
|
+
policyengine_us-1.384.0.dist-info/licenses/LICENSE,sha256=2N5ReRelkdqkR9a-KP-y-shmcD5P62XoYiG-miLTAzo,34519
|
|
8312
|
+
policyengine_us-1.384.0.dist-info/RECORD,,
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Test script demonstrating UCGID hierarchical functionality.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import numpy as np
|
|
6
|
-
from policyengine_us import Microsimulation
|
|
7
|
-
from policyengine_us.variables.household.demographic.geographic.ucgid.ucgid_enum import (
|
|
8
|
-
UCGID,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class TestUCGIDHierarchical:
|
|
13
|
-
"""Test class for UCGID hierarchical functionality."""
|
|
14
|
-
|
|
15
|
-
def test_ucgid_enum_hierarchical_methods(self):
|
|
16
|
-
"""Test the hierarchical methods on UCGID enum values directly."""
|
|
17
|
-
print("\n=== Testing UCGID Enum Hierarchical Methods ===")
|
|
18
|
-
|
|
19
|
-
# Test Congressional District (CA_23)
|
|
20
|
-
ca_23 = UCGID.CA_23
|
|
21
|
-
ca_23_codes = ca_23.get_hierarchical_codes()
|
|
22
|
-
assert ca_23_codes == ["5001800US0623", "0400000US06", "0100000US"]
|
|
23
|
-
|
|
24
|
-
# Test State (CA)
|
|
25
|
-
ca = UCGID.CA
|
|
26
|
-
ca_codes = ca.get_hierarchical_codes()
|
|
27
|
-
assert ca_codes == ["0400000US06", "0100000US"]
|
|
28
|
-
|
|
29
|
-
# Test US
|
|
30
|
-
us = UCGID.US
|
|
31
|
-
us_codes = us.get_hierarchical_codes()
|
|
32
|
-
assert us_codes == ["0100000US"]
|
|
33
|
-
|
|
34
|
-
# Test hierarchy matching
|
|
35
|
-
assert ca_23.matches_hierarchy("0400000US06") == True
|
|
36
|
-
assert ca_23.matches_hierarchy("0100000US") == True
|
|
37
|
-
assert ca.matches_hierarchy("5001800US0623") == False
|
|
38
|
-
|
|
39
|
-
def test_ucgid_simulation_usage(self):
|
|
40
|
-
"""Test how UCGID is used in a PolicyEngine simulation."""
|
|
41
|
-
simulation = Microsimulation()
|
|
42
|
-
ucgid_values = simulation.calculate("ucgid", "2024")
|
|
43
|
-
|
|
44
|
-
# The UCGID value should be a string (enum name)
|
|
45
|
-
ucgid_string = ucgid_values.iloc[0] # First household
|
|
46
|
-
assert type(ucgid_string) == str
|
|
47
|
-
|
|
48
|
-
# Convert the string back to enum to access hierarchical methods
|
|
49
|
-
ucgid_enum = UCGID[ucgid_string]
|
|
50
|
-
hierarchical_codes = ucgid_enum.get_hierarchical_codes()
|
|
51
|
-
|
|
52
|
-
# Should have 2 hierarchical codes for state-level UCGIDs: [state, US]
|
|
53
|
-
assert len(hierarchical_codes) == 2
|
|
54
|
-
assert (
|
|
55
|
-
hierarchical_codes[1] == "0100000US"
|
|
56
|
-
) # Second code should always be US
|
|
57
|
-
assert hierarchical_codes[0].startswith(
|
|
58
|
-
"0400000US"
|
|
59
|
-
) # First should be state-level
|
|
60
|
-
|
|
61
|
-
# Test hierarchy matching in simulation context
|
|
62
|
-
is_in_us = ucgid_enum.matches_hierarchy("0100000US")
|
|
63
|
-
assert is_in_us == True
|
|
64
|
-
|
|
65
|
-
def test_ucgid_str_variable(self):
|
|
66
|
-
"""Test the UCGID string variable functionality."""
|
|
67
|
-
simulation = Microsimulation()
|
|
68
|
-
ucgid_str_values = simulation.calculate("ucgid_str", "2024")
|
|
69
|
-
|
|
70
|
-
# The UCGID string variable should return a string representation
|
|
71
|
-
ucgid_str = ucgid_str_values.iloc[0]
|
|
72
|
-
assert type(ucgid_str) == str
|
|
73
|
-
assert (
|
|
74
|
-
ucgid_str.startswith("0100000US")
|
|
75
|
-
| ucgid_str.startswith("0400000US")
|
|
76
|
-
| ucgid_str.startswith("5001800US")
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
# Create a basic simulation to test with specific input values
|
|
80
|
-
from policyengine_us import Simulation
|
|
81
|
-
|
|
82
|
-
simulation = Simulation(
|
|
83
|
-
situation={
|
|
84
|
-
"people": {"person": {}},
|
|
85
|
-
"households": {"household": {"members": ["person"]}},
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
# Set a specific UCGID value for testing (CA_23)
|
|
90
|
-
simulation.set_input("ucgid", 2024, UCGID.CA_23)
|
|
91
|
-
|
|
92
|
-
# Calculate the ucgid_str value
|
|
93
|
-
ucgid_str_values = simulation.calculate("ucgid_str", 2024)
|
|
94
|
-
ucgid_str = ucgid_str_values[0]
|
|
95
|
-
|
|
96
|
-
# Verify it contains all three hierarchical codes
|
|
97
|
-
assert ucgid_str == "5001800US0623,0400000US06,0100000US"
|
|
98
|
-
|
|
99
|
-
def test_ucgid_microsimulation_input_override(self):
|
|
100
|
-
"""Test setting UCGID input for all households in a microsimulation."""
|
|
101
|
-
microsim = Microsimulation()
|
|
102
|
-
|
|
103
|
-
# Get initial values
|
|
104
|
-
ucgid_before = microsim.calculate("ucgid", 2024)
|
|
105
|
-
num_households = len(ucgid_before)
|
|
106
|
-
|
|
107
|
-
# Set all households to CA_23
|
|
108
|
-
input_array = np.array([UCGID.CA_23] * num_households)
|
|
109
|
-
microsim.set_input("ucgid", 2024, input_array)
|
|
110
|
-
|
|
111
|
-
# Verify the input was set
|
|
112
|
-
ucgid_after = microsim.calculate("ucgid", 2024)
|
|
113
|
-
after_values = ucgid_after.values
|
|
114
|
-
assert all(val == "CA_23" for val in after_values)
|
|
115
|
-
assert len(set(after_values)) == 1
|
|
116
|
-
|
|
117
|
-
# Test that ucgid_str now returns hierarchical codes for all households
|
|
118
|
-
ucgid_str_values = microsim.calculate("ucgid_str", 2024)
|
|
119
|
-
expected_str = "5001800US0623,0400000US06,0100000US"
|
|
120
|
-
str_values = ucgid_str_values.values
|
|
121
|
-
assert all(str_val == expected_str for str_val in str_values)
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
from policyengine_us.model_api import *
|
|
2
|
-
from policyengine_core.simulations import Simulation
|
|
3
|
-
from policyengine_us.variables.household.demographic.geographic.ucgid.ucgid_enum import (
|
|
4
|
-
UCGID,
|
|
5
|
-
)
|
|
6
|
-
import numpy as np
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class ucgid(Variable):
|
|
10
|
-
value_type = Enum
|
|
11
|
-
possible_values = UCGID
|
|
12
|
-
default_value = UCGID.US
|
|
13
|
-
entity = Household
|
|
14
|
-
label = "Unified Congressional Geographic Identifier (UCGID)"
|
|
15
|
-
definition_period = YEAR
|
|
16
|
-
documentation = """
|
|
17
|
-
Unified Congressional Geographic Identifier (UCGID) for the household as defined by the U.S. Census Bureau.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
def formula(household, period, parameters):
|
|
21
|
-
simulation: Simulation = household.simulation
|
|
22
|
-
|
|
23
|
-
# Check if this variable has been set as input
|
|
24
|
-
if simulation.get_holder("ucgid").get_known_periods():
|
|
25
|
-
return household("ucgid", period)
|
|
26
|
-
|
|
27
|
-
# Try to derive from state_code
|
|
28
|
-
state_code_enum = household("state_code", period)
|
|
29
|
-
state_code_strings = state_code_enum.decode_to_str()
|
|
30
|
-
|
|
31
|
-
# Map state codes to UCGID state values
|
|
32
|
-
state_mapping = {
|
|
33
|
-
"AL": UCGID.AL,
|
|
34
|
-
"AK": UCGID.AK,
|
|
35
|
-
"AZ": UCGID.AZ,
|
|
36
|
-
"AR": UCGID.AR,
|
|
37
|
-
"CA": UCGID.CA,
|
|
38
|
-
"CO": UCGID.CO,
|
|
39
|
-
"CT": UCGID.CT,
|
|
40
|
-
"DE": UCGID.DE,
|
|
41
|
-
"DC": UCGID.DC,
|
|
42
|
-
"FL": UCGID.FL,
|
|
43
|
-
"GA": UCGID.GA,
|
|
44
|
-
"HI": UCGID.HI,
|
|
45
|
-
"ID": UCGID.ID,
|
|
46
|
-
"IL": UCGID.IL,
|
|
47
|
-
"IN": UCGID.IN,
|
|
48
|
-
"IA": UCGID.IA,
|
|
49
|
-
"KS": UCGID.KS,
|
|
50
|
-
"KY": UCGID.KY,
|
|
51
|
-
"LA": UCGID.LA,
|
|
52
|
-
"ME": UCGID.ME,
|
|
53
|
-
"MD": UCGID.MD,
|
|
54
|
-
"MA": UCGID.MA,
|
|
55
|
-
"MI": UCGID.MI,
|
|
56
|
-
"MN": UCGID.MN,
|
|
57
|
-
"MS": UCGID.MS,
|
|
58
|
-
"MO": UCGID.MO,
|
|
59
|
-
"MT": UCGID.MT,
|
|
60
|
-
"NE": UCGID.NE,
|
|
61
|
-
"NV": UCGID.NV,
|
|
62
|
-
"NH": UCGID.NH,
|
|
63
|
-
"NJ": UCGID.NJ,
|
|
64
|
-
"NM": UCGID.NM,
|
|
65
|
-
"NY": UCGID.NY,
|
|
66
|
-
"NC": UCGID.NC,
|
|
67
|
-
"ND": UCGID.ND,
|
|
68
|
-
"OH": UCGID.OH,
|
|
69
|
-
"OK": UCGID.OK,
|
|
70
|
-
"OR": UCGID.OR,
|
|
71
|
-
"PA": UCGID.PA,
|
|
72
|
-
"RI": UCGID.RI,
|
|
73
|
-
"SC": UCGID.SC,
|
|
74
|
-
"SD": UCGID.SD,
|
|
75
|
-
"TN": UCGID.TN,
|
|
76
|
-
"TX": UCGID.TX,
|
|
77
|
-
"UT": UCGID.UT,
|
|
78
|
-
"VT": UCGID.VT,
|
|
79
|
-
"VA": UCGID.VA,
|
|
80
|
-
"WA": UCGID.WA,
|
|
81
|
-
"WV": UCGID.WV,
|
|
82
|
-
"WI": UCGID.WI,
|
|
83
|
-
"WY": UCGID.WY,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
# Convert state code strings to UCGID values
|
|
87
|
-
result = np.empty(len(state_code_strings), dtype=object)
|
|
88
|
-
for i, state_str in enumerate(state_code_strings):
|
|
89
|
-
if state_str in state_mapping:
|
|
90
|
-
result[i] = state_mapping[state_str]
|
|
91
|
-
else:
|
|
92
|
-
result[i] = UCGID.US
|
|
93
|
-
|
|
94
|
-
return result
|
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
from policyengine_us.model_api import *
|
|
2
|
-
from typing import List
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class UCGID(Enum):
|
|
6
|
-
US = "0100000US"
|
|
7
|
-
AL = "0400000US01"
|
|
8
|
-
AK = "0400000US02"
|
|
9
|
-
AZ = "0400000US04"
|
|
10
|
-
AR = "0400000US05"
|
|
11
|
-
CA = "0400000US06"
|
|
12
|
-
CO = "0400000US08"
|
|
13
|
-
CT = "0400000US09"
|
|
14
|
-
DE = "0400000US10"
|
|
15
|
-
DC = "0400000US11"
|
|
16
|
-
FL = "0400000US12"
|
|
17
|
-
GA = "0400000US13"
|
|
18
|
-
HI = "0400000US15"
|
|
19
|
-
ID = "0400000US16"
|
|
20
|
-
IL = "0400000US17"
|
|
21
|
-
IN = "0400000US18"
|
|
22
|
-
IA = "0400000US19"
|
|
23
|
-
KS = "0400000US20"
|
|
24
|
-
KY = "0400000US21"
|
|
25
|
-
LA = "0400000US22"
|
|
26
|
-
ME = "0400000US23"
|
|
27
|
-
MD = "0400000US24"
|
|
28
|
-
MA = "0400000US25"
|
|
29
|
-
MI = "0400000US26"
|
|
30
|
-
MN = "0400000US27"
|
|
31
|
-
MS = "0400000US28"
|
|
32
|
-
MO = "0400000US29"
|
|
33
|
-
MT = "0400000US30"
|
|
34
|
-
NE = "0400000US31"
|
|
35
|
-
NV = "0400000US32"
|
|
36
|
-
NH = "0400000US33"
|
|
37
|
-
NJ = "0400000US34"
|
|
38
|
-
NM = "0400000US35"
|
|
39
|
-
NY = "0400000US36"
|
|
40
|
-
NC = "0400000US37"
|
|
41
|
-
ND = "0400000US38"
|
|
42
|
-
OH = "0400000US39"
|
|
43
|
-
OK = "0400000US40"
|
|
44
|
-
OR = "0400000US41"
|
|
45
|
-
PA = "0400000US42"
|
|
46
|
-
RI = "0400000US44"
|
|
47
|
-
SC = "0400000US45"
|
|
48
|
-
SD = "0400000US46"
|
|
49
|
-
TN = "0400000US47"
|
|
50
|
-
TX = "0400000US48"
|
|
51
|
-
UT = "0400000US49"
|
|
52
|
-
VT = "0400000US50"
|
|
53
|
-
VA = "0400000US51"
|
|
54
|
-
WA = "0400000US53"
|
|
55
|
-
WV = "0400000US54"
|
|
56
|
-
WI = "0400000US55"
|
|
57
|
-
WY = "0400000US56"
|
|
58
|
-
AL_01 = "5001800US0101"
|
|
59
|
-
AL_02 = "5001800US0102"
|
|
60
|
-
AL_03 = "5001800US0103"
|
|
61
|
-
AL_04 = "5001800US0104"
|
|
62
|
-
AL_05 = "5001800US0105"
|
|
63
|
-
AL_06 = "5001800US0106"
|
|
64
|
-
AL_07 = "5001800US0107"
|
|
65
|
-
AK_01 = "5001800US0200"
|
|
66
|
-
AZ_01 = "5001800US0401"
|
|
67
|
-
AZ_02 = "5001800US0402"
|
|
68
|
-
AZ_03 = "5001800US0403"
|
|
69
|
-
AZ_04 = "5001800US0404"
|
|
70
|
-
AZ_05 = "5001800US0405"
|
|
71
|
-
AZ_06 = "5001800US0406"
|
|
72
|
-
AZ_07 = "5001800US0407"
|
|
73
|
-
AZ_08 = "5001800US0408"
|
|
74
|
-
AZ_09 = "5001800US0409"
|
|
75
|
-
AR_01 = "5001800US0501"
|
|
76
|
-
AR_02 = "5001800US0502"
|
|
77
|
-
AR_03 = "5001800US0503"
|
|
78
|
-
AR_04 = "5001800US0504"
|
|
79
|
-
CA_01 = "5001800US0601"
|
|
80
|
-
CA_02 = "5001800US0602"
|
|
81
|
-
CA_03 = "5001800US0603"
|
|
82
|
-
CA_04 = "5001800US0604"
|
|
83
|
-
CA_05 = "5001800US0605"
|
|
84
|
-
CA_06 = "5001800US0606"
|
|
85
|
-
CA_07 = "5001800US0607"
|
|
86
|
-
CA_08 = "5001800US0608"
|
|
87
|
-
CA_09 = "5001800US0609"
|
|
88
|
-
CA_10 = "5001800US0610"
|
|
89
|
-
CA_11 = "5001800US0611"
|
|
90
|
-
CA_12 = "5001800US0612"
|
|
91
|
-
CA_13 = "5001800US0613"
|
|
92
|
-
CA_14 = "5001800US0614"
|
|
93
|
-
CA_15 = "5001800US0615"
|
|
94
|
-
CA_16 = "5001800US0616"
|
|
95
|
-
CA_17 = "5001800US0617"
|
|
96
|
-
CA_18 = "5001800US0618"
|
|
97
|
-
CA_19 = "5001800US0619"
|
|
98
|
-
CA_20 = "5001800US0620"
|
|
99
|
-
CA_21 = "5001800US0621"
|
|
100
|
-
CA_22 = "5001800US0622"
|
|
101
|
-
CA_23 = "5001800US0623"
|
|
102
|
-
CA_24 = "5001800US0624"
|
|
103
|
-
CA_25 = "5001800US0625"
|
|
104
|
-
CA_26 = "5001800US0626"
|
|
105
|
-
CA_27 = "5001800US0627"
|
|
106
|
-
CA_28 = "5001800US0628"
|
|
107
|
-
CA_29 = "5001800US0629"
|
|
108
|
-
CA_30 = "5001800US0630"
|
|
109
|
-
CA_31 = "5001800US0631"
|
|
110
|
-
CA_32 = "5001800US0632"
|
|
111
|
-
CA_33 = "5001800US0633"
|
|
112
|
-
CA_34 = "5001800US0634"
|
|
113
|
-
CA_35 = "5001800US0635"
|
|
114
|
-
CA_36 = "5001800US0636"
|
|
115
|
-
CA_37 = "5001800US0637"
|
|
116
|
-
CA_38 = "5001800US0638"
|
|
117
|
-
CA_39 = "5001800US0639"
|
|
118
|
-
CA_40 = "5001800US0640"
|
|
119
|
-
CA_41 = "5001800US0641"
|
|
120
|
-
CA_42 = "5001800US0642"
|
|
121
|
-
CA_43 = "5001800US0643"
|
|
122
|
-
CA_44 = "5001800US0644"
|
|
123
|
-
CA_45 = "5001800US0645"
|
|
124
|
-
CA_46 = "5001800US0646"
|
|
125
|
-
CA_47 = "5001800US0647"
|
|
126
|
-
CA_48 = "5001800US0648"
|
|
127
|
-
CA_49 = "5001800US0649"
|
|
128
|
-
CA_50 = "5001800US0650"
|
|
129
|
-
CA_51 = "5001800US0651"
|
|
130
|
-
CA_52 = "5001800US0652"
|
|
131
|
-
CO_01 = "5001800US0801"
|
|
132
|
-
CO_02 = "5001800US0802"
|
|
133
|
-
CO_03 = "5001800US0803"
|
|
134
|
-
CO_04 = "5001800US0804"
|
|
135
|
-
CO_05 = "5001800US0805"
|
|
136
|
-
CO_06 = "5001800US0806"
|
|
137
|
-
CO_07 = "5001800US0807"
|
|
138
|
-
CO_08 = "5001800US0808"
|
|
139
|
-
CT_01 = "5001800US0901"
|
|
140
|
-
CT_02 = "5001800US0902"
|
|
141
|
-
CT_03 = "5001800US0903"
|
|
142
|
-
CT_04 = "5001800US0904"
|
|
143
|
-
CT_05 = "5001800US0905"
|
|
144
|
-
DE_01 = "5001800US1000"
|
|
145
|
-
DC_01 = "5001800US1198"
|
|
146
|
-
FL_01 = "5001800US1201"
|
|
147
|
-
FL_02 = "5001800US1202"
|
|
148
|
-
FL_03 = "5001800US1203"
|
|
149
|
-
FL_04 = "5001800US1204"
|
|
150
|
-
FL_05 = "5001800US1205"
|
|
151
|
-
FL_06 = "5001800US1206"
|
|
152
|
-
FL_07 = "5001800US1207"
|
|
153
|
-
FL_08 = "5001800US1208"
|
|
154
|
-
FL_09 = "5001800US1209"
|
|
155
|
-
FL_10 = "5001800US1210"
|
|
156
|
-
FL_11 = "5001800US1211"
|
|
157
|
-
FL_12 = "5001800US1212"
|
|
158
|
-
FL_13 = "5001800US1213"
|
|
159
|
-
FL_14 = "5001800US1214"
|
|
160
|
-
FL_15 = "5001800US1215"
|
|
161
|
-
FL_16 = "5001800US1216"
|
|
162
|
-
FL_17 = "5001800US1217"
|
|
163
|
-
FL_18 = "5001800US1218"
|
|
164
|
-
FL_19 = "5001800US1219"
|
|
165
|
-
FL_20 = "5001800US1220"
|
|
166
|
-
FL_21 = "5001800US1221"
|
|
167
|
-
FL_22 = "5001800US1222"
|
|
168
|
-
FL_23 = "5001800US1223"
|
|
169
|
-
FL_24 = "5001800US1224"
|
|
170
|
-
FL_25 = "5001800US1225"
|
|
171
|
-
FL_26 = "5001800US1226"
|
|
172
|
-
FL_27 = "5001800US1227"
|
|
173
|
-
FL_28 = "5001800US1228"
|
|
174
|
-
GA_01 = "5001800US1301"
|
|
175
|
-
GA_02 = "5001800US1302"
|
|
176
|
-
GA_03 = "5001800US1303"
|
|
177
|
-
GA_04 = "5001800US1304"
|
|
178
|
-
GA_05 = "5001800US1305"
|
|
179
|
-
GA_06 = "5001800US1306"
|
|
180
|
-
GA_07 = "5001800US1307"
|
|
181
|
-
GA_08 = "5001800US1308"
|
|
182
|
-
GA_09 = "5001800US1309"
|
|
183
|
-
GA_10 = "5001800US1310"
|
|
184
|
-
GA_11 = "5001800US1311"
|
|
185
|
-
GA_12 = "5001800US1312"
|
|
186
|
-
GA_13 = "5001800US1313"
|
|
187
|
-
GA_14 = "5001800US1314"
|
|
188
|
-
HI_01 = "5001800US1501"
|
|
189
|
-
HI_02 = "5001800US1502"
|
|
190
|
-
ID_01 = "5001800US1601"
|
|
191
|
-
ID_02 = "5001800US1602"
|
|
192
|
-
IL_01 = "5001800US1701"
|
|
193
|
-
IL_02 = "5001800US1702"
|
|
194
|
-
IL_03 = "5001800US1703"
|
|
195
|
-
IL_04 = "5001800US1704"
|
|
196
|
-
IL_05 = "5001800US1705"
|
|
197
|
-
IL_06 = "5001800US1706"
|
|
198
|
-
IL_07 = "5001800US1707"
|
|
199
|
-
IL_08 = "5001800US1708"
|
|
200
|
-
IL_09 = "5001800US1709"
|
|
201
|
-
IL_10 = "5001800US1710"
|
|
202
|
-
IL_11 = "5001800US1711"
|
|
203
|
-
IL_12 = "5001800US1712"
|
|
204
|
-
IL_13 = "5001800US1713"
|
|
205
|
-
IL_14 = "5001800US1714"
|
|
206
|
-
IL_15 = "5001800US1715"
|
|
207
|
-
IL_16 = "5001800US1716"
|
|
208
|
-
IL_17 = "5001800US1717"
|
|
209
|
-
IN_01 = "5001800US1801"
|
|
210
|
-
IN_02 = "5001800US1802"
|
|
211
|
-
IN_03 = "5001800US1803"
|
|
212
|
-
IN_04 = "5001800US1804"
|
|
213
|
-
IN_05 = "5001800US1805"
|
|
214
|
-
IN_06 = "5001800US1806"
|
|
215
|
-
IN_07 = "5001800US1807"
|
|
216
|
-
IN_08 = "5001800US1808"
|
|
217
|
-
IN_09 = "5001800US1809"
|
|
218
|
-
IA_01 = "5001800US1901"
|
|
219
|
-
IA_02 = "5001800US1902"
|
|
220
|
-
IA_03 = "5001800US1903"
|
|
221
|
-
IA_04 = "5001800US1904"
|
|
222
|
-
KS_01 = "5001800US2001"
|
|
223
|
-
KS_02 = "5001800US2002"
|
|
224
|
-
KS_03 = "5001800US2003"
|
|
225
|
-
KS_04 = "5001800US2004"
|
|
226
|
-
KY_01 = "5001800US2101"
|
|
227
|
-
KY_02 = "5001800US2102"
|
|
228
|
-
KY_03 = "5001800US2103"
|
|
229
|
-
KY_04 = "5001800US2104"
|
|
230
|
-
KY_05 = "5001800US2105"
|
|
231
|
-
KY_06 = "5001800US2106"
|
|
232
|
-
LA_01 = "5001800US2201"
|
|
233
|
-
LA_02 = "5001800US2202"
|
|
234
|
-
LA_03 = "5001800US2203"
|
|
235
|
-
LA_04 = "5001800US2204"
|
|
236
|
-
LA_05 = "5001800US2205"
|
|
237
|
-
LA_06 = "5001800US2206"
|
|
238
|
-
ME_01 = "5001800US2301"
|
|
239
|
-
ME_02 = "5001800US2302"
|
|
240
|
-
MD_01 = "5001800US2401"
|
|
241
|
-
MD_02 = "5001800US2402"
|
|
242
|
-
MD_03 = "5001800US2403"
|
|
243
|
-
MD_04 = "5001800US2404"
|
|
244
|
-
MD_05 = "5001800US2405"
|
|
245
|
-
MD_06 = "5001800US2406"
|
|
246
|
-
MD_07 = "5001800US2407"
|
|
247
|
-
MD_08 = "5001800US2408"
|
|
248
|
-
MA_01 = "5001800US2501"
|
|
249
|
-
MA_02 = "5001800US2502"
|
|
250
|
-
MA_03 = "5001800US2503"
|
|
251
|
-
MA_04 = "5001800US2504"
|
|
252
|
-
MA_05 = "5001800US2505"
|
|
253
|
-
MA_06 = "5001800US2506"
|
|
254
|
-
MA_07 = "5001800US2507"
|
|
255
|
-
MA_08 = "5001800US2508"
|
|
256
|
-
MA_09 = "5001800US2509"
|
|
257
|
-
MI_01 = "5001800US2601"
|
|
258
|
-
MI_02 = "5001800US2602"
|
|
259
|
-
MI_03 = "5001800US2603"
|
|
260
|
-
MI_04 = "5001800US2604"
|
|
261
|
-
MI_05 = "5001800US2605"
|
|
262
|
-
MI_06 = "5001800US2606"
|
|
263
|
-
MI_07 = "5001800US2607"
|
|
264
|
-
MI_08 = "5001800US2608"
|
|
265
|
-
MI_09 = "5001800US2609"
|
|
266
|
-
MI_10 = "5001800US2610"
|
|
267
|
-
MI_11 = "5001800US2611"
|
|
268
|
-
MI_12 = "5001800US2612"
|
|
269
|
-
MI_13 = "5001800US2613"
|
|
270
|
-
MN_01 = "5001800US2701"
|
|
271
|
-
MN_02 = "5001800US2702"
|
|
272
|
-
MN_03 = "5001800US2703"
|
|
273
|
-
MN_04 = "5001800US2704"
|
|
274
|
-
MN_05 = "5001800US2705"
|
|
275
|
-
MN_06 = "5001800US2706"
|
|
276
|
-
MN_07 = "5001800US2707"
|
|
277
|
-
MN_08 = "5001800US2708"
|
|
278
|
-
MS_01 = "5001800US2801"
|
|
279
|
-
MS_02 = "5001800US2802"
|
|
280
|
-
MS_03 = "5001800US2803"
|
|
281
|
-
MS_04 = "5001800US2804"
|
|
282
|
-
MO_01 = "5001800US2901"
|
|
283
|
-
MO_02 = "5001800US2902"
|
|
284
|
-
MO_03 = "5001800US2903"
|
|
285
|
-
MO_04 = "5001800US2904"
|
|
286
|
-
MO_05 = "5001800US2905"
|
|
287
|
-
MO_06 = "5001800US2906"
|
|
288
|
-
MO_07 = "5001800US2907"
|
|
289
|
-
MO_08 = "5001800US2908"
|
|
290
|
-
MT_01 = "5001800US3001"
|
|
291
|
-
MT_02 = "5001800US3002"
|
|
292
|
-
NE_01 = "5001800US3101"
|
|
293
|
-
NE_02 = "5001800US3102"
|
|
294
|
-
NE_03 = "5001800US3103"
|
|
295
|
-
NV_01 = "5001800US3201"
|
|
296
|
-
NV_02 = "5001800US3202"
|
|
297
|
-
NV_03 = "5001800US3203"
|
|
298
|
-
NV_04 = "5001800US3204"
|
|
299
|
-
NH_01 = "5001800US3301"
|
|
300
|
-
NH_02 = "5001800US3302"
|
|
301
|
-
NJ_01 = "5001800US3401"
|
|
302
|
-
NJ_02 = "5001800US3402"
|
|
303
|
-
NJ_03 = "5001800US3403"
|
|
304
|
-
NJ_04 = "5001800US3404"
|
|
305
|
-
NJ_05 = "5001800US3405"
|
|
306
|
-
NJ_06 = "5001800US3406"
|
|
307
|
-
NJ_07 = "5001800US3407"
|
|
308
|
-
NJ_08 = "5001800US3408"
|
|
309
|
-
NJ_09 = "5001800US3409"
|
|
310
|
-
NJ_10 = "5001800US3410"
|
|
311
|
-
NJ_11 = "5001800US3411"
|
|
312
|
-
NJ_12 = "5001800US3412"
|
|
313
|
-
NM_01 = "5001800US3501"
|
|
314
|
-
NM_02 = "5001800US3502"
|
|
315
|
-
NM_03 = "5001800US3503"
|
|
316
|
-
NY_01 = "5001800US3601"
|
|
317
|
-
NY_02 = "5001800US3602"
|
|
318
|
-
NY_03 = "5001800US3603"
|
|
319
|
-
NY_04 = "5001800US3604"
|
|
320
|
-
NY_05 = "5001800US3605"
|
|
321
|
-
NY_06 = "5001800US3606"
|
|
322
|
-
NY_07 = "5001800US3607"
|
|
323
|
-
NY_08 = "5001800US3608"
|
|
324
|
-
NY_09 = "5001800US3609"
|
|
325
|
-
NY_10 = "5001800US3610"
|
|
326
|
-
NY_11 = "5001800US3611"
|
|
327
|
-
NY_12 = "5001800US3612"
|
|
328
|
-
NY_13 = "5001800US3613"
|
|
329
|
-
NY_14 = "5001800US3614"
|
|
330
|
-
NY_15 = "5001800US3615"
|
|
331
|
-
NY_16 = "5001800US3616"
|
|
332
|
-
NY_17 = "5001800US3617"
|
|
333
|
-
NY_18 = "5001800US3618"
|
|
334
|
-
NY_19 = "5001800US3619"
|
|
335
|
-
NY_20 = "5001800US3620"
|
|
336
|
-
NY_21 = "5001800US3621"
|
|
337
|
-
NY_22 = "5001800US3622"
|
|
338
|
-
NY_23 = "5001800US3623"
|
|
339
|
-
NY_24 = "5001800US3624"
|
|
340
|
-
NY_25 = "5001800US3625"
|
|
341
|
-
NY_26 = "5001800US3626"
|
|
342
|
-
NC_01 = "5001800US3701"
|
|
343
|
-
NC_02 = "5001800US3702"
|
|
344
|
-
NC_03 = "5001800US3703"
|
|
345
|
-
NC_04 = "5001800US3704"
|
|
346
|
-
NC_05 = "5001800US3705"
|
|
347
|
-
NC_06 = "5001800US3706"
|
|
348
|
-
NC_07 = "5001800US3707"
|
|
349
|
-
NC_08 = "5001800US3708"
|
|
350
|
-
NC_09 = "5001800US3709"
|
|
351
|
-
NC_10 = "5001800US3710"
|
|
352
|
-
NC_11 = "5001800US3711"
|
|
353
|
-
NC_12 = "5001800US3712"
|
|
354
|
-
NC_13 = "5001800US3713"
|
|
355
|
-
NC_14 = "5001800US3714"
|
|
356
|
-
ND_01 = "5001800US3800"
|
|
357
|
-
OH_01 = "5001800US3901"
|
|
358
|
-
OH_02 = "5001800US3902"
|
|
359
|
-
OH_03 = "5001800US3903"
|
|
360
|
-
OH_04 = "5001800US3904"
|
|
361
|
-
OH_05 = "5001800US3905"
|
|
362
|
-
OH_06 = "5001800US3906"
|
|
363
|
-
OH_07 = "5001800US3907"
|
|
364
|
-
OH_08 = "5001800US3908"
|
|
365
|
-
OH_09 = "5001800US3909"
|
|
366
|
-
OH_10 = "5001800US3910"
|
|
367
|
-
OH_11 = "5001800US3911"
|
|
368
|
-
OH_12 = "5001800US3912"
|
|
369
|
-
OH_13 = "5001800US3913"
|
|
370
|
-
OH_14 = "5001800US3914"
|
|
371
|
-
OH_15 = "5001800US3915"
|
|
372
|
-
OK_01 = "5001800US4001"
|
|
373
|
-
OK_02 = "5001800US4002"
|
|
374
|
-
OK_03 = "5001800US4003"
|
|
375
|
-
OK_04 = "5001800US4004"
|
|
376
|
-
OK_05 = "5001800US4005"
|
|
377
|
-
OR_01 = "5001800US4101"
|
|
378
|
-
OR_02 = "5001800US4102"
|
|
379
|
-
OR_03 = "5001800US4103"
|
|
380
|
-
OR_04 = "5001800US4104"
|
|
381
|
-
OR_05 = "5001800US4105"
|
|
382
|
-
OR_06 = "5001800US4106"
|
|
383
|
-
PA_01 = "5001800US4201"
|
|
384
|
-
PA_02 = "5001800US4202"
|
|
385
|
-
PA_03 = "5001800US4203"
|
|
386
|
-
PA_04 = "5001800US4204"
|
|
387
|
-
PA_05 = "5001800US4205"
|
|
388
|
-
PA_06 = "5001800US4206"
|
|
389
|
-
PA_07 = "5001800US4207"
|
|
390
|
-
PA_08 = "5001800US4208"
|
|
391
|
-
PA_09 = "5001800US4209"
|
|
392
|
-
PA_10 = "5001800US4210"
|
|
393
|
-
PA_11 = "5001800US4211"
|
|
394
|
-
PA_12 = "5001800US4212"
|
|
395
|
-
PA_13 = "5001800US4213"
|
|
396
|
-
PA_14 = "5001800US4214"
|
|
397
|
-
PA_15 = "5001800US4215"
|
|
398
|
-
PA_16 = "5001800US4216"
|
|
399
|
-
PA_17 = "5001800US4217"
|
|
400
|
-
RI_01 = "5001800US4401"
|
|
401
|
-
RI_02 = "5001800US4402"
|
|
402
|
-
SC_01 = "5001800US4501"
|
|
403
|
-
SC_02 = "5001800US4502"
|
|
404
|
-
SC_03 = "5001800US4503"
|
|
405
|
-
SC_04 = "5001800US4504"
|
|
406
|
-
SC_05 = "5001800US4505"
|
|
407
|
-
SC_06 = "5001800US4506"
|
|
408
|
-
SC_07 = "5001800US4507"
|
|
409
|
-
SD_01 = "5001800US4600"
|
|
410
|
-
TN_01 = "5001800US4701"
|
|
411
|
-
TN_02 = "5001800US4702"
|
|
412
|
-
TN_03 = "5001800US4703"
|
|
413
|
-
TN_04 = "5001800US4704"
|
|
414
|
-
TN_05 = "5001800US4705"
|
|
415
|
-
TN_06 = "5001800US4706"
|
|
416
|
-
TN_07 = "5001800US4707"
|
|
417
|
-
TN_08 = "5001800US4708"
|
|
418
|
-
TN_09 = "5001800US4709"
|
|
419
|
-
TX_01 = "5001800US4801"
|
|
420
|
-
TX_02 = "5001800US4802"
|
|
421
|
-
TX_03 = "5001800US4803"
|
|
422
|
-
TX_04 = "5001800US4804"
|
|
423
|
-
TX_05 = "5001800US4805"
|
|
424
|
-
TX_06 = "5001800US4806"
|
|
425
|
-
TX_07 = "5001800US4807"
|
|
426
|
-
TX_08 = "5001800US4808"
|
|
427
|
-
TX_09 = "5001800US4809"
|
|
428
|
-
TX_10 = "5001800US4810"
|
|
429
|
-
TX_11 = "5001800US4811"
|
|
430
|
-
TX_12 = "5001800US4812"
|
|
431
|
-
TX_13 = "5001800US4813"
|
|
432
|
-
TX_14 = "5001800US4814"
|
|
433
|
-
TX_15 = "5001800US4815"
|
|
434
|
-
TX_16 = "5001800US4816"
|
|
435
|
-
TX_17 = "5001800US4817"
|
|
436
|
-
TX_18 = "5001800US4818"
|
|
437
|
-
TX_19 = "5001800US4819"
|
|
438
|
-
TX_20 = "5001800US4820"
|
|
439
|
-
TX_21 = "5001800US4821"
|
|
440
|
-
TX_22 = "5001800US4822"
|
|
441
|
-
TX_23 = "5001800US4823"
|
|
442
|
-
TX_24 = "5001800US4824"
|
|
443
|
-
TX_25 = "5001800US4825"
|
|
444
|
-
TX_26 = "5001800US4826"
|
|
445
|
-
TX_27 = "5001800US4827"
|
|
446
|
-
TX_28 = "5001800US4828"
|
|
447
|
-
TX_29 = "5001800US4829"
|
|
448
|
-
TX_30 = "5001800US4830"
|
|
449
|
-
TX_31 = "5001800US4831"
|
|
450
|
-
TX_32 = "5001800US4832"
|
|
451
|
-
TX_33 = "5001800US4833"
|
|
452
|
-
TX_34 = "5001800US4834"
|
|
453
|
-
TX_35 = "5001800US4835"
|
|
454
|
-
TX_36 = "5001800US4836"
|
|
455
|
-
TX_37 = "5001800US4837"
|
|
456
|
-
TX_38 = "5001800US4838"
|
|
457
|
-
UT_01 = "5001800US4901"
|
|
458
|
-
UT_02 = "5001800US4902"
|
|
459
|
-
UT_03 = "5001800US4903"
|
|
460
|
-
UT_04 = "5001800US4904"
|
|
461
|
-
VT_01 = "5001800US5000"
|
|
462
|
-
VA_01 = "5001800US5101"
|
|
463
|
-
VA_02 = "5001800US5102"
|
|
464
|
-
VA_03 = "5001800US5103"
|
|
465
|
-
VA_04 = "5001800US5104"
|
|
466
|
-
VA_05 = "5001800US5105"
|
|
467
|
-
VA_06 = "5001800US5106"
|
|
468
|
-
VA_07 = "5001800US5107"
|
|
469
|
-
VA_08 = "5001800US5108"
|
|
470
|
-
VA_09 = "5001800US5109"
|
|
471
|
-
VA_10 = "5001800US5110"
|
|
472
|
-
VA_11 = "5001800US5111"
|
|
473
|
-
WA_01 = "5001800US5301"
|
|
474
|
-
WA_02 = "5001800US5302"
|
|
475
|
-
WA_03 = "5001800US5303"
|
|
476
|
-
WA_04 = "5001800US5304"
|
|
477
|
-
WA_05 = "5001800US5305"
|
|
478
|
-
WA_06 = "5001800US5306"
|
|
479
|
-
WA_07 = "5001800US5307"
|
|
480
|
-
WA_08 = "5001800US5308"
|
|
481
|
-
WA_09 = "5001800US5309"
|
|
482
|
-
WA_10 = "5001800US5310"
|
|
483
|
-
WV_01 = "5001800US5401"
|
|
484
|
-
WV_02 = "5001800US5402"
|
|
485
|
-
WI_01 = "5001800US5501"
|
|
486
|
-
WI_02 = "5001800US5502"
|
|
487
|
-
WI_03 = "5001800US5503"
|
|
488
|
-
WI_04 = "5001800US5504"
|
|
489
|
-
WI_05 = "5001800US5505"
|
|
490
|
-
WI_06 = "5001800US5506"
|
|
491
|
-
WI_07 = "5001800US5507"
|
|
492
|
-
WI_08 = "5001800US5508"
|
|
493
|
-
WY_01 = "5001800US5600"
|
|
494
|
-
|
|
495
|
-
def get_hierarchical_codes(self) -> List[str]:
|
|
496
|
-
"""
|
|
497
|
-
Returns all applicable UCGID codes for this enum value in hierarchical order.
|
|
498
|
-
|
|
499
|
-
Returns:
|
|
500
|
-
List of UCGID codes from most specific to least specific
|
|
501
|
-
|
|
502
|
-
Examples:
|
|
503
|
-
UCGID.CA_23.get_hierarchical_codes() -> ["5001800US0623", "0400000US06", "0100000US"]
|
|
504
|
-
UCGID.CA.get_hierarchical_codes() -> ["0400000US06", "0100000US"]
|
|
505
|
-
UCGID.US.get_hierarchical_codes() -> ["0100000US"]
|
|
506
|
-
"""
|
|
507
|
-
code = self.value
|
|
508
|
-
codes_list = [code]
|
|
509
|
-
|
|
510
|
-
# If it's a district code (Congressional District format: 5001800US + state + district)
|
|
511
|
-
if code.startswith("5001800US"):
|
|
512
|
-
# Extract state code from district code
|
|
513
|
-
state_code_num = code[9:11] # Extract 2-digit state code
|
|
514
|
-
state_code = f"0400000US{state_code_num}"
|
|
515
|
-
|
|
516
|
-
# Add state code if it exists in the enum
|
|
517
|
-
for state_enum in UCGID:
|
|
518
|
-
if state_enum.value == state_code:
|
|
519
|
-
codes_list.append(state_code)
|
|
520
|
-
break
|
|
521
|
-
|
|
522
|
-
# Add US code
|
|
523
|
-
codes_list.append("0100000US")
|
|
524
|
-
|
|
525
|
-
# If it's a state code (State format: 0400000US + state code)
|
|
526
|
-
elif code.startswith("0400000US"):
|
|
527
|
-
# Add US code
|
|
528
|
-
codes_list.append("0100000US")
|
|
529
|
-
|
|
530
|
-
# If it's already the US code, return as-is
|
|
531
|
-
# (US code: "0100000US")
|
|
532
|
-
|
|
533
|
-
return codes_list
|
|
534
|
-
|
|
535
|
-
def matches_hierarchy(self, target_code: str) -> bool:
|
|
536
|
-
"""
|
|
537
|
-
Check if this UCGID code matches a target code in the hierarchy.
|
|
538
|
-
|
|
539
|
-
Args:
|
|
540
|
-
target_code: The target code to match against
|
|
541
|
-
|
|
542
|
-
Returns:
|
|
543
|
-
True if this code belongs to the target code's hierarchy
|
|
544
|
-
|
|
545
|
-
Examples:
|
|
546
|
-
UCGID.CA_23.matches_hierarchy("0400000US06") -> True (CA_23 is in CA)
|
|
547
|
-
UCGID.CA_23.matches_hierarchy("0100000US") -> True (CA_23 is in US)
|
|
548
|
-
UCGID.CA.matches_hierarchy("5001800US0623") -> False (CA is not CA_23)
|
|
549
|
-
"""
|
|
550
|
-
hierarchical_codes = self.get_hierarchical_codes()
|
|
551
|
-
return target_code in hierarchical_codes
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
from policyengine_us.model_api import *
|
|
2
|
-
from policyengine_us.variables.household.demographic.geographic.ucgid.ucgid_enum import (
|
|
3
|
-
UCGID,
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class ucgid_str(Variable):
|
|
8
|
-
value_type = str
|
|
9
|
-
entity = Household
|
|
10
|
-
label = "UCGID (string)"
|
|
11
|
-
documentation = "UCGID variable, stored as a string"
|
|
12
|
-
definition_period = YEAR
|
|
13
|
-
|
|
14
|
-
def formula(household, period, parameters):
|
|
15
|
-
import numpy as np
|
|
16
|
-
|
|
17
|
-
ucgid_enum_names = household("ucgid", period).decode_to_str()
|
|
18
|
-
|
|
19
|
-
# Convert each enum name to its hierarchical codes
|
|
20
|
-
result = []
|
|
21
|
-
for enum_name in ucgid_enum_names:
|
|
22
|
-
# Get the enum instance from its name
|
|
23
|
-
ucgid_enum = UCGID[enum_name]
|
|
24
|
-
|
|
25
|
-
# Get all hierarchical codes and join with commas
|
|
26
|
-
hierarchical_codes = ucgid_enum.get_hierarchical_codes()
|
|
27
|
-
result.append(",".join(hierarchical_codes))
|
|
28
|
-
|
|
29
|
-
return np.array(result)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|