qml.noise.meas_eq¶
- meas_eq(mps)[source]¶
Builds a conditional as a
BooleanFnfor evaluating if a given measurement process is of the same type as the specified measurement process.- Parameters:
mps (MeasurementProcess, Callable) – An instance(s) of any class that inherits from
MeasurementProcessor ameasurementfunction(s).- Returns:
A callable object that accepts an instance of
MeasurementProcessand returns a boolean output. It accepts any input from:Union[class, function, list(Union[class, function, MeasurementProcess])]and evaluates toTrueif 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_eqwith 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
measurementfunction 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