diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 258fb63eebd..a8e3ad54a67 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -237,6 +237,10 @@

Bug fixes

+* Fixes a bug and a test where the ``QuantumTape.is_sampled`` attribute was not + being updated. + [(#1126)](https://github.com/PennyLaneAI/pennylane/pull/1126) + * Fixes a bug where `BasisEmbedding` would not accept inputs whose bits are all ones or all zeros. [(#1114)](https://github.com/PennyLaneAI/pennylane/pull/1114) @@ -261,7 +265,7 @@ This release contains contributions from (in alphabetical order): Thomas Bromley, Olivia Di Matteo, Kyle Godbey, Diego Guala, Josh Izaac, Daniel Polatajko, Chase Roberts, -Sankalp Sanand, Pritish Sehzpaul, Maria Schuld. +Sankalp Sanand, Pritish Sehzpaul, Maria Schuld, Antal Száva. # Release 0.14.1 (current release) diff --git a/pennylane/tape/tapes/tape.py b/pennylane/tape/tapes/tape.py index d6ae2a07592..8799dd08b3b 100644 --- a/pennylane/tape/tapes/tape.py +++ b/pennylane/tape/tapes/tape.py @@ -379,6 +379,8 @@ def _update_circuit_info(self): [op.wires for op in self.operations + self.observables] ) self.num_wires = len(self.wires) + + self.is_sampled = any(m.return_type is Sample for m in self.measurements) self.all_sampled = all(m.return_type is Sample for m in self.measurements) def _update_observables(self): diff --git a/tests/tape/tapes/test_tape.py b/tests/tape/tapes/test_tape.py index 94cf27987a4..2a0dde5b2de 100644 --- a/tests/tape/tapes/test_tape.py +++ b/tests/tape/tapes/test_tape.py @@ -856,9 +856,14 @@ def circuit(): qml.T(wires=0) return sample(qml.PauliZ(0)) - qnode = qml.tape.QNode(circuit, dev) + # Choosing parameter-shift not to swap the device under the hood + qnode = qml.tape.QNode(circuit, dev, diff_method="parameter-shift") qnode() + # Double-checking that the T gate is not supported + assert "T" not in qnode.device.operations + assert "T" not in qnode._original_device.operations + assert qnode.qtape.is_sampled class TestExecution: