Repository navigation
Fix BinaryCIF interval quantization and delta decoding - #265
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 56 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request fixes issues in the BinaryCIF decoder by correcting the interval quantization step size calculation, reading the standard numSteps field, and ensuring delta decoding copies its input to avoid modifying a read-only buffer. It also adds corresponding unit tests and updates the release notes. The review feedback suggests adding robust error handling to prevent a potential ZeroDivisionError when numSteps is 1 or less, and an IndexError when decoding empty columns.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
==========================================
+ Coverage 87.53% 87.55% +0.01%
==========================================
Files 294 294
Lines 60497 60497
==========================================
+ Hits 52956 52967 +11
+ Misses 7541 7530 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Independent review Correct, and ready to merge.
On Gemini's two points (neither blocks the merge):
🤖 Generated with Claude Code |
Valid BinaryCIF numeric columns failed to decode in two cases: interval quantization looked up
num_stepsinstead of the standardnumSteps, and delta decoding tried to modify the read-only array returned by ByteArray decoding.Read
numSteps, calculate the quantization step as(max - min) / (numSteps - 1), and copy delta input before modifying it. An interval with min=1, max=2, and three steps now decodes[0, 1, 2]to[1, 1.5, 2]. The metadata and arithmetic follow the BinaryCIF encoding specification.Regression tests start with encoded byte payloads and exercise the complete decoding chains. They cover both floating-point output types and zero, positive, and negative delta origins. All five new subcases fail on the original code with
KeyError: 'num_steps'orValueError: assignment destination is read-only, and pass after the fix.Validation on Linux, CPython 3.14.6:
python -m pytest --offline -q Tests/test_PDB_binary_cif.py: 18 passed, 25 subtests passed, including the existing public-parser structure comparisons.pre-commit run --all-files: passed, including both mypy checks.Other platforms and Python versions were not tested locally; CI is pending. This fixes the two BinaryCIF findings from the review. The alignment safety fixes are independently covered by #264; neither PR depends on the other.