braket.circuits.angled_gate module
- class braket.circuits.angled_gate.AngledGate(angle: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]
Bases:
Gate
,Parameterizable
Class
AngledGate
represents a quantum gate that operates on N qubits and an angle.Initializes an
AngledGate
.- Parameters:
angle (Union[FreeParameterExpression, float]) – The angle of the gate in radians or expression representation.
qubit_count (Optional[int]) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises:
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
isNone
- property parameters: list[FreeParameterExpression | float]
Returns the parameters associated with the object, either unbound free parameters or bound values.
- Returns:
list[Union[FreeParameterExpression, float]] – The free parameters or fixed value associated with the object.
- property angle: FreeParameterExpression | float
Returns the angle of the gate
- Returns:
Union[FreeParameterExpression, float] – The angle of the gate in radians
- bind_values(**kwargs) AngledGate [source]
Takes in parameters and attempts to assign them to values.
- Returns:
AngledGate – A new Gate of the same type with the requested parameters bound.
- Raises:
NotImplementedError – Subclasses should implement this function.
- class braket.circuits.angled_gate.DoubleAngledGate(angle_1: FreeParameterExpression | float, angle_2: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]
Bases:
Gate
,Parameterizable
Class
DoubleAngledGate
represents a quantum gate that operates on N qubits and two angles.Inits a
DoubleAngledGate
.- Parameters:
angle_1 (Union[FreeParameterExpression, float]) – The first angle of the gate in radians or expression representation.
angle_2 (Union[FreeParameterExpression, float]) – The second angle of the gate in radians or expression representation.
qubit_count (Optional[int]) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises:
ValueError – If
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle_1
orangle_2
isNone
- property parameters: list[FreeParameterExpression | float]
Returns the parameters associated with the object, either unbound free parameters or bound values.
- Returns:
list[Union[FreeParameterExpression, float]] – The free parameters or fixed value associated with the object.
- property angle_1: FreeParameterExpression | float
Returns the first angle of the gate
- Returns:
Union[FreeParameterExpression, float] – The first angle of the gate in radians
- property angle_2: FreeParameterExpression | float
Returns the second angle of the gate
- Returns:
Union[FreeParameterExpression, float] – The second angle of the gate in radians
- bind_values(**kwargs: FreeParameterExpression | str) AngledGate [source]
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (FreeParameterExpression | str) – The parameters that are being assigned.
- Returns:
AngledGate – A new Gate of the same type with the requested parameters bound.
- Raises:
NotImplementedError – Subclasses should implement this function.
- class braket.circuits.angled_gate.TripleAngledGate(angle_1: FreeParameterExpression | float, angle_2: FreeParameterExpression | float, angle_3: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]
Bases:
Gate
,Parameterizable
Class
TripleAngledGate
represents a quantum gate that operates on N qubits and three angles.Inits a
TripleAngledGate
.- Parameters:
angle_1 (Union[FreeParameterExpression, float]) – The first angle of the gate in radians or expression representation.
angle_2 (Union[FreeParameterExpression, float]) – The second angle of the gate in radians or expression representation.
angle_3 (Union[FreeParameterExpression, float]) – The third angle of the gate in radians or expression representation.
qubit_count (Optional[int]) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises:
ValueError – If
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle_1
orangle_2
orangle_3
isNone
- property parameters: list[FreeParameterExpression | float]
Returns the parameters associated with the object, either unbound free parameters or bound values.
- Returns:
list[Union[FreeParameterExpression, float]] – The free parameters or fixed value associated with the object.
- property angle_1: FreeParameterExpression | float
Returns the first angle of the gate
- Returns:
Union[FreeParameterExpression, float] – The first angle of the gate in radians
- property angle_2: FreeParameterExpression | float
Returns the second angle of the gate
- Returns:
Union[FreeParameterExpression, float] – The second angle of the gate in radians
- property angle_3: FreeParameterExpression | float
Returns the third angle of the gate
- Returns:
Union[FreeParameterExpression, float] – The third angle of the gate in radians
- bind_values(**kwargs: FreeParameterExpression | str) AngledGate [source]
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (FreeParameterExpression | str) – The parameters that are being assigned.
- Returns:
AngledGate – A new Gate of the same type with the requested parameters bound.
- Raises:
NotImplementedError – Subclasses should implement this function.
- braket.circuits.angled_gate.angled_ascii_characters(gate: str, angle: FreeParameterExpression | float) str [source]
Generates a formatted ascii representation of an angled gate.
- Parameters:
gate (str) – The name of the gate.
angle (Union[FreeParameterExpression, float]) – The angle for the gate.
- Returns:
str – Returns the ascii representation for an angled gate.
- braket.circuits.angled_gate.get_angle(gate: AngledGate, **kwargs: FreeParameterExpression | str) AngledGate [source]
Gets the angle with all values substituted in that are requested.
- Parameters:
gate (AngledGate) – The subclass of AngledGate for which the angle is being obtained.
**kwargs (FreeParameterExpression | str) – The named parameters that are being filled for a particular gate.
- Returns:
AngledGate – A new gate of the type of the AngledGate originally used with all angles updated.