Repository navigation
Conversation
… 'NA' group values Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Who hits this: Anyone running
augur filter --group-by country_code --group-by-weights weights.tsvwhen a grouping column contains literal strings parsed as missing by pandas by default, such as ISO alpha-2 country codeNA(Namibia) or influenza segmentNA. https://docs.nextstrain.org/en/latest/guides/bioinformatics/filtering-and-subsampling.htmlDescription of proposed changes
augur/io/metadata.py:read_metadata()reads TSV metadata withna_filter=False, so literal values such asNA(Namibia) orNonestay strings. However,augur/filter/weights_file.py:read_weights_file()calledpd.read_csv(..., dtype="string")withoutna_filter=False, so pandas convertedNA,N/A,None,NULL,nan, and blank cells topd.NA.Because the metadata reader kept
'NA'as a string while the weights reader turned'NA'intopd.NA:NA=3,ZA=1,default=1(budget 4,--subsample-seed 42),NAfell back todefault=1, yielding2:2quotas (nam1, nam3, zaf2, zaf4) instead of3:1(nam1, nam3, nam4, zaf2).NA=0,ZA=1,default=1,NAfell back todefault=1(2:2quotas) instead of excludingNA(0:4, selecting onlyzaf1..zaf4).NA=3,ZA=1and no default row,augur filterexited with code 2 reporting'country_code': ['NA']as uncovered.NAor blank cell in theweightcolumn becamepd.NA, bypassed the nullable-boolean mask inread_weights_file(), and crashed downstream with an unhandledValueError: cannot convert NA to integertraceback instead of raisingInvalidWeightsFilewith the offending line number.Changes
augur/filter/weights_file.py: passna_filter=Falsetopd.read_csv(...)inread_weights_file(), matchingread_metadata().tests/filter/test_weights_file.py: add unit tests covering literal NA-like group tokens ("NA","N/A","None","NULL","nan",""), explicit weights, zero-weight exclusion, complete weights files without a default, and cleanInvalidWeightsFilerejection forNA/blank weight cells.Verification
augur filter --group-by country_code --group-by-weights(single-key and multi-keycountry_code×year, plus blank-value and default-row controls).pytest tests/filter augur/filter: 68 passed (baseline: 54 passed).pytest --no-cov: 1,559 passed (baseline: 1,545 passed), all 6/6 weighted cram functional tests passed,mypyclean (0issues in 87 files),flake8clean (0diagnostics).Checklist
pytest, weighted cram tests,mypy,flake8)tests/filter/test_weights_file.pyFound and written with AI agents; a separate AI referee reproduced the problem before this PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N