From 48c8f5f74b471f6f901c3a705779ea026050b8b7 Mon Sep 17 00:00:00 2001 From: Liam Hurwitz Date: Thu, 19 Dec 2024 17:11:13 +0100 Subject: [PATCH] Fix mypy error by creating a new variable. Add Measurement import --- pyzx/circuit/qasmparser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyzx/circuit/qasmparser.py b/pyzx/circuit/qasmparser.py index 25f2fa44..2f9ca90a 100644 --- a/pyzx/circuit/qasmparser.py +++ b/pyzx/circuit/qasmparser.py @@ -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 @@ -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"):