How to use the pennylane.Rot function in PennyLane

To help you get started, we’ve selected a few PennyLane examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XanaduAI / pennylane / tests / test_tf.py View on Github external
def ansatz(x, y, z):
            qml.QubitStateVector(np.array([1, 0, 1, 1])/np.sqrt(3), wires=[0, 1])
            qml.Rot(x, y, z, wires=0)
            qml.CNOT(wires=[0, 1])
            return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliY(1))
github XanaduAI / pennylane / tests / qnodes / test_qnode_base.py View on Github external
decomposition."""

        class DummyOp(qml.operation.Operation):
            """Dummy operation"""
            num_params = 0
            num_wires = 1
            par_domain = "R"
            grad_method = "A"

            @staticmethod
            def decomposition(wires=None):
                ops = [qml.Hadamard(wires=wires)]
                return ops

        queue = [
            qml.Rot(0, 1, 2, wires=0),
            DummyOp(wires=0),
            qml.RX(6, wires=0)
        ]

        with pytest.raises(qml.DeviceError, match="DummyOp not supported on device"):
            decompose_queue(queue, operable_mock_device_2_wires)
github XanaduAI / pennylane / tests / interfaces / test_interfaces_autograd.py View on Github external
def ansatz(x, y, z):
            qml.QubitStateVector(np.array([1, 0, 1, 1]) / np.sqrt(3), wires=[0, 1])
            qml.Rot(x, y, z, wires=0)
            qml.CNOT(wires=[0, 1])
            return qml.expval(qml.PauliZ(0))
github XanaduAI / pennylane / tests / test_device.py View on Github external
def test_parameters_available_at_pre_measure(self, mock_device, monkeypatch):
        """Tests that the parameter mapping is available when pre_measure is called and that accessing
           Device.parameters raises no error"""

        p0 = 0.54
        p1 = -0.32

        queue = [
            qml.RX(p0, wires=0),
            qml.PauliY(wires=1),
            qml.Rot(0.432, 0.123, p1, wires=2),
        ]

        parameters = {0: (0, 0), 1: (2, 3)}

        observables = [
            qml.expval(qml.PauliZ(0)),
            qml.var(qml.PauliZ(1)),
            qml.sample(qml.PauliZ(2)),
        ]

        p_mapping = {}

        with monkeypatch.context() as m:
            m.setattr(Device, "pre_measure", lambda self: p_mapping.update(self.parameters))
            mock_device.execute(queue, observables, parameters=parameters)
github XanaduAI / pennylane / examples / pennylane_run_variational_quantum_eigensolver.py View on Github external
def ansatz(var):
    qml.Rot(0.3, 1.8, 5.4, wires=1)
    qml.RX(var[0], wires=0)
    qml.RY(var[1], wires=1)
    qml.CNOT(wires=[0, 1])
github XanaduAI / qml / demonstrations / tutorial_multiclass_classification.py View on Github external
def layer(W):
    qml.Rot(W[0, 0], W[0, 1], W[0, 2], wires=0)
    qml.Rot(W[1, 0], W[1, 1], W[1, 2], wires=1)
    qml.CNOT(wires=[0, 1])
github XanaduAI / qml / demonstrations / tutorial_QGAN.py View on Github external
def real(angles, **kwargs):
    qml.Hadamard(wires=0)
    qml.Rot(*angles, wires=0)
github XanaduAI / qml / demonstrations / tutorial_ensemble_multi_qpu.py View on Github external
def circuit0(params, x=None):
    for i in range(n_wires):
        qml.RX(x[i % n_features], wires=i)
        qml.Rot(*params[1, 0, i], wires=i)

    qml.CZ(wires=[1, 0])
    qml.CZ(wires=[1, 2])
    qml.CZ(wires=[3, 0])

    for i in range(n_wires):
        qml.Rot(*params[1, 1, i], wires=i)
    return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1)), qml.expval(qml.PauliZ(2))
github XanaduAI / pennylane / examples / Q3a_variational-classifier-parity.py View on Github external
def layer(W):
    """ Single layer of the variational classifier.

    Args:
        W: array of variables
    """

    qml.Rot(W[0, 0], W[0, 1], W[0, 2], wires=0)
    qml.Rot(W[1, 0], W[1, 1], W[1, 2], wires=1)
    qml.Rot(W[2, 0], W[2, 1], W[2, 2], wires=2)
    qml.Rot(W[3, 0], W[3, 1], W[3, 2], wires=3)

    qml.CNOT(wires=[0, 1])
    qml.CNOT(wires=[1, 2])
    qml.CNOT(wires=[2, 3])
    qml.CNOT(wires=[3, 0])

PennyLane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.

Apache-2.0
Latest version published 20 days ago

Package Health Score

87 / 100
Full package analysis