Skip to content

Commit

Permalink
Removed old return type (#331)
Browse files Browse the repository at this point in the history
* Removed old return

* Fixed tests; changelog

* Added link to changelog

* Trigger CI

* Codefactor

* Additional changes
  • Loading branch information
mudit2812 authored Aug 30, 2023
1 parent 01a2d43 commit f77adda
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
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

0 comments on commit f77adda

Please sign in to comment.