Skip to content

Commit

Permalink
Add work_wires property to GroverOperator (#6738)
Browse files Browse the repository at this point in the history
**Context:**

`qml.GroverOperator` now has a `work_wires` property similar to
`MultiControlledX`.

**Benefits:** Nice to have.

**Possible Drawbacks:** None identified.

**Related GitHub Issues:** Fixes #6591 

[sc-78409]

---------

Co-authored-by: Isaac De Vlugt <[email protected]>
  • Loading branch information
andrijapau and isaacdevlugt authored Dec 20, 2024
1 parent 8d33455 commit 7d1b0e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ such as `shots`, `rng` and `prng_key`.

<h4>Other Improvements</h4>

* `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.
[(#6689)](https://github.com/PennyLaneAI/pennylane/pull/6689)

Expand Down
5 changes: 5 additions & 0 deletions pennylane/templates/subroutines/grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def __init__(self, wires: WiresLike, work_wires: WiresLike = (), id=None):

super().__init__(wires=wires, id=id)

@property
def work_wires(self):
"""Additional auxiliary wires that can be used in the decomposition of :class:`~.MultiControlledX`."""
return self.hyperparameters["work_wires"]

@property
def num_params(self):
return 0
Expand Down
6 changes: 6 additions & 0 deletions tests/templates/test_subroutines/test_grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 7d1b0e5

Please sign in to comment.