예제 #1
0
def test_delete():
    program = SimulatedLocalProgram([cirq.Circuit()], None, program_id='program')
    job1 = SimulatedLocalJob(
        job_id='test_job1', processor_id='test1', parent_program=program, repetitions=100, sweeps=[]
    )
    job2 = SimulatedLocalJob(
        job_id='test_job2', processor_id='test1', parent_program=program, repetitions=100, sweeps=[]
    )
    job3 = SimulatedLocalJob(
        job_id='test_job3', processor_id='test1', parent_program=program, repetitions=100, sweeps=[]
    )
    program.add_job(job1.id(), job1)
    program.add_job(job2.id(), job2)
    program.add_job(job3.id(), job3)
    assert set(program.list_jobs()) == {job1, job2, job3}
    program.delete_job(job2.id())
    assert set(program.list_jobs()) == {job1, job3}
    program.delete(delete_jobs=True)
    assert program.list_jobs() == []
예제 #2
0
def test_run():
    program = ParentProgram(
        [cirq.Circuit(cirq.X(Q), cirq.measure(Q, key='m'))], None)
    job = SimulatedLocalJob(job_id='test_job',
                            processor_id='test1',
                            parent_program=program,
                            repetitions=100,
                            sweeps=[])
    assert job.id() == 'test_job'
    assert job.execution_status() == quantum.enums.ExecutionStatus.State.READY
    results = job.results()
    assert np.all(results[0].measurements['m'] == 1)
    assert job.execution_status(
    ) == quantum.enums.ExecutionStatus.State.SUCCESS