def test_defaults(self): """Test backend defaults.""" fake_backend = ConfigurableFakeBackend("Tashkent", n_qubits=10) defaults = fake_backend.defaults() self.assertEqual(len(defaults.cmd_def), 54) self.assertEqual(len(defaults.meas_freq_est), 10) self.assertEqual(len(defaults.qubit_freq_est), 10)
def test_with_coupling_map(self): """Test backend generation with coupling map.""" target_coupling_map = [[0, 1], [1, 2], [2, 3]] fake_backend = ConfigurableFakeBackend( "Tashkent", n_qubits=4, coupling_map=target_coupling_map ) cmd_def = fake_backend.defaults().cmd_def configured_cmap = fake_backend.configuration().coupling_map controlled_not_qubits = [cmd.qubits for cmd in cmd_def if cmd.name == "cx"] self.assertEqual(controlled_not_qubits, target_coupling_map) self.assertEqual(configured_cmap, target_coupling_map)
def test_measure_all(self): """Test utility function - measure.""" with pulse.build(self.backend) as schedule: regs = pulse.measure_all() self.assertEqual(regs, [pulse.MemorySlot(0), pulse.MemorySlot(1)]) reference = macros.measure_all(self.backend) self.assertEqual(schedule, reference) backend_100q = ConfigurableBackend('100q', 100) with pulse.build(backend_100q) as schedule: regs = pulse.measure_all() reference = backend_100q.defaults().instruction_schedule_map.\ get('measure', list(range(100))) self.assertEqual(schedule, reference)