column#

class qtypy.column.constant(value, dtype=None)[source]#

Column representing a constant value.

Parameters:
  • value (any) – The constant value to store in the column.

  • cpp_value_type (str, optional) – The C++ type name for the value.

qtypy.column.definition(*args, **kwargs)[source]#

Declare a C++-backed custom column in the dataflow.

Usage:

args = []
kwargs = {}

@column.definition("CppClassName", (cpp_ctor_args...))("col1", "col2")
def user_block(slot, *args, **kwargs):
    ...

df["custom_column"] = user_block(*args, **kwargs)
Overview:
  • The first argument to column.definition is the name of the concrete C++ class implementing the qty::column::definition interface.

    • This class must be compiled and have a generated dictionary so it is accessible via PyROOT bindings.

    • You can verify availability with:

      import ROOT
      hasattr(ROOT, "CppClassName")
      
  • The optional second argument is a tuple of constructor arguments for the C++ class. If omitted, the default constructor is used.

    • All constructor arguments are passed as strings to the Cling interpreter.

    • For non-trivial types, the string must be a valid C++ expression.

      Examples:
      • Pass a string / std::string:

        '"arg"'
        
      • Pass a vector from Python:

        f'std::vector<double>{{{", ".join(str(v) for v in vec)}}}'
        
    • In practice, it is often simpler to rely on the default constructor and perform configuration in the Python user_block.

  • The second function call specifies the names of input columns from the dataflow.

    • These columns must already exist.

    • They are passed as qty::column::observable objects to the C++ class evaluate() method.

  • The decorated function (user_block) is invoked on the instantiated C++ object(s).

    • The first argument (slot) is the C++ instance.

    • Additional arguments are user-defined.

    • This function is executed after instantiation and connection to the dataflow, but before the event loop starts.

    • This is the recommended place to configure the C++ instance (e.g., set member variables), making constructor arguments often unnecessary.

Args:

cpp_class (str): Name of the C++ class.

cpp_ctor_args (tuple, optional): Constructor arguments passed to the

C++ class as strings.

Returns:

Callable: A decorator that produces a Definition column.