Skip to content

Commit

Permalink
fix: Optional ctrl for U, add tests (#251)
Browse files Browse the repository at this point in the history
* Makes `ctrl_modifiers` optional for the `U` gate
* Add missing gates to simulation test data
  • Loading branch information
speller26 committed Apr 26, 2024
1 parent 0bf40ca commit 6d38d5c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/braket/default_simulator/gate_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ def __init__(
theta: float,
phi: float,
lambda_: float,
ctrl_modifiers: list[int],
ctrl_modifiers: Sequence[int] = (),
power: float = 1,
):
super().__init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,41 @@
[0.97766824, 0, 0, 0.02233176],
),
([gate_operations.ZZ([0, 1], 0.15)], 2, [0.99718882 - 0.07492971j, 0, 0, 0], [1, 0, 0, 0]),
(
[gate_operations.Hadamard([0]), gate_operations.GPi([0], 0.15)],
1,
[0.69916673 - 0.10566872j, 0.69916673 + 0.10566872j],
[0.5, 0.5],
),
(
[gate_operations.Hadamard([0]), gate_operations.GPi2([0], 0.15)],
1,
[0.42528093 - 0.49438554j, 0.57471907 - 0.49438554j],
[0.42528093, 0.57471907],
),
(
[gate_operations.MS([0, 1], np.pi / 2, -np.pi / 4, 0.3)],
2,
[0.98877108, 0, 0, 0.10566872 - 0.10566872j],
[0.97766824, 0, 0, 0.02233176],
),
(
[gate_operations.Hadamard([0]), gate_operations.PRx([0], 0.15, 0.4)],
1,
[0.6844863 - 0.04880085j, 0.72575165 - 0.04880085j],
[0.47090303, 0.52909697],
),
(
[gate_operations.Hadamard([0]), gate_operations.Hadamard([1]), gate_operations.ECR([0, 1])],
2,
[
0.35355339 + 0.35355339j,
0.35355339 + 0.35355339j,
0.35355339 - 0.35355339j,
0.35355339 - 0.35355339j,
],
[0.25, 0.25, 0.25, 0.25],
),
(
[
gate_operations.PauliX([0]),
Expand All @@ -155,6 +190,18 @@
[0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0],
),
(
[gate_operations.Hadamard([0]), gate_operations.U([0], 0.15, 0.4, 0.7)],
1,
[0.66459511 - 0.03413278j, 0.36864009 + 0.64903989j],
[0.44285171, 0.55714829],
),
(
[gate_operations.Hadamard([0]), gate_operations.GPhase([], 0.15)],
1,
[0.69916673 + 0.10566872j, 0.69916673 + 0.10566872j],
[0.5, 0.5],
),
]

apply_observables_testdata = [
Expand Down

0 comments on commit 6d38d5c

Please sign in to comment.