Skip to content

Commit

Permalink
Changed to use the split for b_list_shadow (#2137)
Browse files Browse the repository at this point in the history
* Changed to use the split for b_list_shadow

* Used a variable to save matching indexes

* super minor change

* Change one more instance of matchingIndexes

---------

Co-authored-by: Andrea Mari <[email protected]>
  • Loading branch information
bdg221 and andreamari authored Dec 20, 2023
1 parent 3733bec commit 67171e5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions mitiq/shadows/classical_postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,13 @@ def expectation_estimation_shadow(

# loop over the splits of the shadow:
for idxes in group_idxes:
if len(
np.nonzero(np.all(u_lists_shadow[idxes] == target_obs, axis=1))[0]
):
matching_indexes = np.nonzero(
np.all(u_lists_shadow[idxes] == target_obs, axis=1)
)

if len(matching_indexes[0]):
product = (-1) ** np.sum(
b_lists_shadow[
np.nonzero(
np.all(u_lists_shadow[idxes] == target_obs, axis=1)
)
].astype(int),
b_lists_shadow[idxes][matching_indexes].astype(int),
axis=1,
)

Expand Down

0 comments on commit 67171e5

Please sign in to comment.