diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa374f9a..fb4025b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,15 @@ ### Breaking changes +* Now supports Qiskit version 0.18.0. As a result of breaking changes + within Qiskit, version 0.17 and below are no longer supported. + [(#81)](https://github.com/XanaduAI/pennylane-qiskit/pull/81) + ### Improvements +* Added a test for returning probabilities when using the `IBMQDevice`. + [(#82)](https://github.com/XanaduAI/pennylane-qiskit/pull/82) + ### Documentation * Major redesign of the documentation, making it easier to navigate. @@ -13,14 +20,21 @@ ### Bug fixes -* Renamed `QiskitDevice.probabilities` to `QiskitDevice.probability` to overload `pennylane.Device.probability`. This fixes a bug that raises `NotImplementedError` when a QNode is used to compute probabilities on a IBMQ device. - [(#80)](https://github.com/XanaduAI/pennylane-qiskit/pull/80) +* Added a type conversion of parameters for parametrized gates, and renamed + various gates for Qiskit version 0.18.0 support. + [(#81)](https://github.com/XanaduAI/pennylane-qiskit/pull/81) + +* Renamed `QiskitDevice.probabilities` to `QiskitDevice.probability` to overload + `pennylane.Device.probability`. This fixes a bug that raises `NotImplementedError` + when a QNode is used to compute probabilities on a IBMQ device. + [(#80)](https://github.com/XanaduAI/pennylane-qiskit/pull/80) + ### Contributors This release contains contributions from (in alphabetical order): -Rafael Haenel +Rafael Haenel, Josh Izaac, Maria Schuld, Antal Száva --- diff --git a/tests/test_ibmq.py b/tests/test_ibmq.py index b3b02ffad..1fbed5583 100644 --- a/tests/test_ibmq.py +++ b/tests/test_ibmq.py @@ -140,3 +140,28 @@ def circuit(theta, phi): res = circuit(theta, phi) expected = np.array([np.cos(theta), np.cos(theta) * np.cos(phi)]) assert np.allclose(res, expected, **tol) + + +@pytest.mark.parametrize("analytic", [False]) +@pytest.mark.parametrize("x", [[0.2, 0.5], [0.4, 0.9], [0.8, 0.3]]) +@pytest.mark.parametrize("shots", [1000]) +def test_probability(token, x, tol, shots): + """Test that the probs function works.""" + IBMQ.enable_account(token) + dev = IBMQDevice(wires=2, backend="ibmq_qasm_simulator", shots=shots) + dev_analytic = qml.device("default.qubit", wires=2, analytic=True) + + def circuit(x): + qml.RX(x[0], wires=0) + qml.RY(x[1], wires=0) + qml.CNOT(wires=[0, 1]) + return qml.probs(wires=[0, 1]) + + prob = qml.QNode(circuit, dev) + prob_analytic = qml.QNode(circuit, dev_analytic) + + called_prob = prob(x) + + assert np.isclose(called_prob.sum(), 1, **tol) + assert np.allclose(prob_analytic(x), prob(x), **tol) + assert not np.array_equal(prob_analytic(x), prob(x))