fix: consistent byteorder settings#3954
Merged
Merged
Conversation
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3954 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
|
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.
Making a few changes to have consistent byteorder settings in the codebase.
First of all,
ak.to_buffersdefaults to native byteorder here:awkward/src/awkward/operations/ak_to_buffers.py
Line 24 in 8640184
We do the same for
ak._do.to_buffers(which is used insideak.to_buffers) for consistency even though it's semi-public API.Secondly, buffers are generally native (always or almost always) as they are in-memory. Therefore
ak.to_buffersshould have the same defaults asak.to_buffers.ak.from_buffers(*ak.to_buffers(...))should just work on all systems. One shouldn't have to specifyak.from_buffers(*ak.to_buffers(...), byteorder=ak._util.native_byteorder)in order for this to work on a big-endian system for example.And finally, awkward expects arrays/dtypes to be in native byteorder when the
NumpyArrayandIndexclasses are constructed as wrappers around the buffers. We modify the naming in the tests to express just that as the default in awkward internally is not "little". It's "native".All of these changes are no-ops for little endian systems as
ak._util.native_byteorderis"<". But they make byteorder settings more self-consistent in the codebase and make these ops that depend on byteorder seamless in big endian systems without one having to specifybyteorder=">"explicitly just because they are on a different system.