From 96ae086514170f8dec850a4f50718317e540598e Mon Sep 17 00:00:00 2001 From: andrijapau Date: Fri, 20 Dec 2024 16:29:02 -0500 Subject: [PATCH 1/6] feat: Add work_wires property to GroverOperator --- pennylane/templates/subroutines/grover.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pennylane/templates/subroutines/grover.py b/pennylane/templates/subroutines/grover.py index 1d051fd3fe5..a56d757d574 100644 --- a/pennylane/templates/subroutines/grover.py +++ b/pennylane/templates/subroutines/grover.py @@ -123,6 +123,10 @@ def __init__(self, wires: WiresLike, work_wires: WiresLike = (), id=None): super().__init__(wires=wires, id=id) + @property + def work_wires(self): + return self.hyperparameters["work_wires"] + @property def num_params(self): return 0 From 4a55ab800eafbc786cc9b06371a3e5e169be1fd9 Mon Sep 17 00:00:00 2001 From: andrijapau Date: Fri, 20 Dec 2024 16:32:13 -0500 Subject: [PATCH 2/6] fix: Add test for property --- tests/templates/test_subroutines/test_grover.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/templates/test_subroutines/test_grover.py b/tests/templates/test_subroutines/test_grover.py index 4839f9cc613..c7ca2a87d16 100644 --- a/tests/templates/test_subroutines/test_grover.py +++ b/tests/templates/test_subroutines/test_grover.py @@ -31,6 +31,12 @@ def test_repr(): assert repr(op) == expected +def test_work_wire_property(): + op = qml.GroverOperator(wires=(0, 1, 2), work_wires=(3, 4)) + expected = qml.wires.Wires((3, 4)) + assert op.work_wires == expected + + def test_standard_validity(): """Test the standard criteria for a valid operation.""" work_wires = qml.wires.Wires((3, 4)) From 0a4d838997326cc4c230afb000e5be36162241af Mon Sep 17 00:00:00 2001 From: andrijapau Date: Fri, 20 Dec 2024 16:33:24 -0500 Subject: [PATCH 3/6] doc: Update changelog-dev.md --- doc/releases/changelog-dev.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 8df2567e397..72683f88267 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -341,6 +341,9 @@ such as `shots`, `rng` and `prng_key`.

Other Improvements

+* `GroverOperator` now has a `work_wires` property. + [(#6738)](https://github.com/PennyLaneAI/pennylane/pull/6738) + * `Wires` object usage across Pennylane source code has been tidied up. [(#6689)](https://github.com/PennyLaneAI/pennylane/pull/6689) From 64705e8345890343789d1557b386b5af4ef36cf2 Mon Sep 17 00:00:00 2001 From: Andrija Paurevic <46359773+andrijapau@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:56:05 -0500 Subject: [PATCH 4/6] Update doc/releases/changelog-dev.md Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com> --- doc/releases/changelog-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 72683f88267..b2a3d3c32d4 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -341,7 +341,7 @@ such as `shots`, `rng` and `prng_key`.

Other Improvements

-* `GroverOperator` now has a `work_wires` property. +* `qml.GroverOperator` now has a `work_wires` property. [(#6738)](https://github.com/PennyLaneAI/pennylane/pull/6738) * `Wires` object usage across Pennylane source code has been tidied up. From 84515c60c45aa83ca5d47cc05212cce7d0c0f56f Mon Sep 17 00:00:00 2001 From: Andrija Paurevic <46359773+andrijapau@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:56:34 -0500 Subject: [PATCH 5/6] Update pennylane/templates/subroutines/grover.py Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com> --- pennylane/templates/subroutines/grover.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pennylane/templates/subroutines/grover.py b/pennylane/templates/subroutines/grover.py index a56d757d574..759f406883c 100644 --- a/pennylane/templates/subroutines/grover.py +++ b/pennylane/templates/subroutines/grover.py @@ -125,6 +125,7 @@ def __init__(self, wires: WiresLike, work_wires: WiresLike = (), id=None): @property def work_wires(self): + """Additional auxiliary wires that can be used in the decomposition of :class:`~.MultiControlledX`.""" return self.hyperparameters["work_wires"] @property From 0106aaf368cba85395fdfb3f397ab5105534f7f6 Mon Sep 17 00:00:00 2001 From: andrijapau Date: Fri, 20 Dec 2024 16:58:28 -0500 Subject: [PATCH 6/6] doc: Fix work_wires property doc string --- pennylane/templates/subroutines/grover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane/templates/subroutines/grover.py b/pennylane/templates/subroutines/grover.py index 759f406883c..938db918d87 100644 --- a/pennylane/templates/subroutines/grover.py +++ b/pennylane/templates/subroutines/grover.py @@ -125,7 +125,7 @@ def __init__(self, wires: WiresLike, work_wires: WiresLike = (), id=None): @property def work_wires(self): - """Additional auxiliary wires that can be used in the decomposition of :class:`~.MultiControlledX`.""" + """Additional auxiliary wires that can be used in the decomposition of :class:`~.MultiControlledX`.""" return self.hyperparameters["work_wires"] @property