From db4f98d2474a002b764340ff128113b8f0c34668 Mon Sep 17 00:00:00 2001 From: Chris Elenbaas Date: Fri, 31 Jan 2025 12:02:09 +0100 Subject: [PATCH 1/5] Fix bug in writer for SWAP instruction. --- opensquirrel/writer/writer.py | 2 +- test/writer/test_writer.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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) From adff86034cdab7fafb4eb043e876c11e80ea6323 Mon Sep 17 00:00:00 2001 From: Chris Elenbaas Date: Fri, 31 Jan 2025 12:10:05 +0100 Subject: [PATCH 2/5] Add CHANGELOG entry. Update OpenSquirrel version number. --- CHANGELOG.md | 8 +++++++- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f26441d9..5e84261d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,13 @@ This project adheres to [Semantic Versioning](http://semver.org/). * **Removed** for now removed features. -## [ 0.3.0 ] - [ xxxx-yy-zz ] +## [0.4.0] - [ xxxx-yy-zz ] + +### Fixed + +- Bug in the writing of SWAP instruction arguments + +## [ 0.3.0 ] - [ 2025-01-30 ] ### Added diff --git a/pyproject.toml b/pyproject.toml index 83a680a3..728c6d7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "opensquirrel" -version = "0.2.0" +version = "0.3.0" description = "A quantum circuit transformation and manipulation tool" authors = [ "Quantum Inspire " From fb22fb86c2458a8aee6d016dc8dcb295d65f6802 Mon Sep 17 00:00:00 2001 From: Chris Elenbaas <67630508+elenbaasc@users.noreply.github.com> Date: Fri, 31 Jan 2025 13:16:20 +0100 Subject: [PATCH 3/5] Update CHANGELOG.md Co-authored-by: Roberto Turrado Camblor --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e84261d..3e46478d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- Bug in the writing of SWAP instruction arguments +- Bug in the writing of SWAP instructions. ## [ 0.3.0 ] - [ 2025-01-30 ] From f5d3b07952f51293b7f024a9f3d63018ded3a398 Mon Sep 17 00:00:00 2001 From: Chris Elenbaas Date: Fri, 31 Jan 2025 13:24:53 +0100 Subject: [PATCH 4/5] Undo version number update (not part of this bugfix). --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 728c6d7a..83a680a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "opensquirrel" -version = "0.3.0" +version = "0.2.0" description = "A quantum circuit transformation and manipulation tool" authors = [ "Quantum Inspire " From 3a6da907d47fca6cd9b65038a355cbf8692c2e89 Mon Sep 17 00:00:00 2001 From: Chris Elenbaas <67630508+elenbaasc@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:26:26 +0100 Subject: [PATCH 5/5] Update CHANGELOG.md Co-authored-by: Roberto Turrado Camblor --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e46478d..aba9e88d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- Bug in the writing of SWAP instructions. +- Bug in the writing of SWAP instructions ## [ 0.3.0 ] - [ 2025-01-30 ]