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

Fix seeds for more tests #6460

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions tests/templates/test_subroutines/test_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ def test_lightning_qubit(self):

@pytest.mark.autograd
@pytest.mark.parametrize("shots", [None, 50000])
def test_qnode_autograd(self, shots):
def test_qnode_autograd(self, shots, seed):
"""Test that the QNode executes with Autograd."""

dev = qml.device("default.qubit", shots=shots, wires=3)
dev = qml.device("default.qubit", shots=shots, wires=3, seed=seed)
diff_method = "backprop" if shots is None else "parameter-shift"
qnode = qml.QNode(self.circuit, dev, interface="autograd", diff_method=diff_method)

Expand Down
8 changes: 4 additions & 4 deletions tests/transforms/test_diagonalize_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,12 @@ def test_bad_to_eigvals_input_raises_error(self, supported_base_obs):
@pytest.mark.parametrize("to_eigvals", [True, False])
@pytest.mark.parametrize("supported_base_obs", ([qml.Z], [qml.Z, qml.X], [qml.Z, qml.X, qml.Y]))
@pytest.mark.parametrize("shots", [None, 2000, (4000, 5000, 6000)])
def test_qnode_integration(self, to_eigvals, supported_base_obs, shots):
def test_qnode_integration(self, to_eigvals, supported_base_obs, shots, seed):

if to_eigvals and supported_base_obs != [qml.Z]:
pytest.skip("to_eigvals is not supported when not diagonalizing all gates")

dev = qml.device("default.qubit", shots=shots)
dev = qml.device("default.qubit", shots=shots, seed=seed)

@qml.qnode(dev)
def circuit():
Expand All @@ -650,6 +650,6 @@ def circuit_diagonalized():

if len(dev.shots.shot_vector) > 1:
for r_diagonalized, r in zip(res, expected_res):
assert np.allclose(r_diagonalized, r, atol=0.1)
assert np.allclose(r_diagonalized, r, rtol=0.1)
else:
assert np.allclose(expected_res, res, atol=0.1)
assert np.allclose(expected_res, res, rtol=0.1)
Loading