Use positional access for the reference row in build_tables#24
Open
arpitjain099 wants to merge 1 commit into
Open
Use positional access for the reference row in build_tables#24arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
build_tables read the first (root/reference) row of each column with column[0]. Because the Series is indexed by sample-name strings, [0] is a label lookup, not a positional one. On pandas 2.x that raised a deprecation warning and on pandas 3.x it fails hard with KeyError: 0, crashing cascade-table construction during Step 2. Switch the three sites to column.iloc[0], which is the positional access the code intends (the comment notes column[0] is the top row / root / reference). Fixes USDA-VS#22 Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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.
Fixes #22.
build_tablesinbin/vsnp3_fasta_to_snps_table.pyreads the first (root/reference) row of each column withcolumn[0]at three sites (lines 290, 304, 335). The column is apandas.Seriesindexed by sample-name strings, socolumn[0]is a label lookup for the label0, not positional access. On pandas 2.x that still worked but emitted a deprecation warning; on pandas 3.x it fails hard withKeyError: 0, which crashes cascade-table construction during Step 2 (traceback in the issue).The fix is
column.iloc[0], which is the positional access the code intends - the comment on line 290 even notes thatcolumn[0]is the top row / root / reference. The value returned is unchanged (the first/top row), so behavior is the same on older pandas and no longer crashes on newer pandas.The repo has no test harness for this module, so I verified the semantics directly: for a string-indexed Series,
s.iloc[0]returns the first element whiles[0]raisesKeyErroron pandas 3.x (and warns on 2.x).python -m py_compileon the changed file passes.