Skip to content

Commit

Permalink
Skip slow test.
Browse files Browse the repository at this point in the history
  • Loading branch information
fdmalone committed Jun 29, 2024
1 parent f124e06 commit 132d369
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
markers =
slow: marks tests as slow (deselect with '--skipslow')
34 changes: 16 additions & 18 deletions recirq/qcqmc/blueprint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import cirq
import numpy as np
import pytest
import quaff

from recirq.qcqmc.blueprint import (
BlueprintParamsTrialWf,
Expand Down Expand Up @@ -154,24 +155,19 @@ def test_medium(
assert len(list(blueprint.resolvers)) == 3

resolved_circuits = list(blueprint.resolved_clifford_circuits)
# print(resolved_circuits)
assert len(resolved_circuits) == 3
for circuit_tuple in resolved_circuits:
print(len(circuit_tuple), len(circuit_tuple[0]))
assert len(circuit_tuple) == 8
assert len(circuit_tuple) == 1
for circuit, qubits in zip(circuit_tuple, blueprint_params.qubit_partition):
assert len(circuit.all_qubits()) == len(qubits)
assert set(circuit.all_qubits()) == set(qubits)


@pytest.mark.slow
@pytest.mark.parametrize("seed", range(0, 3, 2))
def test_quaff_respects_seed(seed):
n_cliffords = 500
from quaff import (
TruncatedCliffordGate,
get_parameterized_truncated_cliffords_ops,
get_truncated_cliffords_resolver,
)

rng_1a = np.random.default_rng(seed)
rng_1b = np.random.default_rng(seed)
Expand All @@ -181,53 +177,55 @@ def test_quaff_respects_seed(seed):
qubits = cirq.LineQubit.range(4)
qubit_partition = ((qubits[0], qubits[1]), (qubits[2], qubits[3]))

parameterized_clifford_circuit = cirq.Circuit(
get_parameterized_truncated_cliffords_ops(qubit_partition)
)
cirq.Circuit(quaff.get_parameterized_truncated_cliffords_ops(qubit_partition))

truncated_cliffords_1a = [
[
TruncatedCliffordGate.random(len(qubits), rng_1a)
quaff.TruncatedCliffordGate.random(len(qubits), rng_1a)
for qubits in qubit_partition
]
for _ in range(n_cliffords)
]

truncated_cliffords_1b = [
[
TruncatedCliffordGate.random(len(qubits), rng_1b)
quaff.TruncatedCliffordGate.random(len(qubits), rng_1b)
for qubits in qubit_partition
]
for _ in range(n_cliffords)
]

truncated_cliffords_2a = [
[
TruncatedCliffordGate.random(len(qubits), rng_2a)
quaff.TruncatedCliffordGate.random(len(qubits), rng_2a)
for qubits in qubit_partition
]
for _ in range(n_cliffords)
]

truncated_cliffords_2b = [
[
TruncatedCliffordGate.random(len(qubits), rng_2b)
quaff.TruncatedCliffordGate.random(len(qubits), rng_2b)
for qubits in qubit_partition
]
for _ in range(n_cliffords)
]

resolvers_1a = [
get_truncated_cliffords_resolver(gates) for gates in truncated_cliffords_1a
quaff.get_truncated_cliffords_resolver(gates)
for gates in truncated_cliffords_1a
]
resolvers_1b = [
get_truncated_cliffords_resolver(gates) for gates in truncated_cliffords_1b
quaff.get_truncated_cliffords_resolver(gates)
for gates in truncated_cliffords_1b
]
resolvers_2a = [
get_truncated_cliffords_resolver(gates) for gates in truncated_cliffords_2a
quaff.get_truncated_cliffords_resolver(gates)
for gates in truncated_cliffords_2a
]
resolvers_2b = [
get_truncated_cliffords_resolver(gates) for gates in truncated_cliffords_2b
quaff.get_truncated_cliffords_resolver(gates)
for gates in truncated_cliffords_2b
]

assert resolvers_1a == resolvers_1b
Expand Down
9 changes: 9 additions & 0 deletions recirq/qcqmc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,12 @@ def fixture_8_qubit_ham_and_trial_wf(
)

return fixture_8_qubit_ham, trial_wf


def pytest_addoption(parser):
parser.addoption("--skipslow", action="store_true", help="skips slow tests")


def pytest_runtest_setup(item):
if "slow" in item.keywords and item.config.getvalue("skipslow"):
pytest.skip("skipped because of --skipslow option")

0 comments on commit 132d369

Please sign in to comment.