95a3314789b0b19f68b803804e2c55be067ff884,qiskit/aqua/operators/common.py,,measure_pauli_z,#Any#Any#,43
Before Change
observable = 0
tot = sum(data.values())
for key in data:
value = 1
for j in range(pauli.numberofqubits):
if ((pauli.x[j] or pauli.z[j]) and
key[pauli.numberofqubits - j - 1] == "1"):
value = -value
// print(key, data[key])
observable = observable + value * data[key] / tot
return observable
// observable = 0.0
// num_shots = sum(data.values())
After Change
observable = 0.0
num_shots = sum(data.values())
p_z_or_x = np.logical_or(pauli.z, pauli.x)
for key, value in data.items():
bitstr = np.asarray(list(key))[::-1].astype(np.bool)
// pylint: disable=no-member
sign = -1.0 if np.logical_xor.reduce(np.logical_and(bitstr, p_z_or_x)) else 1.0
observable += sign * value
observable /= num_shots
return observable
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances
Project Name: Qiskit/qiskit-aqua
Commit Name: 95a3314789b0b19f68b803804e2c55be067ff884
Time: 2019-07-22
Author: chenrich@us.ibm.com
File Name: qiskit/aqua/operators/common.py
Class Name:
Method Name: measure_pauli_z
Project Name: SheffieldML/GPy
Commit Name: f35578804a2dcbc9066d48a103bcaf4ed1d0fd5d
Time: 2013-04-23
Author: james.hensman@gmail.com
File Name: GPy/kern/coregionalise.py
Class Name: coregionalise
Method Name: dK_dtheta
Project Name: craffel/mir_eval
Commit Name: 98d8f98800a76e6809c5ac43245bfe685a5cf436
Time: 2014-04-17
Author: brm2132@columbia.edu
File Name: mir_eval/structure.py
Class Name:
Method Name: pairwise