Skip to content

Commit

Permalink
Update noise tests for repeatability
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Howe <[email protected]>
  • Loading branch information
bmhowe23 committed Oct 14, 2024
1 parent 54a3319 commit 8d35bef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions python/tests/builder/test_NoiseModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
@pytest.mark.parametrize('target', ['density-matrix-cpu', 'stim'])
def test_depolarization_channel(target: str):
"""Tests the depolarization channel in the case of a non-zero probability."""
cudaq.set_random_seed(13)
cudaq.set_target(target)
cudaq.set_random_seed(13)
circuit = cudaq.make_kernel()
q = circuit.qalloc()
circuit.x(q)
Expand Down Expand Up @@ -47,8 +47,8 @@ def test_depolarization_channel(target: str):
@pytest.mark.parametrize('target', ['density-matrix-cpu', 'stim'])
def test_depolarization_channel_simple(target: str):
"""Tests the depolarization channel in the case of `probability = 1.0`"""
cudaq.set_random_seed(13)
cudaq.set_target(target)
cudaq.set_random_seed(13)
kernel = cudaq.make_kernel()
qubit = kernel.qalloc()
noise = cudaq.NoiseModel()
Expand Down Expand Up @@ -83,8 +83,8 @@ def test_depolarization_channel_simple(target: str):

def test_amplitude_damping_simple():
"""Tests the amplitude damping channel in the case of `probability = 1.0`"""
cudaq.set_random_seed(13)
cudaq.set_target('density-matrix-cpu')
cudaq.set_random_seed(13)
noise = cudaq.NoiseModel()
# Amplitude damping channel with `1.0` probability of the qubit
# decaying to the ground state.
Expand Down Expand Up @@ -119,8 +119,8 @@ def test_amplitude_damping_simple():
@pytest.mark.parametrize('target', ['density-matrix-cpu', 'stim'])
def test_phase_flip_simple(target: str):
"""Tests the phase flip channel in the case of `probability = 1.0`"""
cudaq.set_random_seed(13)
cudaq.set_target(target)
cudaq.set_random_seed(13)
noise = cudaq.NoiseModel()
# Phase flip channel with `1.0` probability of the qubit
# undergoing a phase rotation of 180 degrees (π).
Expand Down Expand Up @@ -159,8 +159,8 @@ def test_bit_flip_simple(target: str):
Tests the bit flip channel with the probability at `0.0` on qubit 0,
and `1.0` on qubit 1.
"""
cudaq.set_random_seed(13)
cudaq.set_target(target)
cudaq.set_random_seed(13)
noise = cudaq.NoiseModel()
# Bit flip channel with `0.0` probability of the qubit flipping 180 degrees.
bit_flip_zero = cudaq.BitFlipChannel(0.0)
Expand Down Expand Up @@ -198,8 +198,8 @@ def test_bit_flip_simple(target: str):

def test_kraus_channel():
"""Tests the Kraus Channel with a series of custom Kraus Operators."""
cudaq.set_random_seed(13)
cudaq.set_target('density-matrix-cpu')
cudaq.set_random_seed(13)
k0 = np.array([[0.05773502691896258, 0.0], [0., -0.05773502691896258]],
dtype=np.complex128)
k1 = np.array([[0., 0.05773502691896258], [0.05773502691896258, 0.]],
Expand Down Expand Up @@ -489,8 +489,8 @@ def noise_cb(qubits, params):


def check_custom_op_noise(noise_model):
cudaq.set_random_seed(13)
cudaq.set_target('density-matrix-cpu')
cudaq.set_random_seed(13)

@cudaq.kernel
def basic():
Expand Down

0 comments on commit 8d35bef

Please sign in to comment.