ak.from_buffers#
Defined in awkward.operations.ak_from_buffers on line 19.
- ak.from_buffers(form, length, container, buffer_key='{form_key}-{attribute}', *, backend='cpu', byteorder='<', highlevel=True, behavior=None)#
 - Parameters
 form (
ak.forms.Formor str/dict equivalent) – The form of the Awkward Array to reconstitute from named buffers.length (int) – Length of the array. (The output of this function is always single-partition.)
container (Mapping, such as dict) – The str → Python buffers that represent the decomposed Awkward Array. This
containeris only assumed to have a__getitem__method that accepts strings as keys.buffer_key (str or callable) – Python format string containing
"{form_key}"and/or"{attribute}"or a function that takes these as keyword arguments and returns a string to use as a key for a buffer in thecontainer.backend (str) – Library to use to generate values that are put into the new array. The default, cpu, makes NumPy arrays, which are in main memory (e.g. not GPU). If all the values in
containerhave the samebackendas this, they won’t be copied.byteorder (
"<",">") – Endianness of buffers read fromcontainer. If the byteorder does not match the current system byteorder, the arrays will be copied.highlevel (bool) – If True, return an
ak.Array; otherwise, return a low-levelak.contents.Contentsubclass.behavior (None or dict) – Custom
ak.behaviorfor the output array, if high-level.
Reconstitutes an Awkward Array from a Form, length, and a collection of memory buffers, so that data can be losslessly read from file formats and storage devices that only map names to binary blobs (such as a filesystem directory).
The first three arguments of this function are the return values of
ak.to_buffers, so a full round-trip is
>>> reconstituted = ak.from_buffers(*ak.to_buffers(original))
The container argument lets you specify your own Mapping, which might be
an interface to some storage format or device (e.g. h5py). It’s okay if
the container dropped NumPy’s dtype and shape information, leaving
raw bytes, since dtype and shape can be reconstituted from the
ak.forms.NumpyForm.
If the values of container are recognised as arrays by the given backend,
a view over their existing data will be used, where possible.
The buffer_key should be the same as the one used in ak.to_buffers.
See ak.to_buffers for examples.