qml.noise.meas_eq¶
- meas_eq(mps)[source]¶
Builds a conditional as a
BooleanFn
for evaluating if a given measurement process is equal to the specified measurement process.- Parameters
mps (MeasurementProcess, Callable) – An instance(s) of any class that inherits from
MeasurementProcess
or ameasurement
function(s).- Returns
A callable object that accepts an instance of
MeasurementProcess
and returns a boolean output. It accepts any input from:Union[class, function, list(Union[class, function, MeasurementProcess])]
and evaluates toTrue
if the input measurement process(es) is equal to the measurement process(es) specified byops
. Comparison is based on the measurement’s return type, irrespective of wires, observables or any other relevant attribute.- Return type
Example
One may use
meas_eq
with an instance ofMeasurementProcess
:>>> cond_func = qml.noise.meas_eq(qml.expval(qml.Y(0))) >>> cond_func(qml.expval(qml.Z(9))) True
>>> cond_func(qml.sample(op=qml.Y(0))) False
Additionally, a
measurement
function can also be provided:>>> cond_func = qml.noise.meas_eq(qml.expval) >>> cond_func(qml.expval(qml.X(0))) True
>>> cond_func(qml.probs(wires=[0, 1])) False
>>> cond_func(qml.counts(qml.Z(0))) False