From e47af9e21bf6dae8766eaae640cb85f7e22c2c92 Mon Sep 17 00:00:00 2001 From: lishangshu28 Date: Thu, 28 Mar 2024 21:08:46 +0800 Subject: [PATCH 1/2] fix:valid_gates in toopenqasm --- quafu/circuits/quantum_circuit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quafu/circuits/quantum_circuit.py b/quafu/circuits/quantum_circuit.py index 18aed16..cb52f7e 100644 --- a/quafu/circuits/quantum_circuit.py +++ b/quafu/circuits/quantum_circuit.py @@ -489,7 +489,8 @@ def to_openqasm(self) -> str: Returns: openqasm text. """ - valid_gates = QuantumGate.gate_classes #TODO:include instruction futher + valid_gates = list(QuantumGate.gate_classes.keys()) #TODO:include instruction futher + valid_gates.append(["barrier", "delay", "reset"]) qasm = 'OPENQASM 2.0;\ninclude "qelib1.inc";\n' qasm += "qreg q[%d];\n" % self.num qasm += "creg meas[%d];\n" % self.cbits_num From 126c027da498ea460411f6cd2de1140baccdfb55 Mon Sep 17 00:00:00 2001 From: lishangshu28 Date: Thu, 28 Mar 2024 21:11:07 +0800 Subject: [PATCH 2/2] fix:bug --- quafu/circuits/quantum_circuit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quafu/circuits/quantum_circuit.py b/quafu/circuits/quantum_circuit.py index cb52f7e..503f3f3 100644 --- a/quafu/circuits/quantum_circuit.py +++ b/quafu/circuits/quantum_circuit.py @@ -490,7 +490,7 @@ def to_openqasm(self) -> str: openqasm text. """ valid_gates = list(QuantumGate.gate_classes.keys()) #TODO:include instruction futher - valid_gates.append(["barrier", "delay", "reset"]) + valid_gates.extend(["barrier", "delay", "reset"]) qasm = 'OPENQASM 2.0;\ninclude "qelib1.inc";\n' qasm += "qreg q[%d];\n" % self.num qasm += "creg meas[%d];\n" % self.cbits_num