From 6260442412f7a015ae2074a8559f4f4995859af7 Mon Sep 17 00:00:00 2001 From: "Christopher J. Wood" Date: Fri, 26 Apr 2019 12:43:12 -0400 Subject: [PATCH] update failing tests for changes in terra api (#179) * Update failing tests for changes in Terra API --- qiskit/providers/aer/noise/errors/errorutils.py | 2 +- test/terra/backends/qasm_simulator/qasm_basics.py | 7 +++---- test/terra/backends/test_statevector_simulator.py | 7 +++---- test/terra/utils/mock.py | 8 +++++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/qiskit/providers/aer/noise/errors/errorutils.py b/qiskit/providers/aer/noise/errors/errorutils.py index b0c035316b..ef680ebe81 100644 --- a/qiskit/providers/aer/noise/errors/errorutils.py +++ b/qiskit/providers/aer/noise/errors/errorutils.py @@ -428,7 +428,7 @@ def circuit2superop(circuit, min_qubits=1): qubits = instr.qubits else: qubits = instr['qubits'] - superop = superop.compose(instr_op, qubits=qubits) + superop = superop.compose(instr_op, qubits) return superop diff --git a/test/terra/backends/qasm_simulator/qasm_basics.py b/test/terra/backends/qasm_simulator/qasm_basics.py index 2c1547cfaf..c8a5d7194c 100644 --- a/test/terra/backends/qasm_simulator/qasm_basics.py +++ b/test/terra/backends/qasm_simulator/qasm_basics.py @@ -9,8 +9,7 @@ """ from test.terra.utils.mock import FakeFailureQasmSimulator, FakeSuccessQasmSimulator from qiskit.transpiler import transpile -from qiskit.compiler import assemble_circuits -from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit +from qiskit import assemble, QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit.providers.aer import AerError @@ -24,7 +23,7 @@ def test_simulation_succeed(self): cr = ClassicalRegister(1) succeed_circuit = QuantumCircuit(qr, cr) quantum_circuit = transpile(succeed_circuit, mocked_backend) - qobj = assemble_circuits(quantum_circuit) + qobj = assemble(quantum_circuit) result = mocked_backend.run(qobj).result() self.is_completed(result) @@ -36,6 +35,6 @@ def test_simulation_failed(self): cr = ClassicalRegister(1) failed_circuit = QuantumCircuit(qr, cr) quantum_circuit = transpile(failed_circuit, mocked_backend) - qobj = assemble_circuits(quantum_circuit) + qobj = assemble(quantum_circuit) job = mocked_backend.run(qobj) self.assertRaises(AerError, job.result) diff --git a/test/terra/backends/test_statevector_simulator.py b/test/terra/backends/test_statevector_simulator.py index bb84014b1d..65e04e3afe 100644 --- a/test/terra/backends/test_statevector_simulator.py +++ b/test/terra/backends/test_statevector_simulator.py @@ -20,8 +20,7 @@ from test.terra.reference import ref_non_clifford from test.terra.reference import ref_unitary_gate -from qiskit import execute -from qiskit.compiler import assemble_circuits, RunConfig +from qiskit import execute, assemble from qiskit.providers.aer import StatevectorSimulator @@ -35,7 +34,7 @@ def test_initialize_1(self): """Test StatevectorSimulator initialize""" circuits = ref_initialize.initialize_circuits_1(final_measure=False) targets = ref_initialize.initialize_statevector_1() - qobj = assemble_circuits(circuits, run_config=RunConfig(shots=1)) + qobj = assemble(circuits, shots=1) sim_job = StatevectorSimulator().run(qobj) result = sim_job.result() self.is_completed(result) @@ -45,7 +44,7 @@ def test_initialize_2(self): """Test StatevectorSimulator initialize""" circuits = ref_initialize.initialize_circuits_2(final_measure=False) targets = ref_initialize.initialize_statevector_2() - qobj = assemble_circuits(circuits, run_config=RunConfig(shots=1)) + qobj = assemble(circuits, shots=1) sim_job = StatevectorSimulator().run(qobj) result = sim_job.result() self.is_completed(result) diff --git a/test/terra/utils/mock.py b/test/terra/utils/mock.py index 11db8370b7..36295803ab 100644 --- a/test/terra/utils/mock.py +++ b/test/terra/utils/mock.py @@ -17,6 +17,7 @@ The mock devices are mainly for testing the compiler. """ +import datetime import uuid import logging from concurrent import futures @@ -79,15 +80,16 @@ def __init__(self, configuration, time_alive=10): def properties(self): """Return backend properties""" + dummy_date = datetime.datetime.now().isoformat() properties = { 'backend_name': self.name(), 'backend_version': self.configuration().backend_version, - 'last_update_date': '2000-01-01 00:00:00Z', - 'qubits': [[{'name': 'TODO', 'date': '2000-01-01 00:00:00Z', + 'last_update_date': dummy_date, + 'qubits': [[{'name': 'TODO', 'date': dummy_date, 'unit': 'TODO', 'value': 0}]], 'gates': [{'qubits': [0], 'gate': 'TODO', 'parameters': - [{'name': 'TODO', 'date': '2000-01-01 00:00:00Z', + [{'name': 'TODO', 'date': dummy_date, 'unit': 'TODO', 'value': 0}]}], 'general': [] }