示例#1
0
    def test_expansion(self, n_wires, expected_names, expected_wires):
        """Checks the queue for the default settings."""

        features = list(range(n_wires))

        op = qml.IQPEmbedding(features, wires=range(n_wires))
        tape = op.expand()

        for i, gate in enumerate(tape.operations):
            assert gate.name == expected_names[i]
            assert gate.wires.labels == tuple(expected_wires[i])
示例#2
0
    def test_repeat(self):
        """Checks the queue for repetition of the template."""

        features = list(range(3))

        expected_names = self.QUEUES[2][1] + self.QUEUES[2][1]
        expected_wires = self.QUEUES[2][2] + self.QUEUES[2][2]

        op = qml.IQPEmbedding(features, wires=range(3), n_repeats=2)
        tape = op.expand()

        for i, gate in enumerate(tape.operations):
            assert gate.name == expected_names[i]
            assert gate.wires.labels == tuple(expected_wires[i])
示例#3
0
    def test_custom_pattern(self):
        """Checks the queue for custom pattern for the entanglers."""

        features = list(range(3))
        pattern = [[0, 2], [0, 1]]
        expected_names = [
            "Hadamard",
            "RZ",
            "Hadamard",
            "RZ",
            "Hadamard",
            "RZ",
            "MultiRZ",
            "MultiRZ",
            "MultiRZ",
        ]
        expected_wires = [[0], [0], [1], [1], [2], [2], *pattern]

        op = qml.IQPEmbedding(features, wires=range(3), pattern=pattern)
        tape = op.expand()

        for i, gate in enumerate(tape.operations):
            assert gate.name == expected_names[i]
            assert gate.wires.labels == tuple(expected_wires[i])
示例#4
0
 def circuit():
     qml.IQPEmbedding(features, wires=range(3))
     return qml.expval(qml.Identity(0))
示例#5
0
def circuit_template(features):
    qml.IQPEmbedding(features, range(2))
    return qml.expval(qml.PauliZ(0))
示例#6
0
 def test_id(self):
     """Tests that the id attribute can be set."""
     template = qml.IQPEmbedding(np.array([1, 2]), wires=[0, 1], id="a")
     assert template.id == "a"
示例#7
0
 def circuit(f=None):
     qml.IQPEmbedding(features=f, wires=range(3))
     return [qml.expval(qml.PauliZ(w)) for w in range(3)]
示例#8
0
 def circuit2():
     qml.IQPEmbedding(features, wires=["z", "a", "k"])
     return qml.expval(qml.Identity("z"))