Skip to content

Commit

Permalink
Fix measurement error message (#334)
Browse files Browse the repository at this point in the history
* Fix measurement error message

* Reformat

* Add Changelog
  • Loading branch information
chaeyeunpark authored Aug 22, 2022
1 parent c15fa0d commit 1e43ace
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@

### Bug fixes

* Test updates to reflect new measurement error messages.
[(#334)](https://github.com/PennyLaneAI/pennylane-lightning/pull/334)

### Contributors

This release contains contributions from (in alphabetical order):

Amintor Dusko
Amintor Dusko, Chae-Yeun Park

---

Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.26.0-dev1"
__version__ = "0.26.0-dev2"
14 changes: 7 additions & 7 deletions tests/test_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ def test_not_an_observable(self, dev):
@qml.qnode(dev)
def circuit():
qml.RX(0.52, wires=0)
return qml.expval(qml.CNOT(wires=[0, 1]))
return qml.expval(qml.RX(0.742, wires=[0]))

with pytest.raises(qml.QuantumFunctionError, match="CNOT is not an observable"):
with pytest.raises(qml._device.DeviceError, match="Observable RX not supported"):
circuit()

def test_observable_return_type_is_expectation(self, dev):
Expand Down Expand Up @@ -348,10 +348,10 @@ def test_not_an_observable(self, dev):
@qml.qnode(dev)
def circuit():
qml.RX(0.52, wires=0)
return qml.var(qml.CNOT(wires=[0, 1]))
return qml.var(qml.RX(0.742, wires=[0]))

with pytest.raises(qml.QuantumFunctionError, match="CNOT is not an observable"):
res = circuit()
with pytest.raises(qml._device.DeviceError, match="Observable RX not supported"):
circuit()

def test_observable_return_type_is_variance(self, dev):
"""Test that the return type of the observable is :attr:`ObservableReturnTypes.Variance`"""
Expand All @@ -377,9 +377,9 @@ def test_not_an_observable(self, stat_func):
@qml.qnode(dev)
def circuit():
qml.RX(0.52, wires=0)
return stat_func(qml.CNOT(wires=[0, 1]))
return qml.var(qml.RX(0.742, wires=[0]))

with pytest.raises(qml.QuantumFunctionError, match="CNOT is not an observable"):
with pytest.raises(qml._device.DeviceError, match="Observable RX not supported"):
circuit()


Expand Down

0 comments on commit 1e43ace

Please sign in to comment.