def test_analyze_mode(self): circuit = generate_bell_state() task = Task(circuit, get_qpu_server()) for state in task.states(): self.assertAlmostEqual(state.probability, 0.5)
def test_bit_ordering(self): circ = generate_bit_ordering() for n_shots in [0, 10]: # for expected_res, qbits in [(2, [0, 1, 2, 3]), (1, [0, 1, 2])]: for expected_res, qbits in [(2, [0, 1, 2, 3]), (1, [0, 1, 2]), (2, [2, 3]), (1, [3, 2])]: ref_task = Task(circ, get_qpu_server()) if n_shots == 0: for res in ref_task.states(qbits=qbits): self.assertEqual(res.state.int, expected_res) else: for res in ref_task.execute(nb_samples=n_shots, qbits=qbits): self.assertEqual(res.state.int, expected_res)
def test_break(self): circ = generate_break() task = Task(circ, get_qpu_server()) exp = exception_types.QPUException(exception_types.ErrorType.BREAK) exp = exception_types.QPUException(exception_types.ErrorType.BREAK) raised = False try: res = task.execute() except exception_types.QPUException as Exp: self.assertEqual(Exp.code, 10) self.assertEqual(Exp.modulename, "qat.pylinalg") raised = True self.assertTrue(raised)
def test_default_mode(self): circuit = generate_bell_state() task = Task(circuit, get_qpu_server()) result = task.execute() self.assertTrue(result.state.int == result.state.int)
def test_formula_and_cctrl(self): circ = generate_boolean() task = Task(circ, get_qpu_server()) res = task.execute() self.assertEqual(res.state.int, 7)