policyengine-us 1.362.1__py3-none-any.whl → 1.363.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/tests/policy/baseline/household/demographic/geographic/county/county.yaml +14 -0
- policyengine_us/tests/policy/baseline/household/demographic/geographic/county/first_county_in_state.yaml +21 -0
- policyengine_us/variables/household/demographic/geographic/county/county.py +20 -6
- policyengine_us/variables/household/demographic/geographic/county/first_county_in_state.py +47 -0
- {policyengine_us-1.362.1.dist-info → policyengine_us-1.363.0.dist-info}/METADATA +1 -1
- {policyengine_us-1.362.1.dist-info → policyengine_us-1.363.0.dist-info}/RECORD +9 -7
- {policyengine_us-1.362.1.dist-info → policyengine_us-1.363.0.dist-info}/WHEEL +0 -0
- {policyengine_us-1.362.1.dist-info → policyengine_us-1.363.0.dist-info}/entry_points.txt +0 -0
- {policyengine_us-1.362.1.dist-info → policyengine_us-1.363.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -39,3 +39,17 @@
|
|
|
39
39
|
county_fips: ["36059", "06037", "26163", "32003"]
|
|
40
40
|
output:
|
|
41
41
|
county: [NASSAU_COUNTY_NY, LOS_ANGELES_COUNTY_CA, WAYNE_COUNTY_MI, CLARK_COUNTY_NV]
|
|
42
|
+
|
|
43
|
+
- name: Only have the state code CA as input, return the first county of that state.
|
|
44
|
+
period: 2025
|
|
45
|
+
input:
|
|
46
|
+
state_code: CA
|
|
47
|
+
output:
|
|
48
|
+
county: ALAMEDA_COUNTY_CA
|
|
49
|
+
|
|
50
|
+
- name: Only have the state code DC as input, return the first county of that state.
|
|
51
|
+
period: 2025
|
|
52
|
+
input:
|
|
53
|
+
state_code: DC
|
|
54
|
+
output:
|
|
55
|
+
county: DISTRICT_OF_COLUMBIA_DC
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
- name: Check default county in CA.
|
|
2
|
+
period: 2022
|
|
3
|
+
input:
|
|
4
|
+
state_code: CA
|
|
5
|
+
output:
|
|
6
|
+
first_county_in_state: ALAMEDA_COUNTY_CA
|
|
7
|
+
county: ALAMEDA_COUNTY_CA
|
|
8
|
+
|
|
9
|
+
- name: Check default county in MA.
|
|
10
|
+
period: 2022
|
|
11
|
+
input:
|
|
12
|
+
state_code: MA
|
|
13
|
+
output:
|
|
14
|
+
first_county_in_state: BARNSTABLE_COUNTY_MA
|
|
15
|
+
|
|
16
|
+
- name: Check default county in DC.
|
|
17
|
+
period: 2022
|
|
18
|
+
input:
|
|
19
|
+
state_code: DC
|
|
20
|
+
output:
|
|
21
|
+
first_county_in_state: DISTRICT_OF_COLUMBIA_DC
|
|
@@ -35,9 +35,23 @@ class county(Variable):
|
|
|
35
35
|
state_code = county_fips_codes.loc[county_fips, "state"]
|
|
36
36
|
return map_county_string_to_enum(county_name, state_code)
|
|
37
37
|
|
|
38
|
-
#
|
|
39
|
-
zip_code
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
# Check if zip_code was explicitly provided as input
|
|
39
|
+
# The zip_code variable auto-generates values, so we need to check if it was user input
|
|
40
|
+
input_variables = getattr(simulation, "input_dataset", {})
|
|
41
|
+
if (
|
|
42
|
+
isinstance(input_variables, dict)
|
|
43
|
+
and "zip_code" not in input_variables
|
|
44
|
+
):
|
|
45
|
+
# No ZIP code was provided by user, use first county in state
|
|
46
|
+
return household("first_county_in_state", period)
|
|
47
|
+
|
|
48
|
+
# Attempt to look up from ZIP code (only if explicitly provided)
|
|
49
|
+
try:
|
|
50
|
+
zip_code = household("zip_code", period).astype(int)
|
|
51
|
+
zip_codes = ZIP_CODE_DATASET.set_index("zip_code")
|
|
52
|
+
county_name = zip_codes.county[zip_code]
|
|
53
|
+
state_code = zip_codes.state[zip_code]
|
|
54
|
+
return map_county_string_to_enum(county_name, state_code)
|
|
55
|
+
except:
|
|
56
|
+
# If ZIP code lookup fails, use first county in state as fallback
|
|
57
|
+
return household("first_county_in_state", period)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from policyengine_us.model_api import *
|
|
2
|
+
from policyengine_us.variables.household.demographic.geographic.county.county_enum import (
|
|
3
|
+
County,
|
|
4
|
+
)
|
|
5
|
+
from policyengine_us.variables.household.demographic.geographic.state_code import (
|
|
6
|
+
StateCode,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class first_county_in_state(Variable):
|
|
11
|
+
value_type = Enum
|
|
12
|
+
possible_values = County
|
|
13
|
+
default_value = County.UNKNOWN
|
|
14
|
+
entity = Household
|
|
15
|
+
label = "First county alphabetically in household's state"
|
|
16
|
+
definition_period = YEAR
|
|
17
|
+
|
|
18
|
+
def formula(household, period, parameters):
|
|
19
|
+
# Get state codes as strings
|
|
20
|
+
state_code_str = household("state_code_str", period)
|
|
21
|
+
|
|
22
|
+
# Build mapping of state abbreviations to first county
|
|
23
|
+
state_to_first_county = {}
|
|
24
|
+
|
|
25
|
+
for state in StateCode:
|
|
26
|
+
state_abbr = state.value # e.g., "CA", "TX", etc.
|
|
27
|
+
|
|
28
|
+
# Find all counties for this state
|
|
29
|
+
state_counties = [
|
|
30
|
+
county
|
|
31
|
+
for county in County
|
|
32
|
+
if county != County.UNKNOWN
|
|
33
|
+
and county.value.endswith(f", {state_abbr}")
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
# Sort alphabetically and get the first one
|
|
37
|
+
if state_counties:
|
|
38
|
+
first_county = min(state_counties, key=lambda c: c.value)
|
|
39
|
+
state_to_first_county[state_abbr] = first_county
|
|
40
|
+
|
|
41
|
+
# Map each household's state to its first county
|
|
42
|
+
result = []
|
|
43
|
+
for state_abbr in state_code_str:
|
|
44
|
+
county = state_to_first_county.get(state_abbr, County.UNKNOWN)
|
|
45
|
+
result.append(county)
|
|
46
|
+
|
|
47
|
+
return np.array(result)
|
|
@@ -5014,7 +5014,8 @@ policyengine_us/tests/policy/baseline/household/demographic/age/monthly_age.yaml
|
|
|
5014
5014
|
policyengine_us/tests/policy/baseline/household/demographic/geographic/lives_in_vehicle.yaml,sha256=TaFZl3mSZl7wcuQvfCy-mmhBCzAfNZ2EXnMAPs0ZErw,585
|
|
5015
5015
|
policyengine_us/tests/policy/baseline/household/demographic/geographic/state_group.yaml,sha256=Is1iFAICyaT7gTxOFth7iFHoAM8uaGWM-Sg-OrpMG3A,192
|
|
5016
5016
|
policyengine_us/tests/policy/baseline/household/demographic/geographic/state_name.yaml,sha256=wv0gP9Cp0tOAWapOYFCZL2nLPRgs2BmTp9xnelFPFGo,154
|
|
5017
|
-
policyengine_us/tests/policy/baseline/household/demographic/geographic/county/county.yaml,sha256=
|
|
5017
|
+
policyengine_us/tests/policy/baseline/household/demographic/geographic/county/county.yaml,sha256=hMg6qJf_W6WkIXPJXPS0orEhIMIfLhcEnsrMJkPUCPk,1344
|
|
5018
|
+
policyengine_us/tests/policy/baseline/household/demographic/geographic/county/first_county_in_state.yaml,sha256=cLAyzsr2ztmvZwwPjtR06dc-IK1ZN3krMtKTFe5Wkek,446
|
|
5018
5019
|
policyengine_us/tests/policy/baseline/household/demographic/household/county_str.yaml,sha256=Ocgx2tgPj1cgXf0L1W3Id8FFFIRJko8xaa5hLaliCmQ,134
|
|
5019
5020
|
policyengine_us/tests/policy/baseline/household/demographic/person/immigration_status.yaml,sha256=Q9lF4EPbgw4XxPtIGEE6BHRlM1882JU7zLy8QogDUTo,413
|
|
5020
5021
|
policyengine_us/tests/policy/baseline/household/demographic/person/is_child_dependent.yaml,sha256=O-osoiYeJfrb7jvGTZQU9fatTHHOGlzCSRAok6IRfYU,888
|
|
@@ -7772,9 +7773,10 @@ policyengine_us/variables/household/demographic/geographic/state_group.py,sha256
|
|
|
7772
7773
|
policyengine_us/variables/household/demographic/geographic/state_group_str.py,sha256=YVapmNgz-QhCZXVfVnU72_G_fijilHLJ1kBDThX9IUE,359
|
|
7773
7774
|
policyengine_us/variables/household/demographic/geographic/state_name.py,sha256=tfpURwlCmHRJkk4m0_NVPInByKbWY0Upq7sbZUobZIs,1495
|
|
7774
7775
|
policyengine_us/variables/household/demographic/geographic/tax_unit_state.py,sha256=yQCj1TgJplNL7EGOx59C9av7isbHsyThaWheZMCjSFg,282
|
|
7775
|
-
policyengine_us/variables/household/demographic/geographic/county/county.py,sha256=
|
|
7776
|
+
policyengine_us/variables/household/demographic/geographic/county/county.py,sha256=MPPzpU7ZciOgm3paZRne4w5s7zAljGl2MkI3Xdyi5pw,2374
|
|
7776
7777
|
policyengine_us/variables/household/demographic/geographic/county/county_enum.py,sha256=2-SIpjp72QWPhQQUs8hzxrLcE2baWSkLTdCVRwKOXXw,145769
|
|
7777
7778
|
policyengine_us/variables/household/demographic/geographic/county/county_str.py,sha256=UDWJ8YqH4Ef_JTscy8LMwLAMQ_o-Zan13hziZBY3XPs,339
|
|
7779
|
+
policyengine_us/variables/household/demographic/geographic/county/first_county_in_state.py,sha256=yXCj-LVjxPeILIg42ijefTmi_j4NxJwX0kMtoE47xic,1578
|
|
7778
7780
|
policyengine_us/variables/household/demographic/geographic/state/average_home_energy_use_in_state.py,sha256=aaGYAXLU7tsx-A9NW4nyLij5J5mp0WTRXsyObngekvY,319
|
|
7779
7781
|
policyengine_us/variables/household/demographic/geographic/state/in_state.py,sha256=o3ksZCOHtlJ1JGHIXAPlqcs5-rVbTgOCcDdN1-fYqmA,551
|
|
7780
7782
|
policyengine_us/variables/household/demographic/geographic/ucgid/ucgid.py,sha256=RX4zSK6mqUoI10Jhe8XSDhrG-H0qOv3zmKMHeSl-TQY,3270
|
|
@@ -8228,8 +8230,8 @@ policyengine_us/variables/input/farm_income.py,sha256=BEKxYmHNNnWJAAvULl5qZJigy5
|
|
|
8228
8230
|
policyengine_us/variables/input/geography.py,sha256=XmBlgXhzBoLRKk6R8taVZHqUw1eU8MbNeGS9iJ7_l44,4506
|
|
8229
8231
|
policyengine_us/variables/input/self_employment_income.py,sha256=PwsGz8R4lRikKWUYOhsC0qosNNLXq4f5SQmfw4S3mk8,511
|
|
8230
8232
|
policyengine_us/variables/input/self_employment_income_before_lsr.py,sha256=E8fcX9Nlyqz8dziHhQv_euutdmoIwFMMWePUwbbwv_w,379
|
|
8231
|
-
policyengine_us-1.
|
|
8232
|
-
policyengine_us-1.
|
|
8233
|
-
policyengine_us-1.
|
|
8234
|
-
policyengine_us-1.
|
|
8235
|
-
policyengine_us-1.
|
|
8233
|
+
policyengine_us-1.363.0.dist-info/METADATA,sha256=n1BhF__JoGVF0AQgs1vRvEwQaMiT5U0qlxge0rd0VzA,1693
|
|
8234
|
+
policyengine_us-1.363.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8235
|
+
policyengine_us-1.363.0.dist-info/entry_points.txt,sha256=MLaqNyNTbReALyKNkde85VkuFFpdPWAcy8VRG1mjczc,57
|
|
8236
|
+
policyengine_us-1.363.0.dist-info/licenses/LICENSE,sha256=2N5ReRelkdqkR9a-KP-y-shmcD5P62XoYiG-miLTAzo,34519
|
|
8237
|
+
policyengine_us-1.363.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|