Skip to content

Commit

Permalink
recover indexed_cbits and squeezed_cbits
Browse files Browse the repository at this point in the history
  • Loading branch information
chensgit169 authored Aug 16, 2023
1 parent b462bcc commit 45eee21
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/quafu/results/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ def __init__(self, input_dict):
self.measures = self.transpiled_circuit.measures
self.task_status = status_map[input_dict["status"]]
self.res = eval(input_dict['res'])

self.counts = OrderedDict(sorted(self.res.items(), key=lambda s: s[0]))

self.logicalq_res = {}
for bit_str, count in self.counts.items():
newkey = "".join([bit_str[i] for i in self.measures.values()])
self.logicalq_res[newkey] = count
cbits = list(self.measures.values())
indexed_cbits = {bit: i for i, bit in enumerate(sorted(cbits))}
squeezed_cbits = [indexed_cbits[bit] for bit in cbits]
for key, values in self.counts.items():
newkey = "".join([key[i] for i in squeezed_cbits])
self.logicalq_res[newkey] = values

total_counts = sum(self.counts.values())
self.probabilities = {}
Expand Down

0 comments on commit 45eee21

Please sign in to comment.