コード例 #1
0
def test_cancellation() -> None:
    token = cast(str, os.getenv("IONQ_AUTH"))
    b = IonQBackend(api_key=token, device_name="simulator", label="test 6")

    qc = Circuit(3, 3)
    qc.H(0)
    qc.CX(0, 2)
    qc.Measure(0, 1)
    qc.Measure(1, 0)
    qc.Measure(2, 2)
    b.compile_circuit(qc)
    h = b.process_circuit(qc, n_shots=100)
    b.cancel(h)
コード例 #2
0
def test_shots_bits_edgecases(n_shots, n_bits) -> None:
    ionq_backend = IonQBackend(api_key="invalid",
                               device_name="simulator",
                               label="test 5")
    ionq_backend._MACHINE_DEBUG = True
    c = Circuit(n_bits, n_bits)
    # TODO TKET-813 add more shot based backends and move to integration tests
    h = ionq_backend.process_circuit(c, n_shots)
    res = ionq_backend.get_result(h)

    correct_shots = np.zeros((n_shots, n_bits), dtype=int)
    correct_shape = (n_shots, n_bits)
    correct_counts = Counter({(0, ) * n_bits: n_shots})
    # BackendResult
    assert np.array_equal(res.get_shots(), correct_shots)
    assert res.get_shots().shape == correct_shape
    assert res.get_counts() == correct_counts

    # Direct
    assert np.array_equal(ionq_backend.get_shots(c, n_shots), correct_shots)
    assert ionq_backend.get_shots(c, n_shots).shape == correct_shape
    assert ionq_backend.get_counts(c, n_shots) == correct_counts