Skip to content

Commit

Permalink
Clean up SparseSimulator imports in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
losos0 committed Mar 22, 2024
1 parent cdb03c9 commit b4567ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
5 changes: 2 additions & 3 deletions unitary/alpha/quantum_effect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
import cirq

import unitary.alpha as alpha
from unitary.alpha.sparse_vector_simulator import SparseSimulator

Q0 = cirq.NamedQubit("q0")
Q1 = cirq.NamedQubit("q1")


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_quantum_if(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("q0", 1)
Expand All @@ -46,7 +45,7 @@ def test_quantum_if(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_anti_control(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("q0", 0)
Expand Down
5 changes: 2 additions & 3 deletions unitary/alpha/quantum_object_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
import cirq

import unitary.alpha as alpha
from unitary.alpha.sparse_vector_simulator import SparseSimulator


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_negation(simulator, compile_to_qubits):
piece = alpha.QuantumObject("t", 0)
board = alpha.QuantumWorld(
Expand All @@ -38,7 +37,7 @@ def test_negation(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_add_world_after_state_change(simulator, compile_to_qubits):
piece = alpha.QuantumObject("t", 0)
piece += 1
Expand Down
25 changes: 12 additions & 13 deletions unitary/alpha/qubit_effects_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
import cirq

import unitary.alpha as alpha
from unitary.alpha.sparse_vector_simulator import SparseSimulator


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_flip(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("t", 0)
Expand All @@ -33,7 +32,7 @@ def test_flip(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_partial_flip(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("t", 0)
Expand All @@ -44,7 +43,7 @@ def test_partial_flip(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_partial_flip_multiple(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("t", 0)
Expand All @@ -56,7 +55,7 @@ def test_partial_flip_multiple(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_phase(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("t", 0)
Expand All @@ -67,7 +66,7 @@ def test_phase(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_partial_phase(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("t", 0)
Expand All @@ -78,7 +77,7 @@ def test_partial_phase(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_superposition(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece = alpha.QuantumObject("t", 0)
Expand All @@ -89,7 +88,7 @@ def test_superposition(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_move(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece1 = alpha.QuantumObject("a", 1)
Expand All @@ -110,7 +109,7 @@ def test_move(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_partial_move(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece1 = alpha.QuantumObject("a", 1)
Expand All @@ -133,7 +132,7 @@ def test_partial_move(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_phased_move(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece1 = alpha.QuantumObject("a", 1)
Expand All @@ -154,7 +153,7 @@ def test_phased_move(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_partial_phased_move(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece1 = alpha.QuantumObject("a", 1)
Expand All @@ -177,7 +176,7 @@ def test_partial_phased_move(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_split(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece1 = alpha.QuantumObject("a", 1)
Expand All @@ -199,7 +198,7 @@ def test_split(simulator, compile_to_qubits):


@pytest.mark.parametrize("compile_to_qubits", [False, True])
@pytest.mark.parametrize("simulator", [cirq.Simulator, SparseSimulator])
@pytest.mark.parametrize("simulator", [cirq.Simulator, alpha.SparseSimulator])
def test_phased_split(simulator, compile_to_qubits):
board = alpha.QuantumWorld(sampler=simulator(), compile_to_qubits=compile_to_qubits)
piece1 = alpha.QuantumObject("a", 1)
Expand Down

0 comments on commit b4567ea

Please sign in to comment.