def test_assemble_memory_slots(self): """Test assembling a schedule and inferring number of memoryslots.""" n_memoryslots = 10 # single acquisition schedule = Acquire(5, self.backend_config.acquire(0), mem_slot=pulse.MemorySlot(n_memoryslots-1)) qobj = assemble(schedule, qubit_lo_freq=self.default_qubit_lo_freq, meas_lo_freq=self.default_meas_lo_freq, meas_map=[[0], [1]]) validate_qobj_against_schema(qobj) self.assertEqual(qobj.config.memory_slots, n_memoryslots) # this should be in experimental header as well self.assertEqual(qobj.experiments[0].header.memory_slots, n_memoryslots) # multiple acquisition schedule = Acquire(5, self.backend_config.acquire(0), mem_slot=pulse.MemorySlot(n_memoryslots-1)) schedule = schedule.insert(10, Acquire(5, self.backend_config.acquire(0), mem_slot=pulse.MemorySlot(n_memoryslots-1))) qobj = assemble(schedule, qubit_lo_freq=self.default_qubit_lo_freq, meas_lo_freq=self.default_meas_lo_freq, meas_map=[[0], [1]]) validate_qobj_against_schema(qobj) self.assertEqual(qobj.config.memory_slots, n_memoryslots) # this should be in experimental header as well self.assertEqual(qobj.experiments[0].header.memory_slots, n_memoryslots)
def test_keep_original_schedule_after_attached_to_another_schedule(self): """Test if a schedule keeps its children after attached to another schedule.""" children = Acquire(10, self.config.acquire(0), MemorySlot(0)).shift(20) + Acquire( 10, self.config.acquire(0), MemorySlot(0) ) self.assertEqual(2, len(list(children.instructions))) sched = Acquire(10, self.config.acquire(0), MemorySlot(0)).append(children) self.assertEqual(3, len(list(sched.instructions))) # add 2 instructions to children (2 instructions -> 4 instructions) children = children.append(Acquire(10, self.config.acquire(0), MemorySlot(0))) children = children.insert(100, Acquire(10, self.config.acquire(0), MemorySlot(0))) self.assertEqual(4, len(list(children.instructions))) # sched must keep 3 instructions (must not update to 5 instructions) self.assertEqual(3, len(list(sched.instructions)))