Skip to content

Commit

Permalink
Store q_id and not qubit in _clbit2id
Browse files Browse the repository at this point in the history
  • Loading branch information
jond01 committed Nov 1, 2021
1 parent 74f561b commit 94ad6b5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions quantum-viz/quantum_viz/qiskit_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(
}
self.qubit2id: Dict[Qubit, int] = dict()
self._init_qubits()
self._clbit2id: Dict[Clbit, (Qubit, int)] = dict()
self._clbit2id: Dict[Clbit, (int, int)] = dict()
self._update_qviz_dict()

def _init_qubits(self) -> None:
Expand Down Expand Up @@ -169,8 +169,7 @@ def _get_clbit_def(
self, clbit: Clbit, qubit: Optional[Qubit] = None
) -> Dict[str, int]:
if clbit in self._clbit2id:
qubit, c_id = self._clbit2id[clbit]
q_id = self.qubit2id[qubit]
q_id, c_id = self._clbit2id[clbit]
else:
if qubit is None:
raise NotImplementedError(
Expand All @@ -180,7 +179,7 @@ def _get_clbit_def(
q_id = self.qubit2id[qubit]
c_id = self.qubits[q_id].get("numChildren", 0)
self.qubits[q_id]["numChildren"] = c_id + 1
self._clbit2id[clbit] = (qubit, c_id)
self._clbit2id[clbit] = (q_id, c_id)
return {"type": RegisterType.CLASSICAL.value, "qId": q_id, "cId": c_id}

def _update_qviz_dict(self) -> None:
Expand Down

0 comments on commit 94ad6b5

Please sign in to comment.