From ca25facfe4cd7fe4d6793787b5f676470e9585f2 Mon Sep 17 00:00:00 2001 From: "Jack J. Woehr" Date: Tue, 7 May 2019 00:32:18 -0600 Subject: [PATCH 1/4] Fixes #53 --- test/ibmq/test_ibmq_backends.py | 15 +++--- test/ibmq/test_ibmq_connector.py | 15 +++--- test/ibmq/test_ibmq_integration.py | 15 +++--- test/ibmq/test_ibmq_job.py | 72 ++++++++++++++++----------- test/ibmq/test_ibmq_qasm_simulator.py | 12 +++-- test/ibmq/test_ibmq_qobj.py | 20 ++++---- 6 files changed, 85 insertions(+), 64 deletions(-) diff --git a/test/ibmq/test_ibmq_backends.py b/test/ibmq/test_ibmq_backends.py index 2bba76be9..c698fe097 100644 --- a/test/ibmq/test_ibmq_backends.py +++ b/test/ibmq/test_ibmq_backends.py @@ -15,11 +15,12 @@ from qiskit.providers.ibmq import IBMQ from qiskit.qobj import QobjHeader from qiskit.test import QiskitTestCase, requires_qe_access, slow_test -from qiskit.tools.compiler import compile +from qiskit.compiler import assemble, transpile class TestIBMQBackends(QiskitTestCase): """Tests for all the IBMQ backends.""" + def setUp(self): super().setUp() @@ -94,11 +95,12 @@ def test_qobj_headers_in_result_sims(self, qe_token, qe_url): for backend in backends: with self.subTest(backend=backend): - qobj = compile(self.qc1, backend) + circuits = transpile(self.qc1, backend=backend) # Update the Qobj header. - qobj.header = QobjHeader.from_dict(custom_qobj_header) - # Update the Qobj.experiment header. + qobj_header = QobjHeader.from_dict(custom_qobj_header) + qobj = assemble(circuits, backend=backend, + qobj_header=qobj_header) qobj.experiments[0].header.some_field = 'extra info' result = backend.run(qobj).result() @@ -117,7 +119,7 @@ def test_qobj_headers_in_result_devices(self, qe_token, qe_url): for backend in backends: with self.subTest(backend=backend): - qobj = compile(self.qc1, backend) + qobj = transpile(self.qc1, backend=backend) # Update the Qobj header. qobj.header = QobjHeader.from_dict(custom_qobj_header) @@ -146,4 +148,5 @@ def test_aliases(self, qe_token, qe_url): else: backend_by_display_name = IBMQ.get_backend(display_name) self.assertEqual(backend_by_name, backend_by_display_name) - self.assertEqual(backend_by_display_name.name(), backend_name) + self.assertEqual( + backend_by_display_name.name(), backend_name) diff --git a/test/ibmq/test_ibmq_connector.py b/test/ibmq/test_ibmq_connector.py index c6d84793c..94f11e0eb 100644 --- a/test/ibmq/test_ibmq_connector.py +++ b/test/ibmq/test_ibmq_connector.py @@ -10,9 +10,10 @@ import re from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister -from qiskit.tools.compiler import compile +from qiskit.compiler import assemble, transpile from qiskit.providers.ibmq import IBMQ -from qiskit.providers.ibmq.api import (ApiError, BadBackendError, IBMQConnector) +from qiskit.providers.ibmq.api import ( + ApiError, BadBackendError, IBMQConnector) from qiskit.test import QiskitTestCase, requires_qe_access @@ -57,7 +58,8 @@ def test_api_run_job(self, qe_token, qe_url): backend_name = 'ibmq_qasm_simulator' backend = IBMQ.get_backend(backend_name) - qobj = compile(self.qc1, backend=backend, seed=self.seed, shots=1) + qobj = assemble(transpile(self.qc1, backend=backend, seed_transpiler=self.seed), + backend=backend, shots=1) api = backend._api job = api.run_job(qobj.as_dict(), backend_name) @@ -73,7 +75,8 @@ def test_api_run_job_fail_backend(self, qe_token, qe_url): backend_name = 'ibmq_qasm_simulator' backend = IBMQ.get_backend(backend_name) - qobj = compile(self.qc1, backend=backend, seed=self.seed, shots=1) + qobj = assemble(transpile(self.qc1, backend=backend, seed_transpiler=self.seed), + backend=backend, shots=1) api = backend._api self.assertRaises(BadBackendError, api.run_job, qobj.as_dict(), @@ -133,8 +136,8 @@ def test_get_job_includes(self, qe_token, qe_url): backend_name = 'ibmq_qasm_simulator' backend = IBMQ.get_backend(backend_name) - qobj = compile([self.qc1, self.qc2], - backend=backend, seed=self.seed, shots=1) + qobj = assemble(transpile([self.qc1, self.qc2], backend=backend, seed_transpiler=self.seed), + backend=backend, shots=1) api = backend._api job = api.run_job(qobj.as_dict(), backend_name) diff --git a/test/ibmq/test_ibmq_integration.py b/test/ibmq/test_ibmq_integration.py index 3f49417f7..22d599a3c 100644 --- a/test/ibmq/test_ibmq_integration.py +++ b/test/ibmq/test_ibmq_integration.py @@ -11,9 +11,8 @@ from qiskit.providers.ibmq import IBMQ, least_busy from qiskit.result import Result from qiskit.test import QiskitTestCase, requires_qe_access -from qiskit.tools.compiler import compile from qiskit.execute import execute -from qiskit.transpiler import transpile +from qiskit.compiler import assemble, transpile class TestIBMQIntegration(QiskitTestCase): @@ -54,7 +53,7 @@ def test_compile_remote(self, qe_token, qe_url): qc.cx(qubit_reg[0], qubit_reg[1]) qc.measure(qubit_reg, clbit_reg) - circuits = transpile(qc, backend) + circuits = transpile(qc, backend=backend) self.assertIsInstance(circuits, QuantumCircuit) @requires_qe_access @@ -87,7 +86,8 @@ def test_compile_run_remote(self, qe_token, qe_url): qc.h(qubit_reg[0]) qc.cx(qubit_reg[0], qubit_reg[1]) qc.measure(qubit_reg, clbit_reg) - qobj = compile(qc, backend, seed=self.seed) + qobj = assemble(transpile(qc, backend=backend, seed_transpiler=self.seed), + backend=backend) job = backend.run(qobj) result = job.result(timeout=20) self.assertIsInstance(result, Result) @@ -106,7 +106,8 @@ def test_compile_two_run_remote(self, qe_token, qe_url): qc.measure(qubit_reg, clbit_reg) qc_extra = QuantumCircuit(qubit_reg, clbit_reg, name="extra") qc_extra.measure(qubit_reg, clbit_reg) - qobj = compile([qc, qc_extra], backend, seed=self.seed) + qobj = assemble(transpile([qc, qc_extra], backend=backend, seed_transpiler=self.seed), + backend=backend) job = backend.run(qobj) result = job.result() self.assertIsInstance(result, Result) @@ -124,7 +125,7 @@ def test_execute_remote(self, qe_token, qe_url): qc.cx(qubit_reg[0], qubit_reg[1]) qc.measure(qubit_reg, clbit_reg) - job = execute(qc, backend, seed=self.seed) + job = execute(qc, backend, seed_transpiler=self.seed) results = job.result() self.assertIsInstance(results, Result) @@ -142,6 +143,6 @@ def test_execute_two_remote(self, qe_token, qe_url): qc.measure(qubit_reg, clbit_reg) qc_extra = QuantumCircuit(qubit_reg, clbit_reg) qc_extra.measure(qubit_reg, clbit_reg) - job = execute([qc, qc_extra], backend, seed=self.seed) + job = execute([qc, qc_extra], backend, seed_transpiler=self.seed) results = job.result() self.assertIsInstance(results, Result) diff --git a/test/ibmq/test_ibmq_job.py b/test/ibmq/test_ibmq_job.py index 3ef78addf..50efd3e09 100644 --- a/test/ibmq/test_ibmq_job.py +++ b/test/ibmq/test_ibmq_job.py @@ -22,7 +22,7 @@ from qiskit.providers.ibmq.exceptions import IBMQBackendError from qiskit.providers.ibmq.ibmqjob import IBMQJob from qiskit.test import requires_qe_access, slow_test -from qiskit.tools.compiler import compile +from qiskit.compiler import assemble, transpile from ..jobtestcase import JobTestCase @@ -44,14 +44,15 @@ def test_run_simulator(self, qe_token, qe_url): qc = QuantumCircuit(qr, cr, name='hadamard') qc.h(qr) qc.measure(qr, cr) - qobj = compile([self._qc, qc], backend) + qobj = assemble(transpile([self._qc, qc], backend=backend), backend=backend) shots = qobj.config.shots job = backend.run(qobj) result = job.result() counts_qx1 = result.get_counts(0) counts_qx2 = result.get_counts(1) - counts_ex1 = {'00': shots/2, '11': shots/2} - counts_ex2 = {'00': shots/4, '11': shots/4, '10': shots/4, '01': shots/4} + counts_ex1 = {'00': shots / 2, '11': shots / 2} + counts_ex2 = {'00': shots / 4, '11': shots + / 4, '10': shots / 4, '01': shots / 4} states1 = counts_qx1.keys() | counts_ex1.keys() states2 = counts_qx2.keys() | counts_ex2.keys() # contingency table @@ -77,7 +78,7 @@ def test_run_device(self, qe_token, qe_url): IBMQ.enable_account(qe_token, qe_url) backend = least_busy(IBMQ.backends(simulator=False)) - qobj = compile(self._qc, backend) + qobj = assemble(transpile(self._qc, backend=backend), backend=backend) shots = qobj.config.shots job = backend.run(qobj) while not job.status() is JobStatus.DONE: @@ -85,8 +86,8 @@ def test_run_device(self, qe_token, qe_url): result = job.result() counts_qx = result.get_counts(0) - counts_ex = {'00': shots/2, '11': shots/2} - self.assertDictAlmostEqual(counts_qx, counts_ex, shots*0.1) + counts_ex = {'00': shots / 2, '11': shots / 2} + self.assertDictAlmostEqual(counts_qx, counts_ex, shots * 0.1) # Test fetching the job properties, as this is a real backend and is # guaranteed to have them. @@ -106,17 +107,18 @@ def test_run_async_simulator(self, qe_token, qe_url): qr = QuantumRegister(num_qubits, 'qr') cr = ClassicalRegister(num_qubits, 'cr') qc = QuantumCircuit(qr, cr) - for i in range(num_qubits-1): - qc.cx(qr[i], qr[i+1]) + for i in range(num_qubits - 1): + qc.cx(qr[i], qr[i + 1]) qc.measure(qr, cr) - qobj = compile([qc]*10, backend) + qobj = assemble(transpile([qc] * 10, backend=backend), backend=backend) num_jobs = 5 job_array = [backend.run(qobj) for _ in range(num_jobs)] found_async_jobs = False timeout = 30 start_time = time.time() while not found_async_jobs: - check = sum([job.status() is JobStatus.RUNNING for job in job_array]) + check = sum( + [job.status() is JobStatus.RUNNING for job in job_array]) if check >= 2: self.log.info('found %d simultaneous jobs', check) break @@ -128,7 +130,7 @@ def test_run_async_simulator(self, qe_token, qe_url): for job in job_array: self.log.info('%s %s %s %s', job.status(), job.status() is JobStatus.RUNNING, check, job.job_id()) - self.log.info('- %s', str(time.time()-start_time)) + self.log.info('- %s', str(time.time() - start_time)) if time.time() - start_time > timeout: raise TimeoutError('failed to see multiple running jobs after ' '{0} s'.format(timeout)) @@ -137,7 +139,8 @@ def test_run_async_simulator(self, qe_token, qe_url): result_array = [job.result() for job in job_array] self.log.info('got back all job results') # Ensure all jobs have finished. - self.assertTrue(all([job.status() is JobStatus.DONE for job in job_array])) + self.assertTrue( + all([job.status() is JobStatus.DONE for job in job_array])) self.assertTrue(all([result.success for result in result_array])) # Ensure job ids are unique. @@ -157,17 +160,19 @@ def test_run_async_device(self, qe_token, qe_url): qr = QuantumRegister(num_qubits, 'qr') cr = ClassicalRegister(num_qubits, 'cr') qc = QuantumCircuit(qr, cr) - for i in range(num_qubits-1): - qc.cx(qr[i], qr[i+1]) + for i in range(num_qubits - 1): + qc.cx(qr[i], qr[i + 1]) qc.measure(qr, cr) - qobj = compile(qc, backend) + qobj = assemble(transpile(qc, backend=backend), backend=backend) num_jobs = 3 job_array = [backend.run(qobj) for _ in range(num_jobs)] time.sleep(3) # give time for jobs to start (better way?) job_status = [job.status() for job in job_array] - num_init = sum([status is JobStatus.INITIALIZING for status in job_status]) + num_init = sum( + [status is JobStatus.INITIALIZING for status in job_status]) num_queued = sum([status is JobStatus.QUEUED for status in job_status]) - num_running = sum([status is JobStatus.RUNNING for status in job_status]) + num_running = sum( + [status is JobStatus.RUNNING for status in job_status]) num_done = sum([status is JobStatus.DONE for status in job_status]) num_error = sum([status is JobStatus.ERROR for status in job_status]) self.log.info('number of currently initializing jobs: %d/%d', @@ -186,7 +191,8 @@ def test_run_async_device(self, qe_token, qe_url): result_array = [job.result() for job in job_array] # Ensure all jobs have finished. - self.assertTrue(all([job.status() is JobStatus.DONE for job in job_array])) + self.assertTrue( + all([job.status() is JobStatus.DONE for job in job_array])) self.assertTrue(all([result.success for result in result_array])) # Ensure job ids are unique. @@ -202,7 +208,7 @@ def test_cancel(self, qe_token, qe_url): if self.using_ibmq_credentials else 'ibmqx4') backend = IBMQ.get_backend(backend_name) - qobj = compile(self._qc, backend) + qobj = assemble(transpile(self._qc, backend=backend), backend=backend) job = backend.run(qobj) self.wait_for_initialization(job, timeout=5) can_cancel = job.cancel() @@ -215,7 +221,7 @@ def test_job_id(self, qe_token, qe_url): IBMQ.enable_account(qe_token, qe_url) backend = IBMQ.get_backend('ibmq_qasm_simulator') - qobj = compile(self._qc, backend) + qobj = assemble(transpile(self._qc, backend=backend), backend=backend) job = backend.run(qobj) self.log.info('job_id: %s', job.job_id()) self.assertTrue(job.job_id() is not None) @@ -226,7 +232,7 @@ def test_get_backend_name(self, qe_token, qe_url): IBMQ.enable_account(qe_token, qe_url) backend = IBMQ.get_backend('ibmq_qasm_simulator') - qobj = compile(self._qc, backend) + qobj = assemble(transpile(self._qc, backend=backend), backend=backend) job = backend.run(qobj) self.assertTrue(job.backend().name() == backend.name()) @@ -239,11 +245,13 @@ def test_get_jobs_from_backend(self, qe_token, qe_url): start_time = time.time() job_list = backend.jobs(limit=5, skip=0) self.log.info('time to get jobs: %0.3f s', time.time() - start_time) - self.log.info('found %s jobs on backend %s', len(job_list), backend.name()) + self.log.info('found %s jobs on backend %s', + len(job_list), backend.name()) for job in job_list: self.log.info('status: %s', job.status()) self.assertTrue(isinstance(job.job_id(), str)) - self.log.info('time to get job statuses: %0.3f s', time.time() - start_time) + self.log.info('time to get job statuses: %0.3f s', + time.time() - start_time) @requires_qe_access def test_retrieve_job(self, qe_token, qe_url): @@ -251,7 +259,7 @@ def test_retrieve_job(self, qe_token, qe_url): IBMQ.enable_account(qe_token, qe_url) backend = IBMQ.get_backend('ibmq_qasm_simulator') - qobj = compile(self._qc, backend) + qobj = assemble(transpile(self._qc, backend=backend), backend=backend) job = backend.run(qobj) rjob = backend.retrieve_job(job.job_id()) @@ -268,10 +276,12 @@ def test_retrieve_job_uses_appropriate_backend(self, qe_token, qe_url): backends = IBMQ.backends(simulator=False) real_backend = least_busy(backends) - qobj_sim = compile(self._qc, simulator_backend) + qobj_sim = assemble( + transpile(self._qc, backend=simulator_backend), backend=simulator_backend) job_sim = simulator_backend.run(qobj_sim) - qobj_real = compile(self._qc, real_backend) + qobj_real = assemble( + transpile(self._qc, backend=real_backend), backend=real_backend) job_real = real_backend.run(qobj_real) # test a retrieved job's backend is the same as the queried backend @@ -363,7 +373,7 @@ def test_double_submit_fails(self, qe_token, qe_url): IBMQ.enable_account(qe_token, qe_url) backend = IBMQ.get_backend('ibmq_qasm_simulator') - qobj = compile(self._qc, backend) + qobj = assemble(transpile(self._qc, backend=backend), backend=backend) # backend.run() will automatically call job.submit() job = backend.run(qobj) with self.assertRaises(JobError): @@ -390,13 +400,15 @@ def setUp(self): def test_qobj_enabled_job(self): """Job should be an instance of IBMQJob.""" - qobj = compile(self._qc, self._backend) + qobj = assemble( + transpile(self._qc, backend=self._backend), backend=self._backend) job = self._backend.run(qobj) self.assertIsInstance(job, IBMQJob) def test_qobj_enabled_result(self): """Jobs can be retrieved.""" - qobj = compile(self._qc, self._backend) + qobj = assemble( + transpile(self._qc, backend=self._backend), backend=self._backend) job = self._backend.run(qobj) try: job.result() diff --git a/test/ibmq/test_ibmq_qasm_simulator.py b/test/ibmq/test_ibmq_qasm_simulator.py index 5a55b2fac..3b587e78b 100644 --- a/test/ibmq/test_ibmq_qasm_simulator.py +++ b/test/ibmq/test_ibmq_qasm_simulator.py @@ -10,7 +10,7 @@ from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister from qiskit.providers.ibmq import IBMQ from qiskit.test import QiskitTestCase, requires_qe_access -from qiskit.tools.compiler import compile +from qiskit.compiler import assemble, transpile class TestIbmqQasmSimulator(QiskitTestCase): @@ -27,7 +27,8 @@ def test_execute_one_circuit_simulator_online(self, qe_token, qe_url): qc = QuantumCircuit(qr, cr, name='qc') qc.h(qr[0]) qc.measure(qr[0], cr[0]) - qobj = compile(qc, backend=backend, seed=73846087) + qobj = assemble(transpile(qc, backend=backend, seed_transpiler=73846087), + backend=backend) shots = qobj.config.shots job = backend.run(qobj) result = job.result() @@ -54,7 +55,8 @@ def test_execute_several_circuits_simulator_online(self, qe_token, qe_url): qcr2.measure(qr[0], cr[0]) qcr2.measure(qr[1], cr[1]) shots = 1024 - qobj = compile([qcr1, qcr2], backend=backend, seed=73846087, shots=shots) + qobj = assemble(transpile([qcr1, qcr2], backend=backend, seed_transpiler=73846087), + backend=backend, shots=shots) job = backend.run(qobj) result = job.result() counts1 = result.get_counts(qcr1) @@ -88,8 +90,8 @@ def test_online_qasm_simulator_two_registers(self, qe_token, qe_url): qcr2.measure(qr1[1], cr1[1]) qcr2.measure(qr2[0], cr2[0]) qcr2.measure(qr2[1], cr2[1]) - shots = 1024 - qobj = compile([qcr1, qcr2], backend, seed=8458, shots=shots, seed_mapper=88434) + qobj = assemble(transpile([qcr1, qcr2], backend, seed_transpiler=8458), + backend=backend, shots=1024) job = backend.run(qobj) result = job.result() result1 = result.get_counts(qcr1) diff --git a/test/ibmq/test_ibmq_qobj.py b/test/ibmq/test_ibmq_qobj.py index 1a15d1d7c..42b370765 100644 --- a/test/ibmq/test_ibmq_qobj.py +++ b/test/ibmq/test_ibmq_qobj.py @@ -14,7 +14,7 @@ from qiskit.providers.ibmq import IBMQ from qiskit.qasm import pi from qiskit.test import QiskitTestCase, requires_qe_access, slow_test -from qiskit.tools.compiler import compile +from qiskit.compiler import transpile class TestIBMQQobj(QiskitTestCase): @@ -63,7 +63,7 @@ def test_one_qubit_no_operation(self): circuit = QuantumCircuit(qr, cr) circuit.measure(qr[0], cr[0]) - qobj = compile(circuit, self._remote_backend) + qobj = transpile(circuit, backend=self._remote_backend) result_remote = self._remote_backend.run(qobj).result() result_local = self._local_backend.run(qobj).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit), @@ -79,7 +79,7 @@ def test_one_qubit_operation(self): circuit.x(qr[0]) circuit.measure(qr[0], cr[0]) - qobj = compile(circuit, self._remote_backend) + qobj = transpile(circuit, backend=self._remote_backend) result_remote = self._remote_backend.run(qobj).result() result_local = self._local_backend.run(qobj).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit), @@ -99,7 +99,7 @@ def test_simple_circuit(self): circuit.measure(qr[2], cr[2]) circuit.measure(qr[3], cr[3]) - qobj = compile(circuit, self._remote_backend) + qobj = transpile(circuit, backend=self._remote_backend) result_remote = self._remote_backend.run(qobj).result() result_local = self._local_backend.run(qobj).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit), @@ -120,8 +120,8 @@ def test_readout_order(self): circuit.measure(qr[2], cr[1]) circuit.measure(qr[3], cr[3]) - qobj_remote = compile(circuit, self._remote_backend) - qobj_local = compile(circuit, self._local_backend) + qobj_remote = transpile(circuit, backend=self._remote_backend) + qobj_local = transpile(circuit, backend=self._local_backend) result_remote = self._remote_backend.run(qobj_remote).result() result_local = self._local_backend.run(qobj_local).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit), @@ -148,7 +148,7 @@ def test_multi_register(self): circuit.measure(qr2[0], cr1[2]) circuit.measure(qr2[1], cr1[1]) - qobj = compile(circuit, self._remote_backend) + qobj = transpile(circuit, backend=self._remote_backend) result_remote = self._remote_backend.run(qobj).result() result_local = self._local_backend.run(qobj).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit), @@ -184,7 +184,7 @@ def test_multi_circuit(self): circuit2.measure(qr1[0], cr1[2]) circuit2.measure(qr2[1], cr1[2]) - qobj = compile([circuit1, circuit2], self._remote_backend) + qobj = transpile([circuit1, circuit2], backend=self._remote_backend) result_remote = self._remote_backend.run(qobj).result() result_local = self._local_backend.run(qobj).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit1), @@ -204,7 +204,7 @@ def test_conditional_operation(self): circuit.measure(qr[0], cr[0]) circuit.x(qr[0]).c_if(cr, 1) - qobj = compile(circuit, self._remote_backend) + qobj = transpile(circuit, backend=self._remote_backend) result_remote = self._remote_backend.run(qobj).result() result_local = self._local_backend.run(qobj).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit), @@ -221,7 +221,7 @@ def test_atlantic_circuit(self): circuit.ry(pi, qr[2]) circuit.measure(qr, cr) - qobj = compile(circuit, self._remote_backend) + qobj = transpile(circuit, backend=self._remote_backend) result_remote = self._remote_backend.run(qobj).result() result_local = self._local_backend.run(qobj).result() self.assertDictAlmostEqual(result_remote.get_counts(circuit), From 3c70b285637b22d91ea4561cd855011f6777f548 Mon Sep 17 00:00:00 2001 From: "Jack J. Woehr" Date: Tue, 7 May 2019 00:41:18 -0600 Subject: [PATCH 2/4] make pylint happy hopefully --- test/ibmq/test_ibmq_job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ibmq/test_ibmq_job.py b/test/ibmq/test_ibmq_job.py index 6d1cc8ae8..02b51be79 100644 --- a/test/ibmq/test_ibmq_job.py +++ b/test/ibmq/test_ibmq_job.py @@ -59,7 +59,7 @@ def test_run_simulator(self, qe_token, qe_url): counts_qx2 = result.get_counts(1) counts_ex1 = {'00': shots / 2, '11': shots / 2} counts_ex2 = {'00': shots / 4, '11': shots - / 4, '10': shots / 4, '01': shots / 4} + / 4, '10': shots / 4, '01': shots / 4} states1 = counts_qx1.keys() | counts_ex1.keys() states2 = counts_qx2.keys() | counts_ex2.keys() # contingency table From 880e9f61c64e7d514b7f368b132a22464fed225b Mon Sep 17 00:00:00 2001 From: "Jack J. Woehr" Date: Tue, 7 May 2019 00:44:24 -0600 Subject: [PATCH 3/4] maybe *this* will make pylint happy. --- test/ibmq/test_ibmq_job.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/ibmq/test_ibmq_job.py b/test/ibmq/test_ibmq_job.py index 02b51be79..2b986d185 100644 --- a/test/ibmq/test_ibmq_job.py +++ b/test/ibmq/test_ibmq_job.py @@ -58,8 +58,7 @@ def test_run_simulator(self, qe_token, qe_url): counts_qx1 = result.get_counts(0) counts_qx2 = result.get_counts(1) counts_ex1 = {'00': shots / 2, '11': shots / 2} - counts_ex2 = {'00': shots / 4, '11': shots - / 4, '10': shots / 4, '01': shots / 4} + counts_ex2 = {'00': shots / 4, '11': shots / 4, '10': shots / 4, '01': shots / 4} states1 = counts_qx1.keys() | counts_ex1.keys() states2 = counts_qx2.keys() | counts_ex2.keys() # contingency table From afe1258274aa9642c49b5c9ce3fd49760a686e76 Mon Sep 17 00:00:00 2001 From: "Diego M. Rodriguez" Date: Tue, 7 May 2019 12:12:18 +0200 Subject: [PATCH 4/4] Mark header test as expected failure --- test/ibmq/test_ibmq_backends.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/ibmq/test_ibmq_backends.py b/test/ibmq/test_ibmq_backends.py index 99dcb9474..a2b6b23c1 100644 --- a/test/ibmq/test_ibmq_backends.py +++ b/test/ibmq/test_ibmq_backends.py @@ -15,7 +15,7 @@ """Tests for all IBMQ backends.""" -from unittest import skip +from unittest import skip, expectedFailure from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister from qiskit.providers.exceptions import QiskitBackendNotFoundError @@ -92,6 +92,7 @@ def test_remote_backend_defaults(self, qe_token, qe_url): for backend in remotes: _ = backend.defaults() + @expectedFailure @requires_qe_access def test_qobj_headers_in_result_sims(self, qe_token, qe_url): """Test that the qobj headers are passed onto the results for sims.""" @@ -106,6 +107,7 @@ def test_qobj_headers_in_result_sims(self, qe_token, qe_url): # Update the Qobj header. qobj_header = QobjHeader.from_dict(custom_qobj_header) + # TODO: assemble appends extra keys to the header in terra 0.8. qobj = assemble(circuits, backend=backend, qobj_header=qobj_header) qobj.experiments[0].header.some_field = 'extra info'