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])
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])
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])
def circuit(): qml.IQPEmbedding(features, wires=range(3)) return qml.expval(qml.Identity(0))
def circuit_template(features): qml.IQPEmbedding(features, range(2)) return qml.expval(qml.PauliZ(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"
def circuit(f=None): qml.IQPEmbedding(features=f, wires=range(3)) return [qml.expval(qml.PauliZ(w)) for w in range(3)]
def circuit2(): qml.IQPEmbedding(features, wires=["z", "a", "k"]) return qml.expval(qml.Identity("z"))