From b00325a8db0b25ca0ffc18af2a7217b618676f82 Mon Sep 17 00:00:00 2001 From: chen_wei <109205133+chensgit169@users.noreply.github.com> Date: Wed, 16 Aug 2023 11:37:18 +0800 Subject: [PATCH] recover indexed_cbits and squeezed_cbits --- src/quafu/results/results.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/quafu/results/results.py b/src/quafu/results/results.py index 844bf4e..483582e 100644 --- a/src/quafu/results/results.py +++ b/src/quafu/results/results.py @@ -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 = {}