Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix to qml.registers docstring #6102

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

* A new function `qml.registers` has been added, enabling the creation of registers, which are implemented as a dictionary of `Wires` instances.
[(#5957)](https://github.com/PennyLaneAI/pennylane/pull/5957)
[(#6102)](https://github.com/PennyLaneAI/pennylane/pull/6102)

* The `split_to_single_terms` transform is added. This transform splits expectation values of sums
into multiple single-term measurements on a single tape, providing better support for simulators
Expand Down
8 changes: 4 additions & 4 deletions pennylane/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ def registers(register_dict):
Given nested input dictionary:

>>> wire_registers = qml.registers({"people": {"alice": 2, "bob": 1}})
>>> wire_dict
>>> wire_registers
{'alice': Wires([0, 1]), 'bob': Wires([2]), 'people': Wires([0, 1, 2])}
>>> wire_dict['bob']
>>> wire_registers['bob']
Wires([2])
>>> wire_dict['alice'][1]
>>> wire_registers['alice'][1]
1

A simple example showcasing how to implement the `SWAP <https://en.wikipedia.org/wiki/Swap_test>`_ test:

.. code-block::

dev = qml.device("default.qubit")
reg = registers({"aux": 1, "phi": 5, "psi": 5})
reg = registers({"aux": 1, "phi": 5, "psi": 5})

@qml.qnode(dev)
def circuit():
Expand Down
Loading