def test_from_backend_and_user(self): """Test from_backend() with a backend and user options. `FakeMelbourne` is used in this testcase. This backend does not have `defaults` attribute and thus not provide an instruction schedule map. """ qr = QuantumRegister(4, "qr") initial_layout = [None, qr[0], qr[1], qr[2], None, qr[3]] backend = FakeMelbourne() config = PassManagerConfig.from_backend(backend, basis_gates=["user_gate"], initial_layout=initial_layout) self.assertEqual(config.basis_gates, ["user_gate"]) self.assertNotEqual(config.basis_gates, backend.configuration().basis_gates) self.assertIsNone(config.inst_map) self.assertEqual( str(config.coupling_map), str(CouplingMap(backend.configuration().coupling_map))) self.assertEqual(config.initial_layout, initial_layout)
have been written to the property set. """ def __init__(self, properties): self.properties = properties def run(self, dag): dag_depth = self.property_set['my depth'] gates = self.properties.gates return dag """ To test your passes you can use the fake backend classes. Your solutions will be tested against Yorktown, Ourense and Melbourne, as well as some internal backends. """ backend = FakeMelbourne() properties = backend.properties() coupling_map = backend.configuration().coupling_map """ You must submit a pass manager which uses at least one pass you have written. Examples of creating more complex pass managers can be seen in qiskit.transpiler.preset_passmanagers""" pass_manager = PassManager() pass_manager.append(TrivialLayout(coupling_map)) pass_manager.append(MyBasicAnalysisPass()) pass_manager.append(MyBasicTransformationPass(properties)) """ This allows us to simulate the noise a real device has, so that you don't have to wait for jobs to complete on the actual backends.""" noise_model = basic_device_noise_model(properties) simulator = Aer.get_backend('qasm_simulator') """ This is the circuit we are going to look at""" qc = QuantumCircuit(2, 2) qc.h(1) qc.measure(0, 0) circuits = [qc]
from qiskit.providers.aer.noise import NoiseModel from qiskit.test.mock import FakeMelbourne backend = FakeMelbourne() coupling_map = backend.configuration().coupling_map basis_gates = backend.configuration().basis_gates noise_model = NoiseModel.from_backend(backend)
def time_ibmq_backend_transpile(self, _, __): # Run with ibmq_16_melbourne configuration backend = FakeMelbourne() transpile(self.circuit, basis_gates=['u1', 'u2', 'u3', 'cx', 'id'], coupling_map=backend.configuration().coupling_map)