From 170919a41bca2e97c3c865e4018ca096a06bf3d4 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 25 Jul 2024 13:54:57 -0400 Subject: [PATCH] fix docstrings --- pennylane/registers.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pennylane/registers.py b/pennylane/registers.py index 92481b4ef13..03a9114ddcf 100644 --- a/pennylane/registers.py +++ b/pennylane/registers.py @@ -37,11 +37,22 @@ def registers(register_dict): **Example** - >>> wire_registers = qml.registers({"alice": 1, "bob": {"nest1": 2, "nest2": 1}}) + Given input ``{"ancilla": {"sub_ancilla": 2, "sub_ancilla1": 1}}``, ``qml.registers()`` creates + a dictionary with 3 key-value pairs. The keys are the register names found in the input: + "ancilla", "sub_ancilla" and "sub_ancilla1". The values are the respective :class:`~.Wires` + objects for each register. For example, "ancilla" has two sub registers "sub_ancilla" and + "sub_ancilla1". Therefore, the value associated with key "ancilla" is the union of the + :class:`~.Wires` of its sub registers. Since its sub registers "sub_ancilla" and "sub_ancilla1" + have :class:`~.Wires` objects ``Wires([0, 1])`` and ``Wires([2])`` respectively, the key "ancilla" + has the value ``Wires([0, 1, 2])``. + + >>> wire_registers = qml.registers({"ancilla": {"sub_ancilla": 2, "sub_ancilla1": 1}}) >>> wire_dict - {'alice': Wires([0]), 'nest1': Wires([1, 2]), 'nest2': Wires([3]), 'bob': Wires([1, 2, 3])} - >>> wire_dict['nest1'] - Wires([1, 2]) + {'sub_ancilla': Wires([0, 1]), 'sub_ancilla1': Wires([2]), 'ancilla': Wires([0, 1, 2])} + >>> wire_dict['sub_ancilla1'] + Wires([2]) + >>> wire_dict['sub_ancilla'][1] + 1 A simple example showcasing how to implement the `SWAP `_ test: