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) – String representation, an instance or class of the operation.
- Returns
A callable object that accepts an
Operation
and returns a boolean output. It accepts any input from:Union[str, class, Operation]
and evaluates toTrue
if the input operation(s) is equal to the set of operation(s) specified byops
. 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
code/api/pennylane.noise.op_eq
Download Python script
Download Notebook
View on GitHub