uproot.language.python.PythonLanguage

Defined in uproot.language.python on line 243.

Inheritance order:

  1. uproot.language.Language

class uproot.language.python.PythonLanguage(functions=None, getter='get')
Parameters:
  • functions (None or dict) – Mapping from function name to function, or None for default_functions.

  • getter (str) – Name of the function that extracts branches by name; needed for branches whose names are not valid Python symbols. Default is “get”.

PythonLanguage is the default uproot.language.Language for interpreting expressions passed to arrays (and similar). This interpretation assumes that the expressions have Python syntax and semantics, with math functions loaded into the namespace.

Unlike standard Python, an expression with attributes, such as some.thing, can be a single identifier, so that a TBranch whose name contains dots does not need to be loaded with get("some.thing").

functions

PythonLanguage.functions

Mapping from function name to function (dict).

getter

PythonLanguage.getter

Name of the function that extracts branches by name; needed for branches whose names are not valid Python symbols.

getter_of

PythonLanguage.getter_of(name)

Returns a string, an expression in which the getter is getting name as a quoted string.

For example, "get('something')".

free_symbols

PythonLanguage.free_symbols(expression, keys, aliases, file_path, object_path)
Parameters:
  • expression (str) – The expression to analyze.

  • keys (list of str) – Names of branches or aliases (for aliases that refer to aliases).

  • aliases (list of str) – Names of aliases.

  • file_path (str) – File path for error messages.

  • object_path (str) – Object path for error messages.

Finds the symbols in the expression that are in keys or aliases, in other words, TBranch names or alias names. These expressions may include dots (attributes). Known functions and the getter are excluded.

compute_expressions

PythonLanguage.compute_expressions(hasbranches, arrays, expression_context, keys, aliases, file_path, object_path)
Parameters:
  • hasbranches (uproot.behaviors.TBranch.HasBranches) – The TTree or TBranch that is requesting a computation.

  • arrays (dict of arrays) – Inputs to the computation.

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

  • keys (set of str) – Names of branches or aliases (for aliases that refer to aliases).

  • aliases (dict of str → str) – Names of aliases and their definitions.

  • file_path (str) – File path for error messages.

  • object_path (str) – Object path for error messages.

Computes an array for each expression.