Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Fixup numerical imprecision #770

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

"""AutoQASM tests for parameter support."""

import numpy as np

import braket.experimental.autoqasm as aq
from braket.circuits import FreeParameter
from braket.default_simulator import StateVectorSimulator
Expand Down Expand Up @@ -51,7 +53,7 @@ def test_simple_parametric():
def test_sim_simple():
measurements = _test_parametric_on_local_sim(simple_parametric(), {"theta": 0})
assert 1 not in measurements["__bit_0__"]
measurements = _test_parametric_on_local_sim(simple_parametric(), {"theta": 3.14})
measurements = _test_parametric_on_local_sim(simple_parametric(), {"theta": np.pi})
assert 0 not in measurements["__bit_0__"]


Expand Down Expand Up @@ -80,9 +82,9 @@ def test_multiple_parameters():


def test_sim_multi_param():
measurements = _test_parametric_on_local_sim(multi_parametric(), {"alpha": 3.14, "theta": 0})
measurements = _test_parametric_on_local_sim(multi_parametric(), {"alpha": np.pi, "theta": 0})
assert all(val == "10" for val in measurements["c"])
measurements = _test_parametric_on_local_sim(multi_parametric(), {"alpha": 0, "theta": 3.14})
measurements = _test_parametric_on_local_sim(multi_parametric(), {"alpha": 0, "theta": np.pi})
assert all(val == "01" for val in measurements["c"])


Expand Down Expand Up @@ -171,7 +173,7 @@ def test_sim_multi_angle():
def parametric(phi: float, theta: float):
ms(0, 1, phi, phi, theta)

_test_parametric_on_local_sim(parametric(FreeParameter("phi"), 0.0), {"phi": 3.14})
_test_parametric_on_local_sim(parametric(FreeParameter("phi"), 0.0), {"phi": np.pi})


def test_parameters_passed_as_main_arg():
Expand Down Expand Up @@ -243,7 +245,7 @@ def parametric():
rx_theta(FreeParameter("theta"))
measure(0)

measurements = _test_parametric_on_local_sim(parametric(), {"theta": 3.14})
measurements = _test_parametric_on_local_sim(parametric(), {"theta": np.pi})
assert 0 not in measurements["__bit_0__"]


Expand Down