Skip to content

Fix EVALID year parsing for single-digit state FIPS codes#79

Merged
mihiarc merged 2 commits intomainfrom
fix/evalid-year-parsing-single-digit-fips
Mar 14, 2026
Merged

Fix EVALID year parsing for single-digit state FIPS codes#79
mihiarc merged 2 commits intomainfrom
fix/evalid-year-parsing-single-digit-fips

Conversation

@mihiarc
Copy link
Copy Markdown
Owner

@mihiarc mihiarc commented Mar 14, 2026

Summary

  • find_evalid() parsed EVALID as fixed-width SSYYTT using positional string slicing, which fails for states with single-digit FIPS codes (AL=1, AR=5)
  • Alabama's EVALID 12401 (state=1, year=24, type=01) was misparsed as state=12, year=40 → interpreted as 1940, causing clip_most_recent() to select 2003 periodic inventory instead of 2024 annual data
  • Replaced EVALID string parsing with END_INVYR from POP_EVAL, an unambiguous 4-digit year already in the joined dataframe
  • Removed the now-unused _add_parsed_evalid_columns() function and its EVALIDYearParsing import

Test plan

  • 724 unit tests pass
  • Volume validation: exact EVALIDator match (Georgia)
  • GRM validation: exact EVALIDator match (growth, mortality, removals)
  • ruff + mypy clean

Closes #78

mihiarc added 2 commits March 14, 2026 10:28
find_evalid() parsed EVALID as fixed-width SSYYTT using positional
string slicing, which fails for states with single-digit FIPS codes
(AL=1, AR=5). A 5-digit EVALID like 12401 (AL, year=24, type=01)
was misparsed as state=12, year=40, causing clip_most_recent() to
select 2003 periodic inventory instead of 2024 annual inventory.

Replace EVALID string parsing with END_INVYR from POP_EVAL, which is
an unambiguous 4-digit year already available in the joined dataframe.
Remove the now-unused _add_parsed_evalid_columns() function.

Closes #78
Add EVALID as secondary sort key (descending) for deterministic
tiebreaking when multiple evaluations share the same END_INVYR.

Add unit tests covering single-digit FIPS codes (Alabama, Arkansas),
standard 2-digit codes (Georgia), multi-state selection, and
tiebreaking behavior.
@mihiarc mihiarc merged commit 985e93f into main Mar 14, 2026
3 checks passed
@mihiarc mihiarc deleted the fix/evalid-year-parsing-single-digit-fips branch March 14, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EVALID year parsing fails for single-digit state FIPS codes

1 participant