Skip to content

Commit

Permalink
Replace type | type with Union
Browse files Browse the repository at this point in the history
  • Loading branch information
laurencap committed Oct 27, 2023
1 parent d65f91b commit e90fd53
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions src/braket/experimental/autoqasm/instructions/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# language governing permissions and limitations under the License.


"""Quantum gates, unitary instructions, that apply to qubits.
"""
"""Quantum gates, unitary instructions, that apply to qubits."""

from typing import Union

from braket.circuits.free_parameter_expression import FreeParameterExpression

Expand Down Expand Up @@ -54,14 +55,14 @@ def cnot(
def cphaseshift(
control: QubitIdentifierType,
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Controlled phase shift gate.
Args:
control (QubitIdentifierType): Control qubit.
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("cphaseshift", [control, target], angle)
Expand All @@ -70,14 +71,14 @@ def cphaseshift(
def cphaseshift00(
control: QubitIdentifierType,
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Controlled phase shift gate for phasing the \\|00> state.
Args:
control (QubitIdentifierType): Control qubit.
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("cphaseshift00", [control, target], angle)
Expand All @@ -86,14 +87,14 @@ def cphaseshift00(
def cphaseshift01(
control: QubitIdentifierType,
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Controlled phase shift gate for phasing the \\|01> state.
Args:
control (QubitIdentifierType): Control qubit.
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("cphaseshift01", [control, target], angle)
Expand All @@ -102,14 +103,14 @@ def cphaseshift01(
def cphaseshift10(
control: QubitIdentifierType,
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Controlled phase shift gate for phasing the \\|10> state.
Args:
control (QubitIdentifierType): Control qubit.
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("cphaseshift10", [control, target], angle)
Expand Down Expand Up @@ -189,27 +190,27 @@ def ecr(

def gpi(
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""IonQ GPi gate.
Args:
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("gpi", [target], angle)


def gpi2(
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""IonQ GPi2 gate.
Args:
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("gpi2", [target], angle)
Expand Down Expand Up @@ -256,32 +257,32 @@ def iswap(
def ms(
target_0: QubitIdentifierType,
target_1: QubitIdentifierType,
angle_0: float | FreeParameterExpression,
angle_1: float | FreeParameterExpression,
angle_2: float | FreeParameterExpression,
angle_0: Union[float, FreeParameterExpression],
angle_1: Union[float, FreeParameterExpression],
angle_2: Union[float, FreeParameterExpression],
) -> None:
"""IonQ Mølmer-Sørenson gate.
Args:
target_0 (QubitIdentifierType): Target qubit 0.
target_1 (QubitIdentifierType): Target qubit 1.
angle_0 (float | FreeParameterExpression): Rotation angle 0 in radians.
angle_1 (float | FreeParameterExpression): Rotation angle 1 in radians.
angle_2 (float | FreeParameterExpression): Rotation angle 2 in radians.
angle_0 (Union[float, FreeParameterExpression]): Rotation angle 0 in radians.
angle_1 (Union[float, FreeParameterExpression]): Rotation angle 1 in radians.
angle_2 (Union[float, FreeParameterExpression]): Rotation angle 2 in radians.
"""
_qubit_instruction("ms", [target_0, target_1], angle_0, angle_1, angle_2)


def phaseshift(
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Phase shift gate.
Args:
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("phaseshift", [target], angle)
Expand All @@ -290,56 +291,56 @@ def phaseshift(
def pswap(
target_0: QubitIdentifierType,
target_1: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""PSwap gate.
Args:
target_0 (QubitIdentifierType): Target qubit 0.
target_1 (QubitIdentifierType): Target qubit 1.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("pswap", [target_0, target_1], angle)


def rx(
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""X-axis rotation gate.
Args:
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("rx", [target], angle)


def ry(
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Y-axis rotation gate.
Args:
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("ry", [target], angle)


def rz(
target: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Z-axis rotation gate.
Args:
target (QubitIdentifierType): Target qubit.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("rz", [target], angle)
Expand Down Expand Up @@ -446,14 +447,14 @@ def x(
def xx(
target_0: QubitIdentifierType,
target_1: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Ising XX coupling gate.
Args:
target_0 (QubitIdentifierType): Target qubit 0.
target_1 (QubitIdentifierType): Target qubit 1.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("xx", [target_0, target_1], angle)
Expand All @@ -462,14 +463,14 @@ def xx(
def xy(
target_0: QubitIdentifierType,
target_1: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""XY gates
Args:
target_0 (QubitIdentifierType): Target qubit 0.
target_1 (QubitIdentifierType): Target qubit 1.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("xy", [target_0, target_1], angle)
Expand All @@ -490,14 +491,14 @@ def y(
def yy(
target_0: QubitIdentifierType,
target_1: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Ising YY coupling gate.
Args:
target_0 (QubitIdentifierType): Target qubit 0.
target_1 (QubitIdentifierType): Target qubit 1.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("yy", [target_0, target_1], angle)
Expand All @@ -518,14 +519,14 @@ def z(
def zz(
target_0: QubitIdentifierType,
target_1: QubitIdentifierType,
angle: float | FreeParameterExpression,
angle: Union[float, FreeParameterExpression],
) -> None:
"""Ising ZZ coupling gate.
Args:
target_0 (QubitIdentifierType): Target qubit 0.
target_1 (QubitIdentifierType): Target qubit 1.
angle (float | FreeParameterExpression): Rotation angle in radians.
angle (Union[float, FreeParameterExpression]): Rotation angle in radians.
"""
_qubit_instruction("zz", [target_0, target_1], angle)

0 comments on commit e90fd53

Please sign in to comment.