Skip to content

Commit

Permalink
fix lint in clifford test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobSchaeffeler committed Aug 13, 2024
1 parent 1ec68f9 commit 0754a68
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/python/test_cliffordsynthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Configuration:
coupling_map: str | None = None


def permute_qubits(circuit: QuantumCircuit, permutation: tuple[int]) -> QuantumCircuit:
def permute_qubits(circuit: QuantumCircuit, permutation: tuple[int, ...]) -> QuantumCircuit:
"""Return a new circuit with qubits permuted according to the given permutation."""
permuted_circ = QuantumCircuit(circuit.num_qubits)
qubit_map = {qubit: i for i, qubit in enumerate(circuit.qubits)}
Expand All @@ -43,6 +43,15 @@ def permute_qubits(circuit: QuantumCircuit, permutation: tuple[int]) -> QuantumC
return permuted_circ


def convert_coupling_map(cm: str | None = None) -> list[tuple[int, int]] | None:
"""Convert a coupling map passed as a string to a CouplingMap."""
coupling_map = None
if cm is not None:
pairs = cm.split(";")
coupling_map = [(int(pair.strip("{}").split(",")[0]), int(pair.strip("{}").split(",")[1])) for pair in pairs]
return coupling_map


def create_circuit_tests() -> list[Configuration]:
"""Create test cases for Clifford synthesis."""
path = Path(__file__).resolve().parent.parent / "cliffordsynthesis" / "circuits.json"
Expand All @@ -59,13 +68,6 @@ def create_tableau_tests() -> list[Configuration]:
return [Configuration(**t) for t in tableaus]


def convert_coupling_map(cm):
if cm is not None:
pairs = cm.split(";")
cm = [(int(pair.strip("{}").split(",")[0]), int(pair.strip("{}").split(",")[1])) for pair in pairs]
return cm


@pytest.mark.parametrize("test_config", create_circuit_tests())
@pytest.mark.parametrize("use_maxsat", [True, False], ids=["maxsat", "binary_search"])
def test_optimize_clifford_gates(test_config: Configuration, use_maxsat: bool) -> None:
Expand Down

0 comments on commit 0754a68

Please sign in to comment.