qml.noise.wires_in¶
- wires_in(wires)[source]¶
Builds a conditional as a
BooleanFnfor evaluating if the wires of an input operation are within the specified set of wires.- Parameters:
wires (Union(Iterable[int, str], Wires, Operation, MeasurementProcess, int, str)) – Object to be used for building the wire set.
- Returns:
A callable object with signature
Union(Iterable[int, str], Wires, Operation, MeasurementProcess, int, str). It evaluates toTrueif the wire set constructed from the input to the callable is a subset of the one built from the specifiedwiresset.- Return type:
- Raises:
ValueError – If the wire set cannot be computed from
wires.
Example
One may use
wires_inwith a given sequence of wires which are used as a wire set:>>> cond_func = qml.noise.wires_in([0, 1]) >>> cond_func(qml.X(0)) True
>>> cond_func(qml.X(3)) False
Additionally, if an
Operationis provided, itswiresare extracted and used to build the wire set:>>> cond_func = qml.noise.wires_in(qml.CNOT(["alice", "bob"])) >>> cond_func("alice") True
>>> cond_func("eve") False