group_by_base_key¶
- group_by_base_key(results, axis_name, *, indexed=False)[source]¶
Group child results by base key (label with axis stripped).
- Parameters:
results (
dict[Any,Any]) – Child label -> value mapping from the pipeline.axis_name (
str) – Axis to strip from labels to form base_key.indexed (
bool) – If False, values are collected into a list per base_key. If True, values are stored in a dict[int, value] keyed by the axis value (parsed as int) so they can be ordered later.
- Returns:
dict[base_key, list[value]]- If indexed=True:dict[base_key, dict[int, value]]- Return type:
Example:
>>> results = {(('circ', 0), ('obs', 0)): 1.5, (('circ', 0), ('obs', 1)): 2.0} >>> group_by_base_key(results, 'obs') {(('circ', 0),): [1.5, 2.0]} >>> group_by_base_key(results, 'obs', indexed=True) {(('circ', 0),): {0: 1.5, 1: 2.0}}