fix: properly respect requested byteorder in ak.from_buffers for ndarray buffers#3820
Conversation
|
It's draft only cause I want to add tests. Like this: import awkward as ak
array = ak.Array([1,2,3])
print(array)
print(ak.from_buffers(*ak.to_buffers(array, byteorder=">"), byteorder=">"))which incorrectly prints on main and with the fix. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3820 |
|
I have to check for Like so >>> import numpy as np
>>> np.frombuffer(b"", count=2**100)
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
np.frombuffer(b"", count=2**100)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
OverflowError: Python int too large to convert to C ssize_t |
ariostas
left a comment
There was a problem hiding this comment.
Just checked, and ak._util.native_to_byteorder only copies data when the byte order differs, so it looks good to me!
|
yeah we do the same when the buffer is just bytes a few lines below. It was just forgotten for arrays |
Fixes #3821
Currently the byteorder argument is only respected when the input buffers are bytes and not ndarrays.
This fixes that.