Beispiel #1
0
    def to_proto(self, *qubits):
        if len(qubits) != 1:
            raise ValueError('Wrong number of qubits.')

        q = qubits[0]
        op = operations_pb2.Operation()
        q.to_proto(op.exp_z.target)
        self.parameterized_value_to_proto(self.half_turns, op.exp_z.half_turns)
        return op
Beispiel #2
0
    def to_proto(self, *qubits):
        if len(qubits) == 0:
            raise ValueError('Measurement gate on no qubits.')

        op = operations_pb2.Operation()
        for q in qubits:
            q.to_proto(op.measurement.targets.add())
        op.measurement.key = self.key
        return op
Beispiel #3
0
    def to_proto(self, *qubits):
        if len(qubits) != 2:
            raise ValueError('Wrong number of qubits.')

        p, q = qubits
        op = operations_pb2.Operation()
        p.to_proto(op.exp_11.target1)
        q.to_proto(op.exp_11.target2)
        self.parameterized_value_to_proto(self.half_turns,
                                          op.exp_11.half_turns)
        return op
Beispiel #4
0
 def to_proto(self, *qubits):
     if len(qubits) == 0:
         raise ValueError('Measurement gate on no qubits.')
     if self.invert_mask and len(self.invert_mask) != len(qubits):
         raise ValueError('Measurement gate had invert mask of length '
                          'different than number of qubits it acts on.')
     op = operations_pb2.Operation()
     for q in qubits:
         q.to_proto(op.measurement.targets.add())
     op.measurement.key = self.key
     op.measurement.invert_mask.extend(self.invert_mask)
     return op