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

Removed old return type #331

Merged
merged 6 commits into from
Aug 30, 2023
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

### Breaking changes 💔

* The old return type system has been removed.
[(#331)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/331)

### Deprecations 👋

### Documentation 📝
Expand All @@ -16,6 +19,8 @@

This release contains contributions from (in alphabetical order):

Mudit Pandey,

---
# Release 0.32.0

Expand Down
14 changes: 4 additions & 10 deletions pennylane_qiskit/qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import warnings

import numpy as np
import pennylane
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit import extensions as ex
from qiskit.compiler import transpile
Expand Down Expand Up @@ -499,15 +498,10 @@ def batch_execute(self, circuits, timeout: int = None):
if self.shots is not None or circuit.is_sampled:
self._samples = self.generate_samples(circuit_obj)

if not pennylane.active_return():
res = self._statistics_legacy(circuit)
res = np.asarray(res)
results.append(res)
else:
res = self.statistics(circuit)
single_measurement = len(circuit.measurements) == 1
res = res[0] if single_measurement else tuple(res)
results.append(res)
res = self.statistics(circuit)
single_measurement = len(circuit.measurements) == 1
res = res[0] if single_measurement else tuple(res)
results.append(res)

if self.tracker.active:
self.tracker.update(batches=1, batch_len=len(circuits))
Expand Down
25 changes: 0 additions & 25 deletions tests/test_qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,6 @@ def test_calls_to_reset(self, n_tapes, mocker, device):

assert spy.call_count == n_tapes

def test_result_legacy(self, device, tol):
"""Tests that the result has the correct shape and entry types."""
# TODO: remove once the legacy return system is removed.
qml.disable_return()
dev = device(2)
tapes = [self.tape1, self.tape2]
res = dev.batch_execute(tapes)

# We're calling device methods directly, need to reset before the next
# execution
dev.reset()
tape1_expected = dev.execute(self.tape1)

dev.reset()
tape2_expected = dev.execute(self.tape2)

assert len(res) == 2
assert isinstance(res[0], np.ndarray)
assert np.allclose(res[0], tape1_expected, atol=0)

assert isinstance(res[1], np.ndarray)
assert np.allclose(res[1], tape2_expected, atol=0)

qml.enable_return()

def test_result(self, device, tol):
"""Tests that the result has the correct shape and entry types."""
dev = device(2)
Expand Down
Loading