Esempio n. 1
0
    def test_normal_launch_mode_with_nbshots(self):

        # Create a small program
        prog = Program()
        qubits = prog.qalloc(2)
        prog.apply(H, qubits[0])
        prog.apply(CNOT, qubits)

        circ = prog.to_circ()

        # Simulate
        job = circ.to_job(nbshots=4, aggregate_data=False)
        qpu = PyLinalg()
        result = qpu.submit_job(job)

        self.assertEqual(len(result.raw_data), 4)
        self.assertEqual(result.raw_data[0].probability,
                         None)  #no prob if not aggregating data
Esempio n. 2
0
    def test_normal_launch_mode(self):

        # Create a small program
        prog = Program()
        qubits = prog.qalloc(2)
        prog.apply(H, qubits[0])
        prog.apply(CNOT, qubits)

        circ = prog.to_circ()

        # Simulate
        job = circ.to_job()
        qpu = PyLinalg()
        result = qpu.submit_job(job)

        self.assertEqual(len(result.raw_data), 2)

        self.assertAlmostEqual(result.raw_data[0].probability, 0.5)
        self.assertTrue(result.raw_data[0].state.int in [0, 3])
        self.assertTrue(result.raw_data[1].state.int in [0, 3])
Esempio n. 3
0
    def test_normal_launch_mode_with_nbshots_and_qbs(self):

        # Create a small program
        prog = Program()
        qubits = prog.qalloc(2)
        prog.apply(H, qubits[0])
        prog.apply(CNOT, qubits)

        circ = prog.to_circ()

        # Simulate
        job = circ.to_job(nbshots=4, qubits=[0], aggregate_data=False)
        qpu = PyLinalg()
        result = qpu.submit_job(job)

        self.assertEqual(len(result.raw_data), 4)

        self.assertEqual(result.raw_data[0].probability,
                         None)  #No probability if not aggregating data
        for rd in result.raw_data:
            self.assertTrue(rd.state.int in [0, 1], msg="state= %s" % rd.state)