extract_param_set_idx

extract_param_set_idx(key, default=None)[source]

Extract the param_set index from a pipeline result KEY.

key must be a NodeKey — a tuple of (axis_name, value) pairs, as found on the keys of a raw PipelineResult (e.g. from pipeline.run(...)). It is NOT meant for the output of evaluate(), which is already collapsed to a {param_set_idx: value} mapping whose int keys are the indices.

Raises KeyError when no param_set axis is present, unless default is given — a parameter-free body (e.g. an empty Fubini-Study prefix on the |0> state) carries no such axis and is the sole set, so callers pass default=0.

Return type:

int