You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In shadows/classical_postprocessing.py the expectation_estimation_shadow code includes a section that uses pauli_twirling_calibration. If the f_val returned however is None, then the value, 0.0, is added to the means List. However, the code will continue to execute and a second (invalid) value, np.sum(product) / len(idxes), is added to the means List. Only a single mean should be added to the means List object per split (each loop of the for loop.)
for idxes in group_idxes:
if len(
np.nonzero(np.all(u_lists_shadow[idxes] == target_obs, axis=1))[0]
):
product = (-1) ** np.sum(
b_lists_shadow[
np.nonzero(
np.all(u_lists_shadow[idxes] == target_obs, axis=1)
)
].astype(int),
axis=1,
)
if pauli_twirling_calibration:
if f_est is None:
raise ValueError(
"estimation of Pauli fidelity must be provided for"
"Pauli twirling calibration."
)
b = create_string(num_qubits, target_locs)
f_val = f_est.get(b, None)
if f_val is None:
means.append(0.0)
else:
# product becomes an array of snapshots expectation values
# witch satisfy condition (1) and (2)
product = (1.0 / f_val) * product
else:
product = 3 ** (len(target_locs)) * product
# append the mean of the product in each split
means.append(np.sum(product) / len(idxes))
else:
means.append(0.0)
The solution would be to add "continue" after "means.append(0.0) to have the code properly move on to the next split.
The text was updated successfully, but these errors were encountered:
In shadows/classical_postprocessing.py the expectation_estimation_shadow code includes a section that uses pauli_twirling_calibration. If the f_val returned however is None, then the value, 0.0, is added to the means List. However, the code will continue to execute and a second (invalid) value, np.sum(product) / len(idxes), is added to the means List. Only a single mean should be added to the means List object per split (each loop of the for loop.)
for idxes in group_idxes:
if len(
np.nonzero(np.all(u_lists_shadow[idxes] == target_obs, axis=1))[0]
):
product = (-1) ** np.sum(
b_lists_shadow[
np.nonzero(
np.all(u_lists_shadow[idxes] == target_obs, axis=1)
)
].astype(int),
axis=1,
)
The solution would be to add "continue" after "means.append(0.0) to have the code properly move on to the next split.
The text was updated successfully, but these errors were encountered: