PipelineResult

class PipelineResult[source]

Bases: dict

Pipeline result dict with convenience access for single-result pipelines.

Behaves exactly like a regular dict keyed by NodeKey tuples. For the common single-circuit case, use the value property instead of result[()].

Attributes Summary

value

Return the single result value, unwrapped at the boundary.

Attributes Documentation

value

Return the single result value, unwrapped at the boundary.

Pipelines store expectation values in a canonical list[float] shape indexed by observable position. This accessor squeezes a length-1 list (single-observable expval) to a scalar float so casual callers get the natural shape — mirroring the scalar-in/scalar-out symmetry of higher-level programs like TimeEvolution. Probability and count dicts pass through unchanged; multi-observable lists are returned as-is.

result[()] gives the unsqueezed pipeline-internal form, but only when the spec stage’s reduce collapses its own axis (which the built-in spec stages do for single-circuit batches). Custom spec stages must mirror that behavior; if they do not, the result will not have a () key. evaluate() returns {param_set_idx: value} where value is the unsqueezed form (e.g. [1.0] for a single expectation value, not 1.0).

When the source MetaCircuit was constructed with _was_multi_obs=True (e.g. the user wrote observable=[O]), the pipeline disables the squeeze and a length-1 list is returned as-is.

Raises:

ValueError – If the result contains more than one key.