captest.util.transform_calc_params

captest.util.transform_calc_params(node, cd, agg_cache=None, verbose=True)

Recursively transform a calc_params node, returning resolved values.

This function processes a nested dictionary structure that defines regression parameters, executing aggregations and calculations as needed, and returns a flattened structure with resolved column names.

Node types handled: - dict: Transform each value recursively - tuple (str, str): Aggregation - returns aggregated column name - tuple (callable, dict): Calculation - executes function, returns function name - str: Column group ID - resolved to column name if single column - other: Passed through unchanged (e.g., numeric values)

Parameters:
  • node (dict, tuple, str, or other) – The current node in the calc_params structure.

  • cd (CapData) – CapData instance that functions will act on.

  • agg_cache (dict, optional) – Cache of already aggregated column groups to avoid redundant calls. Keys are tuples of (group_id, agg_func), values are aggregated column names.

  • verbose (bool, default True) – Passed to aggregations and calculations. Set to False to suppress output.

Returns:

The transformed node with all aggregations executed and calculations replaced by their function names.

Return type:

transformed