class JKUBackendTestCase(QiskitTestCase): """Tests for the JKU backend.""" def setUp(self): super().setUp() self.backend = QasmSimulator(silent=True) def test_configuration(self): """Test backend.configuration().""" configuration = self.backend.configuration() return configuration def test_properties(self): """Test backend.properties().""" properties = self.backend.properties() self.assertEqual(properties, None) def test_status(self): """Test backend.status().""" status = self.backend.status() return status def test_run_circuit(self): """Test running a single circuit.""" result = execute(bell(), self.backend, seed_transpiler=34342).result() self.assertEqual(result.success, True) return result
def test_circuit_multi(self): """Test circuit multi regs declared at start. """ qreg0 = QuantumRegister(2, 'q0') creg0 = ClassicalRegister(2, 'c0') qreg1 = QuantumRegister(2, 'q1') creg1 = ClassicalRegister(2, 'c1') circ = QuantumCircuit(qreg0, qreg1) circ.x(qreg0[1]) circ.x(qreg1[0]) meas = QuantumCircuit(qreg0, qreg1, creg0, creg1) meas.measure(qreg0, creg0) meas.measure(qreg1, creg1) qc = circ + meas backend_sim = QasmSimulator(silent=True) qobj_qc = compile(qc, backend_sim, seed_mapper=34342) qobj_circ = compile(circ, backend_sim, seed_mapper=3438) result = backend_sim.run(qobj_qc).result() counts = result.get_counts(qc) target = {'01 10': 1024} result = backend_sim.run(qobj_circ).result() state = result.get_statevector(circ) self.assertEqual(counts, target) self.assertAlmostEqual(state_fidelity(basis_state('0110', 4), state), 1.0, places=7)
def setUp(self): super().setUp() self.backend = QasmSimulator(silent=True) qr = QuantumRegister(2) self.q_circuit = QuantumCircuit(qr) self.q_circuit.h(qr[0]) self.q_circuit.cx(qr[0], qr[1])
def setUp(self): self.seed = 88 self.backend = QasmSimulator(silent=True) qasm_filename = os.path.join(os.path.dirname(__file__), 'qasms', 'example.qasm') compiled_circuit = QuantumCircuit.from_qasm_file(qasm_filename) compiled_circuit.name = 'test' self.circuit = compiled_circuit
import random import unittest import numpy from scipy.stats import chi2_contingency from qiskit import execute from qiskit import QuantumCircuit from qiskit import QuantumRegister from qiskit import ClassicalRegister from qiskit import BasicAer from qiskit_jku_provider import QasmSimulator try: global_pq_simulator = QasmSimulator(silent=True) except ImportError: _skip_class = True else: _skip_class = False from ._random_circuit_generator import RandomCircuitGenerator from .common import QiskitTestCase @unittest.skipIf(_skip_class, 'JKU C++ simulator unavailable') class TestQasmSimulatorJKU(QiskitTestCase): """ Test JKU simulator. """
def setUp(self): super().setUp() self.backend = QasmSimulator(silent=True)