def test_split_then_merge(device):
    transformer = ct.CircuitTransformer(device)
    c = cirq.Circuit(qm.split_move(a1, a2, b1), qm.split_move(a2, a3, b3),
                     qm.split_move(b1, c1, c2), qm.normal_move(c1, d1),
                     qm.normal_move(a3, a4), qm.merge_move(a4, d1, a1))
    transformer.qubit_mapping(c)
    device.validate_circuit(transformer.optimize_circuit(c))
示例#2
0
 def __init__(self,
              init_basis_state: int,
              sampler: cirq.Sampler = cirq.Simulator(),
              device: Optional[cirq.Device] = None,
              error_mitigation: Optional[
                  enums.ErrorMitigation] = enums.ErrorMitigation.Nothing,
              noise_mitigation: Optional[float] = 0.0):
     self.device = device
     self.sampler = sampler
     if device is not None:
         self.transformer = circuit_transformer.CircuitTransformer(device)
     self.with_state(init_basis_state)
     self.error_mitigation = error_mitigation
     self.noise_mitigation = noise_mitigation
def test_move_around_square(device):
    transformer = ct.CircuitTransformer(device)
    c = cirq.Circuit(qm.normal_move(a1, a2), qm.normal_move(a2, b2),
                     qm.normal_move(b2, b1), qm.normal_move(b1, a1))
    transformer.qubit_mapping(c)
    device.validate_circuit(transformer.optimize_circuit(c))
def test_disconnected(device):
    transformer = ct.CircuitTransformer(device)
    c = cirq.Circuit(qm.split_move(a1, a2, a3), qm.split_move(a3, a4, d1),
                     qm.split_move(b1, b2, b3), qm.split_move(c1, c2, c3))
    transformer.qubit_mapping(c)
    device.validate_circuit(transformer.optimize_circuit(c))
def test_three_split_moves(device):
    transformer = ct.CircuitTransformer(device)
    c = cirq.Circuit(qm.split_move(a1, a2, b1), qm.split_move(a2, a3, b3),
                     qm.split_move(b1, c1, c2))
    transformer.qubit_mapping(c)
    device.validate_circuit(transformer.optimize_circuit(c))
def test_single_qubit_with_two_qubits(device):
    transformer = ct.CircuitTransformer(device)
    c = cirq.Circuit(cirq.X(a1), cirq.X(a2), cirq.X(a3),
                     cirq.ISWAP(a3, a4)**0.5)
    transformer.qubit_mapping(c)
    device.validate_circuit(transformer.optimize_circuit(c))
def test_single_qubit_ops(device):
    transformer = ct.CircuitTransformer(device)
    c = cirq.Circuit(cirq.X(a1), cirq.X(a2), cirq.X(a3))
    transformer.qubit_mapping(c)
    c = transformer.optimize_circuit(c)
    device.validate_circuit(c)