Skip to content

Check every mapping table against the HCAT taxonomy - #305

Open
ivorbosloper wants to merge 1 commit into
mainfrom
split/hcat-check
Open

ivorbosloper wants to merge 1 commit into
mainfrom
split/hcat-check

Conversation

@ivorbosloper

Copy link
Copy Markdown
Collaborator

Every HCAT3_name in a mapping table has to carry that name's code. A wrong code is invisible today: the file validates, and a crop query quietly returns another crop — see #304, where 2,098 published fields do exactly that.

tests/test_hcat_codes.py walks every CSV under tests/data-files/ that has HCAT3 columns and checks both halves of the pair against tests/data-files/hcat3.csv (a copy of https://fiboa.org/code/hcat3.csv). Offline and instant.

The 23 rows that are wrong today are listed in KNOWN_BAD with the reason, so the test passes now and a new mistake fails. Injecting one of each kind into dk_2019.csv gives:

convert/dk/dk_2019.csv 1: spring_barley has 3301010403, the taxonomy says 3301010402
convert/dk/dk_2019.csv 2: 'spring_soft_wheat' is not an HCAT class

Two things found while writing it:

  • sk/sk.csv in the fixtures is stale — 244 rows against 320 live, and it still has parsley and zucchini_courgette 3301140200 where the published list has been corrected to parsly and 3301140600. So the conversion tests exercise a table that is no longer what the converter reads. Not fixed here: refreshing it changes what the sk conversion test expects.
  • The check only reaches tables that exist as fixtures — 23 of the 32 bad rows in 32 rows across the code lists disagree with the HCAT taxonomy #304. ch, pt and at have no fixture, so their errors are invisible to it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DVx9uQV2QPM8ecPAY3ZjXG

A wrong code is invisible: the file validates and a crop query quietly
returns another crop. The 23 rows that are wrong today are recorded, so a
new mistake fails.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DVx9uQV2QPM8ecPAY3ZjXG
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.

1 participant