当前位置: 首页>>代码示例>>Python>>正文


Python qiskit.execute方法代码示例

本文整理汇总了Python中qiskit.execute方法的典型用法代码示例。如果您正苦于以下问题:Python qiskit.execute方法的具体用法?Python qiskit.execute怎么用?Python qiskit.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qiskit的用法示例。


在下文中一共展示了qiskit.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paddle_after_measurement

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def paddle_after_measurement(self, circuit, qubit_num, shot_num):
        self.update()
        self.display_statevector(qubit_num)

        backend_sv_sim = BasicAer.get_backend('qasm_simulator')
        cr = ClassicalRegister(qubit_num)
        measure_circuit = deepcopy(circuit)  # make a copy of circuit
        measure_circuit.add_register(cr)    # add classical registers for measurement readout
        measure_circuit.measure(measure_circuit.qregs[0], measure_circuit.cregs[0])
        job_sim = execute(measure_circuit, backend_sv_sim, shots=shot_num)
        result_sim = job_sim.result()
        counts = result_sim.get_counts(circuit)

        self.paddle.set_alpha(255)
        self.image.blit(self.paddle, (0, int(list(counts.keys())[0], 2) * self.block_size))

        return int(list(counts.keys())[0], 2) 
开发者ID:HuangJunye,项目名称:QPong,代码行数:19,代码来源:statevector_grid.py

示例2: test_reset_nondeterministic

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_reset_nondeterministic(self):
        """Test StatevectorSimulator reset with for circuits with non-deterministic counts"""
        # For statevector output we can combine deterministic and non-deterministic
        # count output circuits
        circuits = ref_reset.reset_circuits_nondeterministic(
            final_measure=False)
        targets = ref_reset.reset_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test measure
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:20,代码来源:statevector_basics.py

示例3: test_measure

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_measure(self):
        """Test StatevectorSimulator measure with deterministic counts"""
        circuits = ref_measure.measure_circuits_deterministic(
            allow_sampling=True)
        targets = ref_measure.measure_statevector_deterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test conditional
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:18,代码来源:statevector_basics.py

示例4: test_conditional_unitary_2bit

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_conditional_unitary_2bit(self):
        """Test conditional unitary on 2-bit conditional register."""
        circuits = ref_conditionals.conditional_circuits_2bit(
            final_measure=False, conditional_type='unitary')
        targets = ref_conditionals.conditional_statevector_2bit()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test h-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:18,代码来源:statevector_basics.py

示例5: test_h_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_h_gate_nondeterministic_minimal_basis_gates(self):
        """Test h-gate gate circuits compiling to u3,cx"""
        circuits = ref_1q_clifford.h_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_1q_clifford.h_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test x-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例6: test_x_gate_deterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_x_gate_deterministic_minimal_basis_gates(self):
        """Test x-gate gate circuits compiling to u3,cx"""
        circuits = ref_1q_clifford.x_gate_circuits_deterministic(
            final_measure=False)
        targets = ref_1q_clifford.x_gate_statevector_deterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test z-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例7: test_z_gate_deterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_z_gate_deterministic_minimal_basis_gates(self):
        """Test z-gate gate circuits compiling to u3,cx"""
        circuits = ref_1q_clifford.z_gate_circuits_deterministic(
            final_measure=False)
        targets = ref_1q_clifford.z_gate_statevector_deterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test y-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例8: test_y_gate_deterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_y_gate_deterministic_minimal_basis_gates(self):
        """Test y-gate gate circuits compiling to u3, cx."""
        circuits = ref_1q_clifford.y_gate_circuits_deterministic(
            final_measure=False)
        targets = ref_1q_clifford.y_gate_statevector_deterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test s-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例9: test_s_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_s_gate_nondeterministic_minimal_basis_gates(self):
        """Test s-gate gate circuits compiling to u3,cx"""
        circuits = ref_1q_clifford.s_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_1q_clifford.s_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test sdg-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例10: test_sdg_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_sdg_gate_nondeterministic_minimal_basis_gates(self):
        """Test sdg-gate gate circuits compiling to u3,cx"""
        circuits = ref_1q_clifford.sdg_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_1q_clifford.sdg_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test cx-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例11: test_cx_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_cx_gate_nondeterministic_minimal_basis_gates(self):
        """Test cx-gate gate circuits compiling to u3,cx"""
        circuits = ref_2q_clifford.cx_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_2q_clifford.cx_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test cz-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例12: test_cz_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_cz_gate_nondeterministic_minimal_basis_gates(self):
        """Test cz-gate gate circuits compiling to u3,cx"""
        circuits = ref_2q_clifford.cz_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_2q_clifford.cz_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test swap-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例13: test_swap_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_swap_gate_nondeterministic_minimal_basis_gates(self):
        """Test swap-gate gate circuits compiling to u3,cx"""
        circuits = ref_2q_clifford.swap_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_2q_clifford.swap_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test t-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例14: test_t_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_t_gate_nondeterministic_minimal_basis_gates(self):
        """Test t-gate gate circuits compiling to u3,cx"""
        circuits = ref_non_clifford.t_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_non_clifford.t_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test tdg-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py

示例15: test_tdg_gate_nondeterministic_minimal_basis_gates

# 需要导入模块: import qiskit [as 别名]
# 或者: from qiskit import execute [as 别名]
def test_tdg_gate_nondeterministic_minimal_basis_gates(self):
        """Test tdg-gate gate circuits compiling to u3,cx"""
        circuits = ref_non_clifford.tdg_gate_circuits_nondeterministic(
            final_measure=False)
        targets = ref_non_clifford.tdg_gate_statevector_nondeterministic()
        job = execute(circuits,
                      self.SIMULATOR,
                      shots=1,
                      basis_gates=['u1', 'u2', 'u3', 'cx'],
                      backend_options=self.BACKEND_OPTS)
        result = job.result()
        self.assertSuccess(result)
        self.compare_statevector(result, circuits, targets)

    # ---------------------------------------------------------------------
    # Test ccx-gate
    # --------------------------------------------------------------------- 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:19,代码来源:statevector_basics.py


注:本文中的qiskit.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。