Repository navigation
Cast line_idx to int64 in empty PDB record frames - #167
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation correctly resolves the dtype inconsistency and includes appropriate regression coverage.
0 open findings
What changed in this PR
Ensures line_idx consistently uses int64, including empty PDB record DataFrames.
Changes:
- Casts
line_idxtonp.int64during DataFrame construction. - Adds regression coverage for empty records.
- Documents the fix for issue #64.
| File | Description |
|---|---|
biopandas/pdb/pandas_pdb.py |
Applies the consistent line_idx dtype. |
tests/pdb/test_read_pdb.py |
Verifies dtypes across record frames. |
docs/CHANGELOG.md |
Records the bug fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
a-r-j
marked this pull request as ready for review
October 17, 2026 16:47
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.
Description
The
line_idxcolumn of an empty record DataFrame (e.g.ANISOUfor a file without anisotropic records, orHETATMfor a protein-only file) comes out asobject, while non-empty frames getint64._construct_dfcasts every column listed inpdb_records, butline_idxis appended separately and was never cast. This casts it toint64after the existing dtype loop, as suggested in the issue.Tested: the new
test_line_idx_dtype_for_empty_recordsfails onmain(dtype('O')forANISOUin3eiy.pdb) and passes with the change. Fullpytest: 144 passed, 3 skipped, 14 xfailed.flake8reports nothing new on the touched files.Related issues or pull requests
Fixes #64
Pull Request Checklist
docs/CHANGELOG.mdtests/pdb/test_read_pdb.pypytestand all tests passflake8