-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace to_arrayset/from_arrayset with to_buffers/from_buffers and deprecate the original. #592
Replace to_arrayset/from_arrayset with to_buffers/from_buffers and deprecate the original. #592
Conversation
Why replace The case I noticed was regular, zero-sized dimensions (either as RegularArrays or as the shape of a NumpyArray): >>> ak.from_buffers(*ak.to_buffers(ak.Array(np.empty((5, 0, 3)))))
<Array [[], [], [], [], []] type='5 * 0 * 3 * float64'>
>>> ak.from_buffers(*ak.to_buffers(ak.from_numpy(np.empty((5, 0, 3)), regulararray=True)))
<Array [[], [], [], [], []] type='5 * 0 * 3 * float64'> But I had previously overlooked RecordArrays with no fields (or equivalently, zero-field tuples): >>> ak.from_buffers(*ak.to_buffers(ak.Array([{}, {}, {}, {}, {}])))
<Array [{}, {}, {}, {}, {}] type='5 * {}'>
>>> ak.from_buffers(*ak.to_buffers(ak.Array([(), (), (), (), ()])))
<Array [(), (), (), (), ()] type='5 * ()'> The old >>> ak.from_arrayset(*ak.to_arrayset(ak.Array(np.empty((5, 0, 3)))))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jpivarski/irishep/awkward-1.0/awkward/operations/convert.py", line 4171, in from_arrayset
return from_buffers(
File "/home/jpivarski/irishep/awkward-1.0/awkward/operations/convert.py", line 3727, in from_buffers
out = _form_to_layout(*(args + (None, None)))
File "/home/jpivarski/irishep/awkward-1.0/awkward/operations/convert.py", line 3417, in _form_to_layout
array = raw_array.view(dtype).reshape(shape)
ValueError: cannot reshape array of size 0 into shape (0,3) the wrong answer for RegularArrays (this is supposed to have type >>> ak.from_arrayset(*ak.to_arrayset(ak.from_numpy(np.empty((5, 0, 3)), regulararray=True)))
<Array [] type='0 * 0 * 3 * float64'> and RecordArrays with no fields lose their lengths: >>> ak.from_arrayset(*ak.to_arrayset(ak.Array([{}, {}, {}, {}, {}])))
<Array [] type='0 * {}'>
>>> ak.from_arrayset(*ak.to_arrayset(ak.Array([(), (), (), (), ()])))
<Array [] type='0 * ()'> On top of that, the system for setting the format of key names in Since we're living in 1.x times, Data pickled with old releases (which goes through |
ak.to_buffers
ak.to_arrayset
to pass throughak.to_buffers
and all tests to work againak.from_buffers
ak.from_arrayset
to pass throughak.from_buffers
and get all tests to work againarrayset
functions tobuffers
functionsarrayset
functions tobuffers
functionsdocs-src
Jupytext notebook examples