def test_id(self): """Tests that the id attribute can be set.""" template = qml.QAOAEmbedding(np.array([0]), weights=np.array([[0]]), wires=[0], id="a") assert template.id == "a"
def test_expansion(self, n_wires, weight_shape, expected_names): """Checks the queue for the default settings.""" features = list(range(n_wires)) weights = np.zeros(shape=weight_shape) op = qml.QAOAEmbedding(features, weights, wires=range(n_wires)) tape = op.expand() for i, gate in enumerate(tape.operations): assert gate.name == expected_names[i]
def test_local_field(self, local_field): """Checks that custom local field is used.""" get_name = {"X": "RX", "Y": "RY", "Z": "RZ"} features = list(range(2)) weights = np.zeros(shape=(1, 3)) op = qml.QAOAEmbedding(features, weights, wires=range(2), local_field=local_field) tape = op.expand() gate_names = [gate.name for gate in tape.operations] assert gate_names[3] == get_name[local_field] assert gate_names[4] == get_name[local_field]
def circuit(x=None): qml.QAOAEmbedding(features=x, weights=weights, wires=range(n_wires), local_field="A") return [qml.expval(qml.PauliZ(i)) for i in range(n_wires)]
def circuit_template(features, weights): qml.QAOAEmbedding(features, weights, range(2)) return qml.expval(qml.PauliZ(0))
def circuit(): qml.QAOAEmbedding(features, weights, wires=range(n_wires)) return qml.expval(qml.PauliZ(0))
def circuit2(): qml.QAOAEmbedding(features, weights, wires=["z", "a", "k"]) return qml.expval(qml.Identity("z"))
def circuit(): qml.QAOAEmbedding(features, weights, wires=range(3)) return qml.expval(qml.Identity(0))
def circuit(x=None): qml.QAOAEmbedding(features=x, weights=weights, wires=range(2)) return [qml.expval(qml.PauliZ(i)) for i in range(2)]