You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add docstrings to basic gates like CZPowGate, Rx, Ry [Unitary hack] (#1651)
Fixes#1148
This PR adds detailed docstrings to the `Rx` and `Ry` bloqs in
`qualtran.bloqs.basic_gates.rotation`.
The docstrings now explicitly list the registers these gates operate on,
improving clarity for users, as requested in issue #1148.
Specifically, the `Registers:` section has been added to:
- `Rx`
- `Ry`
This follows the existing convention for other gates like `CZPowGate`
and `CHadamard`.
It differs from `XPowGate` by a global phase. Specifically,
571
+
`Rx(angle)` is `XPowGate(exponent=angle/np.pi, global_shift=-0.5)`.
572
+
573
+
Args:
574
+
angle: The angle of rotation in radians. This can be a symbolic expression
575
+
or a float.
576
+
eps: The precision of the rotation. This parameter is primarily for
577
+
bookkeeping and does not directly affect the tensor representation
578
+
of this gate. It becomes relevant when synthesizing rotations
579
+
from a discrete gate set, where a target precision `eps` is required.
580
+
581
+
Registers:
582
+
q: A single QBit register representing the qubit to be rotated.
583
+
584
+
References:
585
+
[Elementary gates for quantum computation](https://arxiv.org/abs/quant-ph/9503016).
586
+
Barenco et al. 1995. Section 4.2 discusses single-qubit rotations.
587
+
588
+
[Quantum Computation and Quantum Information](https://www.cambridge.org/highereducation/books/quantum-computation-and-quantum-information/01E10196D0A682A6AEFFEA52D53BE9AE).
589
+
Nielsen and Chuang. 2010. Chapter 4.2, pp. 174-177.
590
+
"""
591
+
557
592
angle: Union[sympy.Expr, float]
558
593
eps: SymbolicFloat=1e-11
559
594
@@ -583,6 +618,41 @@ def __str__(self):
583
618
584
619
@frozen
585
620
classRy(CirqGateAsBloqBase):
621
+
r"""Rotates a qubit about the Y-axis of the Bloch sphere.
It differs from `YPowGate` by a global phase. Specifically,
635
+
`Ry(angle)` is `YPowGate(exponent=angle/np.pi, global_shift=-0.5)`.
636
+
637
+
Args:
638
+
angle: The angle of rotation in radians. This can be a symbolic expression
639
+
or a float.
640
+
eps: The precision of the rotation. This parameter is primarily for
641
+
bookkeeping and does not directly affect the tensor representation
642
+
of this gate. It becomes relevant when synthesizing rotations
643
+
from a discrete gate set, where a target precision `eps` is required.
644
+
645
+
Registers:
646
+
q: A single QBit register representing the qubit to be rotated.
647
+
648
+
References:
649
+
[Elementary gates for quantum computation](https://arxiv.org/abs/quant-ph/9503016).
650
+
Barenco et al. 1995. Section 4.2 discusses single-qubit rotations.
651
+
652
+
[Quantum Computation and Quantum Information](https://www.cambridge.org/highereducation/books/quantum-computation-and-quantum-information/01E10196D0A682A6AEFFEA52D53BE9AE).
653
+
Nielsen and Chuang. 2010. Chapter 4.2, pp. 174-177.
0 commit comments