Skip to content

Commit

Permalink
Plugin bug fix (#580)
Browse files Browse the repository at this point in the history
* fixes

* fixes

* xfails

* xfails

* Update tests/test_qiskit_device.py
  • Loading branch information
austingmhuang authored Aug 29, 2024
1 parent a295ece commit 170fa78
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_invalid_qubit_state_vector(self, op, device):
state = np.array([0, 123.432])
wires = [0, 1]

with pytest.raises(ValueError, match=r"State vector must have shape"):
with pytest.raises(ValueError, match=r"State must be of length 4"):
dev.apply([op(state, wires=wires)])

@pytest.mark.parametrize("mat", [U, U2])
Expand Down
7 changes: 5 additions & 2 deletions tests/test_base_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,9 @@ def test_estimator_with_different_pauli_obs(self, mocker, wire, angle, op, expec
],
)
@flaky(max_runs=10, min_passes=7)
@pytest.mark.xfail(
reason="Qiskit variances is different from PennyLane variances, discussion pending on resolution"
)
def test_estimator_with_various_multi_qubit_pauli_obs(
self, mocker, wire, angle, op, multi_q_obs
):
Expand All @@ -1090,8 +1093,8 @@ def test_estimator_with_various_multi_qubit_pauli_obs(
correspond correctly (wire ordering convention in Qiskit and PennyLane don't match.)
"""

pl_dev = qml.device("default.qubit", wires=[0, 1, 2, 3])
dev = QiskitDevice(wires=[0, 1, 2, 3], backend=aer_backend)
pl_dev = qml.device("default.qubit", wires=4)
dev = QiskitDevice(wires=4, backend=aer_backend)

sampler_execute = mocker.spy(dev, "_execute_sampler")
estimator_execute = mocker.spy(dev, "_execute_estimator")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_load_device(self, d, backend):

dev = qml.device(d[0], wires=2, backend=backend, shots=1024)
assert dev.num_wires == 2
assert dev.shots == 1024
assert dev.shots.total_shots == 1024
assert dev.short_name == d[0]
assert dev.provider == d[1]

Expand Down
10 changes: 4 additions & 6 deletions tests/test_qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def test_warning_raised_for_hardware_backend_analytic_expval(self, recorder):
"device are estimates based on samples."
)

# Two warnings are being raised: one about analytic calculations and another about deprecation.
assert len(record) == 2
# One warning raised about analytic calculations.
assert len(record) == 1

@pytest.mark.parametrize("method", ["unitary", "statevector"])
def test_no_warning_raised_for_software_backend_analytic_expval(
Expand All @@ -194,10 +194,8 @@ def test_no_warning_raised_for_software_backend_analytic_expval(

_ = qml.device("qiskit.aer", backend="aer_simulator", method=method, wires=2, shots=None)

# These simulators are being deprecated. Warning is raised in Qiskit 1.0
# Migrate to AerSimulator with AerSimulator(method=method) and append
# run circuits with the `save_state` instruction.
assert len(recwarn) == 1
# These simulators are being deprecated. Warnings are raised in Qiskit <1.1
assert len(recwarn) == 0


class TestAerBackendOptions:
Expand Down

0 comments on commit 170fa78

Please sign in to comment.