qml.noise.wires_in

wires_in(wires)[source]

Builds a conditional as a BooleanFn for evaluating if the wires of an input operation are within the specified set of wires.

Parameters

wires (Union(Iterable[int, str], Wires, Operation, int, str)) – Object to be used for building the wire set.

Returns

A callable object with signature Union(Iterable[int, str], Wires, Operation, int, str). It evaluates to True if the wire set constructed from the input to the callable is a subset of the one built from the specified wires set.

Return type

WiresIn

Raises

ValueError – If the wire set cannot be computed from wires.

Example

One may use wires_in with 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 Operation is provided, its wires are 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