Bugfix/binary parameter truncation fix#247
Merged
medley56 merged 1 commit intorelease/6.1from Apr 2, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes binary parameter truncation in xarr.create_dataset when BinaryParameter values exceed 4 bytes, preparing for patch release 6.1.2 (fixes #246).
Changes:
- Convert
common.BinaryParameterinstances to plainbytesbefore passing values to NumPy, preventing truncation duringnp.asarraydtype sizing. - Add a unit test to ensure binary parameter byte-width is preserved in the resulting
xarray.Dataset. - Bump several GitHub Actions workflow dependencies and adjust the GitHub Release creation step to use a safer argument array pattern.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
space_packet_parser/xarr.py |
Casts BinaryParameter to bytes prior to NumPy array creation to prevent truncation. |
tests/unit/test_xarr.py |
Adds regression test asserting 8-byte binary fields remain 8 bytes and untruncated in datasets. |
.gitignore |
Ignores node_modules. |
.github/workflows/release.yml |
Updates artifact download action version and refactors gh release create invocation. |
.github/workflows/ci.yml |
Updates Codecov GitHub Action version. |
.github/workflows/_build.yml |
Updates artifact upload action version. |
greglucas
reviewed
Apr 2, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/6.1 #247 +/- ##
===============================================
+ Coverage 94.82% 94.85% +0.02%
===============================================
Files 48 48
Lines 3868 3885 +17
===============================================
+ Hits 3668 3685 +17
Misses 200 200 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add conditional logic in create_dataset to change BinaryParameter objects to bytes objects when creating numpy arrays of byte strings - Add a focused regression test in test_xarr.py:181 - Modify workflow run conditions for tests - Bump version to 6.1.2
bdf094a to
0660a8f
Compare
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.
Summary
This prepares for a patch release 6.1.2 with a fix for binary parameter truncation when the binary blob is longer than 4 bytes.
Fixes #246.
Approach
The only way np.asarray will correctly identify the required size for a binary blob is to pass in a bytes object (not a bytes subclass like BinaryParameter). After much digging and many attempts at changing the MRO of BinaryParameter, it appears the only fix is to conditionally cast BinaryParameter objects to bytes objects before attempting to create a numpy array.
Other Considered Option
One option that did work was to change the parent type of BinaryParameter from
bytestonp.bytes_, which correctly registers the class as a subclass ofnp.bytes_and results in numpy correctly determining the size of the bytes object.However, this would require making numpy a core dependency of Space Packet Parser, something we have long worked to avoid.
Performance Impact
This conditional recreation of a bytes object from BinaryParameter in create_dataset does impact performance when creating an xarray Dataset from packets containing BinaryParameter objects. The impact is due to creating a second, immutable copy of every BinaryParameter object (one at a time).
There should be almost no memory impact but there will be a timing impact due to the conditional check and the creation of new bytes objects. This impact should only matter for packets that include binary blobs though.