diff --git a/CHANGELOG.md b/CHANGELOG.md index a2e17857..a7317c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ This project adheres to [Semantic Versioning](http://semver.org/). * **Removed** for now removed features. +## [0.4.0] - [ xxxx-yy-zz ] + +### Fixed + +- Bug in the writing of SWAP instructions + + ## [ 0.3.0 ] - [ 2025-01-30 ] ### Added diff --git a/opensquirrel/writer/writer.py b/opensquirrel/writer/writer.py index 98cd38a8..e6822ba8 100644 --- a/opensquirrel/writer/writer.py +++ b/opensquirrel/writer/writer.py @@ -66,7 +66,7 @@ def visit_gate(self, gate: Gate) -> None: gate_generator = [] if gate.generator is not None: gate_generator = list(inspect.signature(gate.generator).parameters.keys()) - qubit_function_keys = ["target", "control", "qubit"] + qubit_function_keys = ["target", "control", "qubit", "qubit0", "qubit1"] if gate.is_anonymous: if "MatrixGate" in gate_name: # In the case of a MatrixGate the newlines should be removed from the array diff --git a/test/writer/test_writer.py b/test/writer/test_writer.py index c6368984..cf4cfbac 100644 --- a/test/writer/test_writer.py +++ b/test/writer/test_writer.py @@ -86,6 +86,22 @@ def test_measure() -> None: ) +def test_swap() -> None: + builder = CircuitBuilder(2, 2) + builder.SWAP(0, 1) + circuit = builder.to_circuit() + assert ( + writer.circuit_to_string(circuit) + == """version 3.0 + +qubit[2] q +bit[2] b + +SWAP q[0], q[1] +""" + ) + + def test_anonymous_gate() -> None: builder = CircuitBuilder(2, 2) builder.H(0)