Skip to content

Commit c6c580b

Browse files
committed
fix: Properly type FIPS as string
1 parent 739169b commit c6c580b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

policyengine_us/tests/policy/baseline/household/demographic/geographic/county/county.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# Test runner in policyengine-core uses `numexpr.evaluate()` under the hood
2-
# to convert strings to expressions, where possible. This causes errors for
3-
# FIPS codes with leading zeros, EVEN WHEN DEFINED AS STRINGS. However, they do
4-
# work correctly in the code itself, as demonstrated with vectorized input
5-
# in last test case.
61
- name: County based on county FIPS for Nassau County, New York state
72
period: 2025
83
input:
@@ -17,6 +12,27 @@
1712
output:
1813
county: PHILADELPHIA_COUNTY_PA
1914

15+
- name: County derived from county FIPS for Los Angeles County, California
16+
period: 2025
17+
input:
18+
county_fips: "06037"
19+
output:
20+
county: LOS_ANGELES_COUNTY_CA
21+
22+
- name: County equivalent for District of Columnbia
23+
period: 2025
24+
input:
25+
county_fips: "11001"
26+
output:
27+
county: DISTRICT_OF_COLUMBIA_DC
28+
29+
- name: FIPS for Mayagüez, Puerto Rico
30+
period: 2025
31+
input:
32+
county_fips: "72097"
33+
output:
34+
county: MAYAGÜEZ_MUNICIPIO_PR
35+
2036
- name: County FIPS for vectorized input
2137
period: 2025
2238
input:

policyengine_us/variables/input/geography.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def formula(household, period, parameters):
128128

129129

130130
class county_fips(Variable):
131-
value_type = int
131+
value_type = str
132132
label = "County FIPS code"
133133
entity = Household
134134
definition_period = YEAR

0 commit comments

Comments
 (0)