trappy.stats.Trigger module

Trigger is a representation of the following:

  • Event(s) (trappy.base.Base)

  • An associated value
    • scalar
    • vector
  • A set of filters
    • value based
    • function based
class trappy.stats.Trigger.Trigger(trace, template, filters, value, pivot)[source]

Bases: object

Trigger is an event-value relationship which accepts a trace object to “generate” qualified data

Parameters:
  • trace (trappy.trace.FTrace) – A trappy FTrace object
  • template (trappy.Base) – A trappy Event to act as a trigger
  • filters (dict) – Key value filter pairs

The filter can either have a function:

def function_based_filter(elem):
    if condition:
        return True
    else:
        return False

or a value/list of values

f = {}
f["data_column_a"] = function_based_filter
f["data_column_b"] = value

function_based_filter is anything that behaves like a function, i.e. a callable.

Parameters:
  • value (str, int, float) – Value can be a string or a numeric
  • pivot (str) – This is the column around which the data will be pivoted
generate(pivot_val)[source]

Generate the trigger data for a given pivot value and a trace index

Parameters:pivot_val (hashable) – The pivot to generate data for
trappy.stats.Trigger.apply_filter_kv(key, value, data_frame, mask)[source]

Internal function to apply a key value filter to a data_frame and update the initial condition provided in mask.

Parameters:
  • value – The value to checked for
  • data_frame (pandas.DataFrame) – The data to be filtered
  • mask (pandas.Series) – Initial Condition Mask
Returns:

A mask to index the data frame