fix: byteswap non-native input instead of reinterpreting it - #152
Merged
tlambert03 merged 1 commit intoAug 12, 2026
Merged
Conversation
Data in non-native byte order maps to the wrong colors. On a little-endian host, a big-endian float array has its bytes relabelled rather than reordered, so -0.5, 1.5 and NaN all decode as tiny denormals and land on the first ramp color. under, over and bad are unreachable for such input. The numpy 2 migration in pyapp-kit#60 replaced xa.byteswap().newbyteorder(), which numpy 2 removed, with a plain .view() of the swapped dtype. byteswap().view(dtype.newbyteorder()) is the numpy 2 spelling of the original, and what matplotlib uses today. The existing coverage maps an array of zeros and asserts only its shape, both of which are invariant under the bug. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Reviewed-By: Codex (gpt-5.6-sol, reasoning effort xhigh)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
==========================================
- Coverage 95.71% 95.70% -0.01%
==========================================
Files 168 168
Lines 2192 2191 -1
==========================================
- Hits 2098 2097 -1
Misses 94 94 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
matthiasschabel
marked this pull request as ready for review
August 10, 2026 21:27
Member
|
thanks! |
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.
Data in non-native byte order maps to the wrong colors.
reordered, so
-0.5,1.5andNaNall decode as tiny denormals.under,overandbadunreachable forsuch input.
The numpy 2 migration in #60 replaced
xa.byteswap().newbyteorder(), which numpy 2 removed,with a plain
.view()of the swapped dtype.byteswap().view(dtype.newbyteorder())is thenumpy 2 spelling of the original, and what matplotlib uses today.