qml.noise.op_eq¶
- op_eq(ops)[source]¶
Builds a conditional as a
BooleanFn
for evaluating if a given operation is equal to the specified operation.- Parameters
ops (str, class, Operation, MeasurementProcess) – String representation, an instance or class of the operation, or a measurement process.
- Returns
A callable object that accepts an
Operation
orMeasurementProcess
and returns a boolean output. For an input from:Union[str, class, Operation]
it evaluates toTrue
if the input operations are equal to the operations specified byops
. For aMeasurementProcess
input, similar evaluation happens on its observable. In both cases, the comparison is based on the operation’s type, irrespective of wires.- Return type
Example
One may use
op_eq
with a string representation of the name of the operation:>>> cond_func = qml.noise.op_eq("RX") >>> cond_func(qml.RX(1.23, wires=[0])) True
>>> cond_func(qml.RZ(1.23, wires=[3])) False
>>> cond_func("CNOT") False
Additionally, an instance of
Operation
can also be provided:>>> cond_func = qml.noise.op_eq(qml.RX(1.0, "dino")) >>> cond_func(qml.RX(1.23, wires=["eve"])) True
>>> cond_func(qml.RY(1.23, wires=["dino"])) False