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

Remove tests of deprecated QubitStateVector #196

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 5 additions & 7 deletions tests/test_mixed_simulator_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,18 +445,17 @@ def test_basis_state_not_at_beginning_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.PauliX(0), qml.BasisState(np.array([0]), wires=[0])])

@pytest.mark.parametrize("stateprep", (qml.QubitStateVector, qml.StatePrep))
def test_qubit_state_vector_not_at_beginning_error(self, simulator_device_1_wire, stateprep):
def test_qubit_state_vector_not_at_beginning_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if is not
the first operation."""

simulator_device_1_wire.reset()

with pytest.raises(
qml.DeviceError,
match=f"The operation {stateprep.__name__} is only supported at the beginning of a circuit.",
match=f"The operation StatePrep is only supported at the beginning of a circuit.",
):
simulator_device_1_wire.apply([qml.PauliX(0), stateprep(np.array([0, 1]), wires=[0])])
simulator_device_1_wire.apply([qml.PauliX(0), qml.StatePrep(np.array([0, 1]), wires=[0])])


@pytest.mark.parametrize("shots", [100])
Expand All @@ -475,8 +474,7 @@ def test_basis_state_not_analytic_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.BasisState(np.array([0]), wires=[0])])

@pytest.mark.parametrize("stateprep", (qml.QubitStateVector, qml.StatePrep))
def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire, stateprep):
def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if the device
is not in analytic mode."""

Expand All @@ -486,7 +484,7 @@ def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire, st
qml.DeviceError,
match="The operations StatePrep and QubitStateVector are only supported in analytic mode.",
):
simulator_device_1_wire.apply([stateprep(np.array([0, 1]), wires=[0])])
simulator_device_1_wire.apply([qml.StatePrep(np.array([0, 1]), wires=[0])])


@pytest.mark.parametrize("shots", [None])
Expand Down
2 changes: 0 additions & 2 deletions tests/test_qsim_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def circuit(x, y, z):
"op, params",
[
(qml.StatePrep, np.array([0, 1])),
(qml.QubitStateVector, np.array([0, 1])),
(qml.BasisState, np.array([1])),
],
)
Expand Down Expand Up @@ -108,7 +107,6 @@ def test_adjoint_ops_not_supported(self):
[
"StatePrep",
"BasisState",
"QubitStateVector",
"CRX",
"CRY",
"CRZ",
Expand Down
2 changes: 0 additions & 2 deletions tests/test_qsimh_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def circuit(x, y, z):
"op, params",
[
(qml.StatePrep, np.array([0, 1])),
(qml.QubitStateVector, np.array([0, 1])),
(qml.BasisState, np.array([1])),
],
)
Expand Down Expand Up @@ -98,7 +97,6 @@ def test_adjoint_ops_not_supported(self):
"gate",
[
"StatePrep",
"QubitStateVector",
"BasisState",
"CRX",
"CRY",
Expand Down
12 changes: 5 additions & 7 deletions tests/test_simulator_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,17 @@ def test_basis_state_not_at_beginning_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.PauliX(0), qml.BasisState(np.array([0]), wires=[0])])

@pytest.mark.parametrize("stateprep", (qml.StatePrep, qml.QubitStateVector))
def test_qubit_state_vector_not_at_beginning_error(self, simulator_device_1_wire, stateprep):
def test_qubit_state_vector_not_at_beginning_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if is not
the first operation."""

simulator_device_1_wire.reset()

with pytest.raises(
qml.DeviceError,
match=f"The operation {stateprep.__name__} is only supported at the beginning of a circuit.",
match=f"The operation StatePrep is only supported at the beginning of a circuit.",
):
simulator_device_1_wire.apply([qml.PauliX(0), stateprep(np.array([0, 1]), wires=[0])])
simulator_device_1_wire.apply([qml.PauliX(0), qml.StatePrep(np.array([0, 1]), wires=[0])])


@pytest.mark.parametrize("shots", [1000])
Expand All @@ -501,8 +500,7 @@ def test_basis_state_not_analytic_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.BasisState(np.array([0]), wires=[0])])

@pytest.mark.parametrize("stateprep", (qml.QubitStateVector, qml.StatePrep))
def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire, stateprep):
def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if the device
is not in analytic mode."""

Expand All @@ -512,7 +510,7 @@ def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire, st
qml.DeviceError,
match="The operations StatePrep and QubitStateVector are only supported in analytic mode.",
):
simulator_device_1_wire.apply([stateprep(np.array([0, 1]), wires=[0])])
simulator_device_1_wire.apply([qml.StatePrep(np.array([0, 1]), wires=[0])])


@pytest.mark.parametrize("shots", [None])
Expand Down
Loading