def test_unsupported_op(): with pytest.raises(ValueError, match='invalid operation'): programs.xmon_op_from_proto(operations_pb2.Operation()) with pytest.raises(ValueError, match='know how to serialize'): programs.gate_to_proto( cirq.CCZ, (cirq.GridQubit(0, 0), cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)), delay=0)
def assert_proto_dict_convert(gate: cirq.Gate, proto: operations_pb2.Operation, *qubits: cirq.Qid): assert programs.gate_to_proto(gate, qubits, delay=0) == proto assert programs.xmon_op_from_proto(proto) == gate(*qubits)