Skip to content

Commit

Permalink
Fix mypy error by creating a new variable. Add Measurement import
Browse files Browse the repository at this point in the history
  • Loading branch information
contra-bit committed Dec 19, 2024
1 parent e3ebf05 commit 48c8f5f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pyzx/circuit/qasmparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import List, Dict, Tuple, Optional

from . import Circuit
from .gates import Gate, qasm_gate_table
from .gates import Gate, qasm_gate_table, Measurement
from ..utils import settings


Expand Down Expand Up @@ -144,12 +144,12 @@ def parse_command(self, c: str, registers: Dict[str,Tuple[int,int]]) -> List[Gat
if name == "measure":
target, result_bit = args[0].split(' -> ')
# Extract the register name and index separately for both target and result
target_reg, target_idx = target.split('[')
result_reg, result_idx = result_bit.split('[')
_, target_idx = target.split('[')
_, result_idx = result_bit.split('[')
# Remove the trailing ']' and convert to int
target_qbit = int(target_idx[:-1])
result_bit = int(result_idx[:-1])
gate = Measurement(target_qbit, result_bit)
result_register = int(result_idx[:-1])
gate = Measurement(target_qbit, result_register)
gates.append(gate)
return gates
if name in ("opaque", "if"):
Expand Down

0 comments on commit 48c8f5f

Please sign in to comment.