Exemplo n.º 1
0
def test_honeywell() -> None:
    token = os.getenv("HQS_AUTH")
    backend = HoneywellBackend(
        device_name="HQS-LT-1.0-APIVAL", machine_debug=skip_remote_tests
    )
    c = Circuit(4, 4, "test 1")
    c.H(0)
    c.CX(0, 1)
    c.Rz(0.3, 2)
    c.CSWAP(0, 1, 2)
    c.CRz(0.4, 2, 3)
    c.CY(1, 3)
    c.ZZPhase(0.1, 2, 0)
    c.Tdg(3)
    c.measure_all()
    backend.compile_circuit(c)
    n_shots = 4
    handle = backend.process_circuits([c], n_shots)[0]
    correct_shots = np.zeros((4, 4))
    correct_counts = {(0, 0, 0, 0): 4}
    res = backend.get_result(handle, timeout=49)
    shots = res.get_shots()
    counts = res.get_counts()
    assert backend.circuit_status(handle).status is StatusEnum.COMPLETED
    assert np.all(shots == correct_shots)
    assert counts == correct_counts
    newshots = backend.get_shots(c, 4, timeout=49)
    assert np.all(newshots == correct_shots)
    newcounts = backend.get_counts(c, 4)
    assert newcounts == correct_counts
    if token is None:
        assert backend.device is None
Exemplo n.º 2
0
def test_cost_estimate(c: Circuit, n_shots: int) -> None:

    b = HoneywellBackend("HQS-LT-S1-APIVAL")
    b.compile_circuit(c)
    estimate = b.cost_estimate(c, n_shots)
    status = b.circuit_status(b.process_circuit(c, n_shots))
    status_msg = status.message
    message_dict = literal_eval(status_msg)
    if message_dict["cost"] is not None:
        api_cost = float(message_dict["cost"])
        assert estimate == api_cost
Exemplo n.º 3
0
def test_cancel() -> None:
    b = HoneywellBackend(device_name="HQS-LT-1.0-APIVAL", label="test cancel")
    c = Circuit(2, 2).H(0).CX(0, 1).measure_all()
    b.compile_circuit(c)
    handle = b.process_circuit(c, 10)
    try:
        # will raise HTTP error if job is already completed
        b.cancel(handle)
    except HQSAPIError as err:
        check_completed = "job has completed already" in str(err)
        assert check_completed
        if not check_completed:
            raise err

    print(b.circuit_status(handle))