uproot.interpretation.library.Awkward

Defined in uproot.interpretation.library on line 476.

Inheritance order:

  1. uproot.interpretation.library.Library

class uproot.interpretation.library.Awkward

A uproot.interpretation.library.Library that presents TBranch data as Awkward Arrays. The standard name for this library is "ak".

This is the default for all functions that require a uproot.interpretation.library.Library, though Uproot does not explicitly depend on Awkward Array. If you are confronted with a message that Awkward Array is not installed, either install awkward or select another library (likely uproot.interpretation.library.NumPy).

Both the single-TBranch and “group” forms for this library are ak.Array, though groups are always arrays of records. Awkward Array was originally developed for Uproot, so the data structures are usually optimial for Uproot data.

The “group” behavior for this library is:

  • how=None: an array of Awkward records.

  • how=dict: a dict of str → array, mapping the names to arrays.

  • how=tuple: a tuple of arrays, in the order requested. (Names are lost.)

  • how=list: a list of arrays, in the order requested. (Names are lost.)

Since Awkward arrays are not indexed, global_index has no effect.

imported

Inherited from uproot.interpretation.library.Library.

Awkward.imported

empty

Inherited from uproot.interpretation.library.Library.

Awkward.empty(shape, dtype)
Parameters:
  • shape (tuple of int) – NumPy array shape. (The first item must be zero.)

  • dtype (numpy.dtype or its constructor argument) – NumPy array dtype.

Returns an empty NumPy-like array.

zeros

Inherited from uproot.interpretation.library.Library.

Awkward.zeros(shape, dtype)
Parameters:
  • shape (tuple of int) – NumPy array shape. (The first item must be zero.)

  • dtype (numpy.dtype or its constructor argument) – NumPy array dtype.

Returns a NumPy-like array of zeros.

finalize

Inherited from uproot.interpretation.library.Library.

Awkward.finalize(array, branch, interpretation, entry_start, entry_stop, options)
Parameters:
  • array (array) – Internal, temporary, trimmed array. If this is a NumPy array, it may be identical to the output array.

  • branch (uproot.TBranch) – The TBranch that is represented by this array.

  • interpretation (uproot.interpretation.Interpretation) – The interpretation that produced the array.

  • entry_start (int) – First entry that is included in the output.

  • entry_stop (int) – FIrst entry that is excluded (one greater than the last entry that is included) in the output.

  • interp_options (dict) – Flags and other options passed through the interpretation process.

Create a library-appropriate output array for this temporary array.

This array would represent one TBranch (i.e. not a “group”).

group

Inherited from uproot.interpretation.library.Library.

Awkward.group(arrays, expression_context, how)
Parameters:
  • arrays (dict of str → array) – Mapping from names to finalized array objets to combine into a group.

  • expression_context (list of (str, dict) tuples) – Expression strings and a dict of metadata about each.

  • how (None, str, or container type) – Library-dependent instructions for grouping. The only recognized container types are tuple, list, and dict. Note that the container type itself must be passed as how, not an instance of that type (i.e. how=tuple, not how=()).

Combine the finalized arrays into a library-appropriate group type.

global_index

Inherited from uproot.interpretation.library.Library.

Awkward.global_index(array, global_offset)
Parameters:
  • array (array) – The library-appropriate array whose global index needs adjustment.

  • global_offset (int) – A number to add to the global index of array to correct it.

Apply in-place corrections to the global index of array by adding global_offset.

Even though the operation is performed in-place, this method returns the array.

concatenate

Inherited from uproot.interpretation.library.Library.

Awkward.concatenate(all_arrays)
Parameters:

all_arrays (list of arrays) – A list of library-appropriate arrays that need to be concatenated.

Returns a concatenated version of all_arrays.