def test_sequenced_parameterized_schedule(self): """Test parametrized schedule consists of multiple instruction. """ converter = QobjToInstructionConverter([], buffer=0) qobjs = [ PulseQobjInstruction(name='fc', ch='d0', t0=10, phase='P1'), PulseQobjInstruction(name='fc', ch='d0', t0=20, phase='P2'), PulseQobjInstruction(name='fc', ch='d0', t0=30, phase='P3') ] converted_instruction = [converter(qobj) for qobj in qobjs] inst_map = InstructionScheduleMap() inst_map.add( 'inst_seq', 0, ParameterizedSchedule(*converted_instruction, name='inst_seq')) with self.assertRaises(PulseError): inst_map.get('inst_seq', 0, P1=1, P2=2, P3=3, P4=4, P5=5) with self.assertRaises(PulseError): inst_map.get('inst_seq', 0, P1=1) with self.assertRaises(PulseError): inst_map.get('inst_seq', 0, 1, 2, 3, P1=1) p3_expr = Parameter('p3') p3_expr = p3_expr.bind({p3_expr: 3}) sched = inst_map.get('inst_seq', 0, 1, 2, p3_expr) self.assertEqual(sched.instructions[0][-1].phase, 1) self.assertEqual(sched.instructions[1][-1].phase, 2) self.assertEqual(sched.instructions[2][-1].phase, 3) sched = inst_map.get('inst_seq', 0, P1=1, P2=2, P3=p3_expr) self.assertEqual(sched.instructions[0][-1].phase, 1) self.assertEqual(sched.instructions[1][-1].phase, 2) self.assertEqual(sched.instructions[2][-1].phase, 3) sched = inst_map.get('inst_seq', 0, 1, 2, P3=p3_expr) self.assertEqual(sched.instructions[0][-1].phase, 1) self.assertEqual(sched.instructions[1][-1].phase, 2) self.assertEqual(sched.instructions[2][-1].phase, 3)
def test_sequenced_parameterized_schedule(self): """Test parameterized schedule consists of multiple instruction.""" converter = QobjToInstructionConverter([], buffer=0) qobjs = [ PulseQobjInstruction(name="fc", ch="d0", t0=10, phase="P1"), PulseQobjInstruction(name="fc", ch="d0", t0=20, phase="P2"), PulseQobjInstruction(name="fc", ch="d0", t0=30, phase="P3"), ] converted_instruction = [converter(qobj) for qobj in qobjs] inst_map = InstructionScheduleMap() inst_map.add("inst_seq", 0, Schedule(*converted_instruction, name="inst_seq")) with self.assertRaises(PulseError): inst_map.get("inst_seq", 0, P1=1, P2=2, P3=3, P4=4, P5=5) with self.assertRaises(PulseError): inst_map.get("inst_seq", 0, 1, 2, 3, 4, 5, 6, 7, 8) p3_expr = Parameter("p3") p3_expr = p3_expr.bind({p3_expr: 3}) sched = inst_map.get("inst_seq", 0, 1, 2, p3_expr) self.assertEqual(sched.instructions[0][-1].phase, 1) self.assertEqual(sched.instructions[1][-1].phase, 2) self.assertEqual(sched.instructions[2][-1].phase, 3) sched = inst_map.get("inst_seq", 0, P1=1, P2=2, P3=p3_expr) self.assertEqual(sched.instructions[0][-1].phase, 1) self.assertEqual(sched.instructions[1][-1].phase, 2) self.assertEqual(sched.instructions[2][-1].phase, 3) sched = inst_map.get("inst_seq", 0, 1, 2, P3=p3_expr) self.assertEqual(sched.instructions[0][-1].phase, 1) self.assertEqual(sched.instructions[1][-1].phase, 2) self.assertEqual(sched.instructions[2][-1].phase, 3)