fast_carpenter.define.variables module

exception fast_carpenter.define.variables.BadVariablesConfig[source]

Bases: Exception

class fast_carpenter.define.variables.CalculationCfg(name, expression, reduction, fill_missing, mask)[source]

Bases: tuple


Alias for field number 1


Alias for field number 3


Alias for field number 4


Alias for field number 0


Alias for field number 2

class fast_carpenter.define.variables.Define(name, out_dir, variables)[source]

Bases: object

Creates new variables using a string-based expression.

There are two types of expressions:

  • Simple formulae, and
  • Reducing formulae.

The essential difference, unfortunately, is an internal one: simple expressions are nearly directly handled by numexpr, whereas reducing expressions add a layer on top.

From a users perspective, however, simple expressions are those that preserve the dimensionality of the input. If one of the input variables represents a list of values for each event (whose length might vary), then the output will contain an equal-length list of values for each event.

If, however, a reducing expression is used, then there will be one less dimension on the resulting variable. In this case, if an input variable has a list of values for each event, the result of the expression will only contain a single value per event.


variables (list[dictionary]) – A list of single-length dictionaries whose key is the name of the resulting variable, and whose value is the expression to create it.

Other Parameters:
  • name (str) – The name of this stage (handled automatically by fast-flow)
  • out_dir (str) – Where to put the summary table (handled automatically by fast-flow)


  - Muon_pt: "sqrt(Muon_px**2 + Muon_py**2)"
  - Muon_is_good: (Muon_iso > 0.3) & (Muon_pt > 10)
  - NGoodMuons: {reduce: count_nonzero, formula: Muon_is_good}
  - First_Muon_pt: {reduce: 0, formula: Muon_pt}

See also

class fast_carpenter.define.variables.DefinePandas(name, out_dir, variables)[source]

Bases: object

fast_carpenter.define.variables.full_evaluate(tree, expression, fill_missing, mask=None, reduction=None)[source]