uproot.interpretation.library.Library — Uproot documentation

# uproot.interpretation.library.Library

Defined in uproot.interpretation.library on line 42.

class uproot.interpretation.library.Library

  Abstract superclass of array-library handlers, for libraries such as NumPy, Awkward Array, and Pandas.

  A library is used in the finalization and grouping stages of producing an array, converting it from internal representations like uproot.interpretation.jagged.JaggedArray, uproot.interpretation.strings.StringArray, and uproot.interpretation.objects.ObjectArray into the library’s equivalents. It can also be required for concatenation and other late-stage operations on the output arrays.

  Libraries are usually selected by a string name. These names are held in a private registry in the uproot.interpretation.library module.

## imported

Library.imported

  Attempts to import the library and returns the imported module.

## empty

Library.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

Library.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

Library.finalize(array, branch, interpretation, entry_start, entry_stop)
  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.

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

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

## group

Library.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

Library.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

Library.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`.