Skip to content

Commit 879e4f9

Browse files
committed
mod
1 parent 1bfb296 commit 879e4f9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

glue/cirq/stimcirq/_obs_annotation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def __init__(
3535
if isinstance(k, str):
3636
# For backward compatibility
3737
_pauli_keys.append(k)
38-
_qubits_to_pauli_keys.append((cirq.LineQubit(int(k[1:])), k[0]))
38+
_qubits_to_pauli_keys.append((cirq.LineQubit(int(k[1:])), k))
3939
else:
4040
qubit, basis_and_id = k
4141
_pauli_keys.append(basis_and_id)
42-
_qubits_to_pauli_keys.append((qubit, basis_and_id[0]))
42+
_qubits_to_pauli_keys.append((qubit, basis_and_id))
4343
self._qubits_to_pauli_keys = tuple(_qubits_to_pauli_keys)
4444
self.pauli_keys = frozenset(_pauli_keys)
4545
self.observable_index = observable_index
@@ -147,7 +147,7 @@ def _stim_conversion_(
147147

148148
rec_targets.extend(
149149
[
150-
stim.target_pauli(qubit_index=tid, pauli=qubit_to_basis[q])
150+
stim.target_pauli(qubit_index=tid, pauli=qubit_to_basis[q][0])
151151
for q, tid in zip(self.qubits, targets)
152152
]
153153
)

glue/cirq/stimcirq/_obs_annotation_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ def test_json_backwards_compat_exact():
217217
assert cirq.to_json(raw) == packed_v3
218218

219219
# With pauli_keys
220-
pauli_keys = [(cirq.LineQubit(0), "X"), (cirq.LineQubit(1), "Y"), (cirq.LineQubit(2), "Z")]
220+
pauli_keys = [(cirq.LineQubit(0), "X0"), (cirq.LineQubit(1), "Y1"), (cirq.LineQubit(2), "Z2")]
221221
raw = stimcirq.CumulativeObservableAnnotation(parity_keys=['z'], relative_keys=[-2], observable_index=5, pauli_keys=pauli_keys)
222222
packed_v2 ='{\n "cirq_type": "CumulativeObservableAnnotation",\n "parity_keys": [\n "z"\n ],\n "observable_index": 5,\n "pauli_keys": [\n "X0",\n "Y1",\n "Z2"\n ],\n "relative_keys": [\n -2\n ]\n}'
223-
packed_v3 ='{\n "cirq_type": "CumulativeObservableAnnotation",\n "parity_keys": [\n "z"\n ],\n "observable_index": 5,\n "pauli_keys": [\n [\n {\n "cirq_type": "LineQubit",\n "x": 0\n },\n "X"\n ],\n [\n {\n "cirq_type": "LineQubit",\n "x": 1\n },\n "Y"\n ],\n [\n {\n "cirq_type": "LineQubit",\n "x": 2\n },\n "Z"\n ]\n ],\n "relative_keys": [\n -2\n ]\n}'
223+
packed_v3 ='{\n "cirq_type": "CumulativeObservableAnnotation",\n "parity_keys": [\n "z"\n ],\n "observable_index": 5,\n "pauli_keys": [\n [\n {\n "cirq_type": "LineQubit",\n "x": 0\n },\n "X0"\n ],\n [\n {\n "cirq_type": "LineQubit",\n "x": 1\n },\n "Y1"\n ],\n [\n {\n "cirq_type": "LineQubit",\n "x": 2\n },\n "Z2"\n ]\n ],\n "relative_keys": [\n -2\n ]\n}'
224224

225225
assert cirq.read_json(json_text=packed_v2, resolvers=[*cirq.DEFAULT_RESOLVERS, stimcirq.JSON_RESOLVER]) == raw
226226
assert cirq.read_json(json_text=packed_v3, resolvers=[*cirq.DEFAULT_RESOLVERS, stimcirq.JSON_RESOLVER]) == raw

0 commit comments

Comments
 (0)