diff --git a/demonstrations_v2/tutorial_qft/demo.py b/demonstrations_v2/tutorial_qft/demo.py index 550a5fd14c..614fd472a2 100644 --- a/demonstrations_v2/tutorial_qft/demo.py +++ b/demonstrations_v2/tutorial_qft/demo.py @@ -33,7 +33,7 @@ """ from scipy.linalg import dft -import pennylane as qml +import pennylane as qp import numpy as np n = 2 @@ -41,7 +41,7 @@ print("DFT matrix for n = 2:\n") print(np.round(1 / np.sqrt(2 ** n) * dft(2 ** n), 2)) -qft_inverse = qml.adjoint(qml.QFT([0,1])) +qft_inverse = qp.adjoint(qp.QFT([0,1])) print("\n inverse QFT matrix for n = 2:\n") print(np.round(qft_inverse.matrix(), 2)) @@ -90,19 +90,19 @@ # In PennyLane, we rearrange the qubits in the opposite ordering; that is why we # apply SWAP gates at the end. Let's see how the decomposition looks like using the drawer: -import pennylane as qml +import pennylane as qp from functools import partial import matplotlib.pyplot as plt plt.style.use('pennylane.drawer.plot') # This line is to expand the circuit to see the operators -@partial(qml.transforms.decompose, max_expansion=1) +@partial(qp.transforms.decompose, max_expansion=1) def circuit(): - qml.QFT(wires=range(4)) + qp.QFT(wires=range(4)) -qml.draw_mpl(circuit, decimals = 2, style = "pennylane")() +qp.draw_mpl(circuit, decimals = 2, style = "pennylane")() plt.show() ############################################# @@ -123,18 +123,18 @@ def circuit(): def prep(): - """quntum function that prepares the state.""" - qml.PauliX(wires=0) + """quantum function that prepares the state.""" + qp.PauliX(wires=0) for wire in range(1, 6): - qml.Hadamard(wires=wire) - qml.ControlledSequence(qml.PhaseShift(-2 * np.pi / 10, wires=0), control=range(1, 6)) - qml.PauliX(wires=0) + qp.Hadamard(wires=wire) + qp.ControlledSequence(qp.PhaseShift(-2 * np.pi / 10, wires=0), control=range(1, 6)) + qp.PauliX(wires=0) -dev = qml.device("default.qubit") -@qml.qnode(dev) +dev = qp.device("default.qubit") +@qp.qnode(dev) def circuit(): prep() - return qml.state() + return qp.state() state = circuit().real[:32] @@ -149,12 +149,12 @@ def circuit(): # which is able to transform the state into the frequency domain. This is shown in the code below: # -@qml.qnode(dev) +@qp.qnode(dev) def circuit(): prep() - qml.QFT(wires=range(1, 6)) + qp.QFT(wires=range(1, 6)) - return qml.probs(wires=range(1, 6)) + return qp.probs(wires=range(1, 6)) state = circuit()[:32] diff --git a/demonstrations_v2/tutorial_qft/metadata.json b/demonstrations_v2/tutorial_qft/metadata.json index e7d0474270..e8736d9c68 100644 --- a/demonstrations_v2/tutorial_qft/metadata.json +++ b/demonstrations_v2/tutorial_qft/metadata.json @@ -8,7 +8,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2024-04-16T00:00:00+00:00", - "dateOfLastModification": "2025-12-19T00:00:00+00:00", + "dateOfLastModification": "2026-04-06T00:00:00+00:00", "categories": [ "Algorithms", "Quantum Computing"