local_fold

local_fold(dag, scale, *, selection='random', exclude=None, rng=None)[source]

Apply LocalFoldPass and return (folded_dag, effective_scale).

For use with ZNE via functools.partial when customising selection / exclude / rng:

from functools import partial
zne = ZNE(
    scale_factors=[1.0, 1.5, 2.0],
    folding_fn=partial(local_fold, selection="from_left"),
)

Mutates dag in place (deepcopy first if the original is needed).

Return type:

tuple[DAGCircuit, float]