コード例 #1
0
ファイル: test.py プロジェクト: NickyBar/QIP
    def test_print_circuit(self):
        QP_program = QuantumProgram(specs=QPS_SPECS)
        qc, qr, cr = QP_program.get_quantum_elements()

        qc.h(qr[1])
        result = qc.qasm()
        self.assertEqual(len(result), 78)
コード例 #2
0
ファイル: test.py プロジェクト: NickyBar/QIP
 def test_get_components(self):
     """
     Get the program componentes, like Circuits and Registers
     """
     QP_program = QuantumProgram(specs=QPS_SPECS)
     qc, qr, cr = QP_program.get_quantum_elements()
     self.assertIsInstance(qc, QuantumCircuit)
     self.assertIsInstance(qr, QuantumRegister)
     self.assertIsInstance(cr, ClassicalRegister)
コード例 #3
0
ファイル: test.py プロジェクト: NickyBar/QIP
    def test_execute_one_circuit_real_online(self):
        QP_program = QuantumProgram(specs=QPS_SPECS)
        qc, qr, cr = QP_program.get_quantum_elements()

        qc.h(qr[1])
        qc.measure(qr[0], cr[0])

        device = 'ibmqx2'  # the device to run on
        shots = 1  # the number of shots in the experiment.

        apiconnection = QP_program.set_api(API_TOKEN, URL)
        result = QP_program.execute(['circuitName'],
                                    device,
                                    shots,
                                    max_credits=3)
        self.assertIn(result["status"], ["COMPLETED", "Error"])
コード例 #4
0
ファイル: test.py プロジェクト: NickyBar/QIP
    def test_local_qasm_simulator_one_shot(self):
        QP_program = QuantumProgram(specs=QPS_SPECS)
        qc, qr, cr = QP_program.get_quantum_elements()

        qc2 = QP_program.create_circuit("qc2", ["qname"], ["cname"])
        qc3 = QP_program.create_circuit("qc3", ["qname"], ["cname"])
        qc2.h(qr[0])
        qc3.h(qr[0])
        qc2.measure(qr[0], cr[0])
        qc3.measure(qr[0], cr[0])
        circuits = ['qc2', 'qc3']

        device = 'local_qasm_simulator'  # the device to run on
        shots = 1  # the number of shots in the experiment.
        credits = 3
        coupling_map = None
        result = QP_program.execute(circuits, device, shots)
        print(QP_program.get_qasms(['qc2', 'qc3']))
        self.assertEqual(result['status'], 'COMPLETED')