def _cz_to_proto(gate: 'cirq.CZPowGate', p: 'cirq.Qid', q: 'cirq.Qid') -> operations_pb2.Exp11: return operations_pb2.Exp11( target1=_qubit_to_proto(p), target2=_qubit_to_proto(q), half_turns=_parameterized_value_to_proto(gate.exponent), )
def test_cz_proto_convert(): gate = cirq.CZ**sympy.Symbol('k') proto = operations_pb2.Operation(exp_11=operations_pb2.Exp11( target1=operations_pb2.Qubit(row=2, col=3), target2=operations_pb2.Qubit(row=3, col=4), half_turns=operations_pb2.ParameterizedFloat(parameter_key='k'), )) assert_proto_dict_convert(gate, proto, cirq.GridQubit(2, 3), cirq.GridQubit(3, 4)) gate = cirq.CZ**0.5 proto = operations_pb2.Operation(exp_11=operations_pb2.Exp11( target1=operations_pb2.Qubit(row=2, col=3), target2=operations_pb2.Qubit(row=3, col=4), half_turns=operations_pb2.ParameterizedFloat(raw=0.5), )) assert_proto_dict_convert(gate, proto, cirq.GridQubit(2, 3), cirq.GridQubit(3, 4))