Example #1
0
 def test_overlapping_on_expression_assigment_to_zero(self):
     """Test constant*zero expression conflict."""
     schedule = pulse.Schedule()
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(self.qubit))
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(2*self.qubit))
     with self.assertRaises(PulseError):
         schedule.assign_parameters({self.qubit: 0})
Example #2
0
    def test_assemble_sample_pulse(self):
        """Test that the pulse lib and qobj instruction can be paired up."""
        schedule = pulse.Schedule()
        schedule += pulse.Play(pulse.Waveform([0.1]*16, name='test0'),
                               pulse.DriveChannel(0),
                               name='test1')
        schedule += pulse.Play(pulse.SamplePulse([0.1]*16, name='test1'),
                               pulse.DriveChannel(0),
                               name='test2')
        schedule += pulse.Play(pulse.Waveform([0.5]*16, name='test0'),
                               pulse.DriveChannel(0),
                               name='test1')
        qobj = assemble(schedule,
                        qobj_header=self.header,
                        qubit_lo_freq=self.default_qubit_lo_freq,
                        meas_lo_freq=self.default_meas_lo_freq,
                        schedule_los=[],
                        **self.config)
        validate_qobj_against_schema(qobj)

        test_dict = qobj.to_dict()
        experiment = test_dict['experiments'][0]
        inst0_name = experiment['instructions'][0]['name']
        inst1_name = experiment['instructions'][1]['name']
        inst2_name = experiment['instructions'][2]['name']
        pulses = {}
        for item in test_dict['config']['pulse_library']:
            pulses[item['name']] = item['samples']
        self.assertTrue(all(name in pulses for name in [inst0_name, inst1_name, inst2_name]))
        # Their pulses are the same
        self.assertEqual(inst0_name, inst1_name)
        self.assertTrue(np.allclose(pulses[inst0_name], [0.1]*16))
        self.assertTrue(np.allclose(pulses[inst2_name], [0.5]*16))
Example #3
0
 def test_overlapping_on_assignment(self):
     """Test that assignment will catch against existing instructions."""
     schedule = pulse.Schedule()
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(1))
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(self.qubit))
     with self.assertRaises(PulseError):
         schedule.assign_parameters({self.qubit: 1})
Example #4
0
 def test_overlapping_pulses(self):
     """Test that an error is still raised when overlapping instructions are assigned."""
     schedule = pulse.Schedule()
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(self.qubit))
     with self.assertRaises(PulseError):
         schedule |= pulse.Play(pulse.Waveform([0.5, 0.5, 0.5, 0.5]),
                                DriveChannel(self.qubit))
Example #5
0
 def test_overlapping_on_multiple_assignment(self):
     """Test that assigning one qubit then another raises error when overlapping."""
     qubit2 = Parameter('q2')
     schedule = pulse.Schedule()
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(self.qubit))
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(qubit2))
     schedule.assign_parameters({qubit2: 2})
     with self.assertRaises(PulseError):
         schedule.assign_parameters({self.qubit: 2})
Example #6
0
 def test_merging_upon_assignment(self):
     """Test that schedule can match instructions on a channel."""
     schedule = pulse.Schedule()
     schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(1))
     schedule = schedule.insert(4, pulse.Play(pulse.Waveform([1, 1, 1, 1]),
                                              DriveChannel(self.qubit)))
     schedule.assign_parameters({self.qubit: 1})
     self.assertEqual(schedule.ch_duration(DriveChannel(1)), 8)
     self.assertEqual(schedule.channels, (DriveChannel(1),))
    def test_overlapping_on_multiple_assignment(self):
        """Test that assigning one qubit then another raises error when overlapping."""
        param_idx1 = Parameter("q1")
        param_idx2 = Parameter("q2")

        schedule = pulse.Schedule()
        schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]),
                               pulse.DriveChannel(param_idx1))
        schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]),
                               pulse.DriveChannel(param_idx2))
        schedule.assign_parameters({param_idx1: 2})

        with self.assertRaises(PulseError):
            schedule.assign_parameters({param_idx2: 2})
Example #8
0
    def setUp(self):
        self.backend = FakeOpenPulse2Q()
        self.backend_config = self.backend.configuration()

        test_pulse = pulse.Waveform(
            samples=np.array([0.02739068, 0.05, 0.05, 0.05, 0.02739068], dtype=np.complex128),
            name='pulse0'
        )

        self.schedule = pulse.Schedule(name='fake_experiment')
        self.schedule = self.schedule.insert(0, Play(test_pulse, self.backend_config.drive(0)))
        for i in range(self.backend_config.n_qubits):
            self.schedule = self.schedule.insert(5, Acquire(5,
                                                            self.backend_config.acquire(i),
                                                            MemorySlot(i)))

        self.user_lo_config_dict = {self.backend_config.drive(0): 4.91e9}
        self.user_lo_config = pulse.LoConfig(self.user_lo_config_dict)

        self.default_qubit_lo_freq = [4.9e9, 5.0e9]
        self.default_meas_lo_freq = [6.5e9, 6.6e9]

        self.config = {
            'meas_level': 1,
            'memory_slot_size': 100,
            'meas_return': 'avg'
        }

        self.header = {
            'backend_name': 'FakeOpenPulse2Q',
            'backend_version': '0.0.0'
        }
Example #9
0
    def test_gen_iqx_latex_waveform_name_x90(self):
        """Test gen_iqx_latex_waveform_name with x90 waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0],
                                   name="X90p_d0_1234567")
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, 0, 0, 0, 0.1)

        obj = waveform.gen_ibmq_latex_waveform_name(inst_data,
                                                    formatter=self.formatter,
                                                    device=self.device)[0]

        # type check
        self.assertEqual(type(obj), drawings.TextData)

        # data check
        self.assertListEqual(obj.channels, [pulse.DriveChannel(0)])
        self.assertEqual(obj.text, "X90p_d0_1234567")
        self.assertEqual(obj.latex, r"{\rm X}(\pi/2)")

        # style check
        ref_style = {
            "zorder": self.formatter["layer.annotate"],
            "color": self.formatter["color.annotate"],
            "size": self.formatter["text_size.annotate"],
            "va": "center",
            "ha": "center",
        }
        self.assertDictEqual(obj.styles, ref_style)
Example #10
0
 def setUp(self):
     self.backend = FakeOpenPulse2Q()
     self.config = self.backend.configuration()
     self.inst_map = self.backend.defaults().instruction_schedule_map
     self.short_pulse = pulse.Waveform(samples=np.array(
         [0.02739068], dtype=np.complex128),
                                       name='p0')
Example #11
0
    def test_gen_iqx_latex_waveform_name_x90(self):
        """Test gen_iqx_latex_waveform_name with x90 waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0],
                                   name='X90p_d0_1234567')
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = self.create_instruction(play, 0, 0, 0, 0.1)

        obj = generators.gen_iqx_latex_waveform_name(inst_data)[0]

        # type check
        self.assertEqual(type(obj), drawing_objects.TextData)

        # data check
        self.assertEqual(obj.channel, pulse.DriveChannel(0))
        self.assertEqual(obj.text, 'X90p_d0_1234567')
        self.assertEqual(obj.latex, r'{\rm X}(\frac{\pi}{2})')

        # style check
        ref_style = {
            'zorder': self.style['formatter.layer.annotate'],
            'color': self.style['formatter.color.annotate'],
            'size': self.style['formatter.text_size.annotate'],
            'va': 'center',
            'ha': 'center'
        }
        self.assertDictEqual(obj.styles, ref_style)
Example #12
0
    def test_gen_iqx_latex_waveform_name_x90(self):
        """Test gen_iqx_latex_waveform_name with x90 waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0],
                                   name='X90p_d0_1234567')
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, 0, 0, 0, 0.1)

        obj = waveform.gen_ibmq_latex_waveform_name(inst_data,
                                                    formatter=self.formatter,
                                                    device=self.device)[0]

        # type check
        self.assertEqual(type(obj), drawings.TextData)

        # data check
        self.assertListEqual(obj.channels, [pulse.DriveChannel(0)])
        self.assertEqual(obj.text, 'X90p_d0_1234567')
        self.assertEqual(obj.latex, r'{\rm X}(\pi/2)')

        # style check
        ref_style = {
            'zorder': self.formatter['layer.annotate'],
            'color': self.formatter['color.annotate'],
            'size': self.formatter['text_size.annotate'],
            'va': 'center',
            'ha': 'center'
        }
        self.assertDictEqual(obj.styles, ref_style)
Example #13
0
 def setUp(self):
     self.backend = FakeOpenPulse2Q()
     self.config = self.backend.configuration()
     self.short_pulse = pulse.Waveform(samples=np.array([0.02739068], dtype=np.complex128),
                                       name='p0')
     sched = pulse.Schedule(name='fake_experiment')
     sched = sched.insert(0, Play(self.short_pulse, self.config.drive(0)))
     sched = sched.insert(5, Acquire(5, self.config.acquire(0), MemorySlot(0)))
     sched = sched.insert(5, Acquire(5, self.config.acquire(1), MemorySlot(1)))
     self.sched = sched
Example #14
0
    def setUp(self) -> None:
        super().setUp()
        self.style = stylesheet.QiskitPulseStyle()
        self.device = device_info.OpenPulseBackendInfo(
            name="test",
            dt=1,
            channel_frequency_map={
                pulse.DriveChannel(0): 5.0,
                pulse.MeasureChannel(0): 7.0,
                pulse.ControlChannel(0): 5.0,
            },
            qubit_channel_map={
                0: [
                    pulse.DriveChannel(0),
                    pulse.MeasureChannel(0),
                    pulse.AcquireChannel(0),
                    pulse.ControlChannel(0),
                ]
            },
        )

        self.sched = pulse.Schedule()
        self.sched.insert(
            0,
            pulse.Play(pulse.Waveform([0.0, 0.1, 0.2, 0.3, 0.4, 0.5]),
                       pulse.DriveChannel(0)),
            inplace=True,
        )
        self.sched.insert(
            10,
            pulse.Play(pulse.Waveform([0.5, 0.4, 0.3, 0.2, 0.1, 0.0]),
                       pulse.DriveChannel(0)),
            inplace=True,
        )
        self.sched.insert(
            0,
            pulse.Play(pulse.Waveform([0.3, 0.3, 0.3, 0.3, 0.3, 0.3]),
                       pulse.DriveChannel(1)),
            inplace=True,
        )
Example #15
0
    def test_play_array_pulse(self):
        """Test play instruction on an array directly."""
        d0 = pulse.DriveChannel(0)
        test_array = np.array([0., 0.], dtype=np.complex_)

        with pulse.build() as schedule:
            pulse.play(test_array, d0)

        reference = pulse.Schedule()
        test_pulse = pulse.Waveform(test_array)
        reference += instructions.Play(test_pulse, d0)

        self.assertEqual(schedule, reference)
Example #16
0
    def test_gen_iqx_latex_waveform_name_x180(self):
        """Test gen_iqx_latex_waveform_name with x180 waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0], name='Xp_d0_1234567')
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = self.create_instruction(play, 0, 0, 0, 0.1)

        obj = generators.gen_iqx_latex_waveform_name(inst_data)[0]

        # type check
        self.assertEqual(type(obj), drawing_objects.TextData)

        # data check
        self.assertEqual(obj.channel, pulse.DriveChannel(0))
        self.assertEqual(obj.text, 'Xp_d0_1234567')
        self.assertEqual(obj.latex, r'{\rm X}(\pi)')
Example #17
0
    def test_gen_iqx_latex_waveform_name_compensation_tone(self):
        """Test gen_iqx_latex_waveform_name with CR compensation waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0], name='CR90p_d0_u0_1234567')
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = self.create_instruction(play, 0, 0, 0, 0.1)

        obj = generators.gen_iqx_latex_waveform_name(inst_data)[0]

        # type check
        self.assertEqual(type(obj), drawing_objects.TextData)

        # data check
        self.assertEqual(obj.channel, pulse.DriveChannel(0))
        self.assertEqual(obj.text, 'CR90p_d0_u0_1234567')
        self.assertEqual(obj.latex, r'\overline{\rm CR}(\frac{\pi}{4})')
Example #18
0
    def test_gen_filled_waveform_stepwise_play(self):
        """Test gen_filled_waveform_stepwise with play instruction."""
        my_pulse = pulse.Waveform(samples=[0, 0.5 + 0.5j, 0.5 + 0.5j, 0],
                                  name='my_pulse')
        play = pulse.Play(my_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, np.pi / 2, 5e9, 5, 0.1)

        objs = waveform.gen_filled_waveform_stepwise(inst_data,
                                                     formatter=self.formatter,
                                                     device=self.device)

        self.assertEqual(len(objs), 2)

        # type check
        self.assertEqual(type(objs[0]), drawings.LineData)
        self.assertEqual(type(objs[1]), drawings.LineData)

        y_ref = np.array([0, 0, -0.5, -0.5, 0, 0])

        # data check
        self.assertListEqual(objs[0].channels, [pulse.DriveChannel(0)])
        self.assertListEqual(list(objs[0].xvals), [5, 6, 6, 8, 8, 9])
        np.testing.assert_array_almost_equal(objs[0].yvals, y_ref)

        # meta data check
        ref_meta = {
            'duration (cycle time)': 4,
            'duration (sec)': 0.4,
            't0 (cycle time)': 5,
            't0 (sec)': 0.5,
            'phase': np.pi / 2,
            'frequency': 5e9,
            'qubit': 0,
            'name': 'my_pulse',
            'data': 'real'
        }
        self.assertDictEqual(objs[0].meta, ref_meta)

        # style check
        ref_style = {
            'alpha': self.formatter['alpha.fill_waveform'],
            'zorder': self.formatter['layer.fill_waveform'],
            'linewidth': self.formatter['line_width.fill_waveform'],
            'linestyle': self.formatter['line_style.fill_waveform'],
            'color': self.formatter['color.waveforms']['D'][0]
        }
        self.assertDictEqual(objs[0].styles, ref_style)
Example #19
0
    def test_gen_filled_waveform_stepwise_play(self):
        """Test gen_filled_waveform_stepwise with play instruction."""
        my_pulse = pulse.Waveform(samples=[0, 0.5 + 0.5j, 0.5 + 0.5j, 0],
                                  name="my_pulse")
        play = pulse.Play(my_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, np.pi / 2, 5e9, 5, 0.1)

        objs = waveform.gen_filled_waveform_stepwise(inst_data,
                                                     formatter=self.formatter,
                                                     device=self.device)

        self.assertEqual(len(objs), 2)

        # type check
        self.assertEqual(type(objs[0]), drawings.LineData)
        self.assertEqual(type(objs[1]), drawings.LineData)

        y_ref = np.array([0, 0, -0.5, -0.5, 0, 0])

        # data check
        self.assertListEqual(objs[0].channels, [pulse.DriveChannel(0)])
        self.assertListEqual(list(objs[0].xvals), [5, 6, 6, 8, 8, 9])
        np.testing.assert_array_almost_equal(objs[0].yvals, y_ref)

        # meta data check
        ref_meta = {
            "duration (cycle time)": 4,
            "duration (sec)": 0.4,
            "t0 (cycle time)": 5,
            "t0 (sec)": 0.5,
            "phase": np.pi / 2,
            "frequency": 5e9,
            "qubit": 0,
            "name": "my_pulse",
            "data": "real",
        }
        self.assertDictEqual(objs[0].meta, ref_meta)

        # style check
        ref_style = {
            "alpha": self.formatter["alpha.fill_waveform"],
            "zorder": self.formatter["layer.fill_waveform"],
            "linewidth": self.formatter["line_width.fill_waveform"],
            "linestyle": self.formatter["line_style.fill_waveform"],
            "color": self.formatter["color.waveforms"]["D"][0],
        }
        self.assertDictEqual(objs[0].styles, ref_style)
Example #20
0
    def test_gen_iqx_latex_waveform_name_x180(self):
        """Test gen_iqx_latex_waveform_name with x180 waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0], name='Xp_d0_1234567')
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, 0, 0, 0, 0.1)

        obj = waveform.gen_ibmq_latex_waveform_name(inst_data,
                                                    formatter=self.formatter,
                                                    device=self.device)[0]

        # type check
        self.assertEqual(type(obj), drawings.TextData)

        # data check
        self.assertListEqual(obj.channels, [pulse.DriveChannel(0)])
        self.assertEqual(obj.text, 'Xp_d0_1234567')
        self.assertEqual(obj.latex, r'{\rm X}(\pi)')
Example #21
0
    def test_gen_iqx_latex_waveform_name_cr(self):
        """Test gen_iqx_latex_waveform_name with CR waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0], name='CR90p_u0_1234567')
        play = pulse.Play(iqx_pulse, pulse.ControlChannel(0))
        inst_data = create_instruction(play, 0, 0, 0, 0.1)

        obj = waveform.gen_ibmq_latex_waveform_name(inst_data,
                                                    formatter=self.formatter,
                                                    device=self.device)[0]

        # type check
        self.assertEqual(type(obj), drawing_objects.TextData)

        # data check
        self.assertListEqual(obj.channels, [pulse.ControlChannel(0)])
        self.assertEqual(obj.text, 'CR90p_u0_1234567')
        self.assertEqual(obj.latex, r'{\rm CR}(\frac{\pi}{4})')
Example #22
0
    def test_gen_filled_waveform_stepwise_play(self):
        """Test gen_filled_waveform_stepwise with play instruction."""
        my_pulse = pulse.Waveform(samples=[0, 0.5 + 0.5j, 0.5 + 0.5j, 0],
                                  name='my_pulse')
        play = pulse.Play(my_pulse, pulse.DriveChannel(0))
        inst_data = self.create_instruction(play, np.pi / 2, 5e9, 5, 0.1)
        objs = generators.gen_filled_waveform_stepwise(inst_data)

        self.assertEqual(len(objs), 2)

        # type check
        self.assertEqual(type(objs[0]), drawing_objects.FilledAreaData)
        self.assertEqual(type(objs[1]), drawing_objects.FilledAreaData)

        y1_ref = np.array([0, 0, -0.5, -0.5, -0.5, -0.5, 0, 0])
        y2_ref = np.array([0, 0, 0, 0, 0, 0, 0, 0])

        # data check
        self.assertEqual(objs[0].channel, pulse.DriveChannel(0))
        self.assertListEqual(list(objs[0].x), [5, 6, 6, 7, 7, 8, 8, 9])
        np.testing.assert_array_almost_equal(objs[0].y1, y1_ref)
        np.testing.assert_array_almost_equal(objs[0].y2, y2_ref)

        # meta data check
        ref_meta = {
            'duration (cycle time)': 4,
            'duration (sec)': 0.4,
            't0 (cycle time)': 5,
            't0 (sec)': 0.5,
            'phase': np.pi / 2,
            'frequency': 5e9,
            'name': 'my_pulse',
            'data': 'real'
        }
        self.assertDictEqual(objs[0].meta, ref_meta)

        # style check
        ref_style = {
            'alpha': self.style['formatter.alpha.fill_waveform'],
            'zorder': self.style['formatter.layer.fill_waveform'],
            'linewidth': self.style['formatter.line_width.fill_waveform'],
            'linestyle': self.style['formatter.line_style.fill_waveform'],
            'color': self.style['formatter.color.fill_waveform_d'][0]
        }
        self.assertDictEqual(objs[0].styles, ref_style)
Example #23
0
    def test_gen_iqx_latex_waveform_name_compensation_tone(self):
        """Test gen_iqx_latex_waveform_name with CR compensation waveform."""
        iqx_pulse = pulse.Waveform(samples=[0, 0, 0, 0],
                                   name="CR90p_d0_u0_1234567")
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, 0, 0, 0, 0.1)

        obj = waveform.gen_ibmq_latex_waveform_name(inst_data,
                                                    formatter=self.formatter,
                                                    device=self.device)[0]

        # type check
        self.assertEqual(type(obj), drawings.TextData)

        # data check
        self.assertListEqual(obj.channels, [pulse.DriveChannel(0)])
        self.assertEqual(obj.text, "CR90p_d0_u0_1234567")
        self.assertEqual(obj.latex, r"\overline{\rm CR}(\pi/4)")
    def test_pulse_name_conflicts(self):
        """Test that pulse name conflicts can be resolved."""
        name_conflict_pulse = pulse.Waveform(samples=np.array(
            [0.02, 0.05, 0.05, 0.05, 0.02], dtype=np.complex128),
                                             name='pulse0')

        self.schedule = self.schedule.insert(
            1, Play(name_conflict_pulse, self.backend_config.drive(1)))

        qobj = assemble(self.schedule,
                        qobj_header=self.header,
                        qubit_lo_freq=self.default_qubit_lo_freq,
                        meas_lo_freq=self.default_meas_lo_freq,
                        schedule_los=[],
                        **self.config)
        validate_qobj_against_schema(qobj)

        self.assertNotEqual(qobj.config.pulse_library[0].name,
                            qobj.config.pulse_library[1].name)
Example #25
0
    def test_gen_waveform_max_value(self):
        """Test gen_waveform_max_value."""
        iqx_pulse = pulse.Waveform(samples=[0, 0.1, 0.3, -0.2j], name='test')
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, 0, 0, 0, 0.1)

        objs = waveform.gen_waveform_max_value(inst_data,
                                               formatter=self.formatter,
                                               device=self.device)

        # type check
        self.assertEqual(type(objs[0]), drawings.TextData)
        self.assertEqual(type(objs[1]), drawings.TextData)

        # data check, real part, positive max
        self.assertListEqual(objs[0].channels, [pulse.DriveChannel(0)])
        self.assertEqual(objs[0].text, u'0.30\n\u25BE')

        # style check
        ref_style = {
            'zorder': self.formatter['layer.annotate'],
            'color': self.formatter['color.annotate'],
            'size': self.formatter['text_size.annotate'],
            'va': 'bottom',
            'ha': 'center'
        }
        self.assertDictEqual(objs[0].styles, ref_style)

        # data check, imaginary part, negative max
        self.assertListEqual(objs[1].channels, [pulse.DriveChannel(0)])
        self.assertEqual(objs[1].text, u'\u25B4\n-0.20')

        # style check
        ref_style = {
            'zorder': self.formatter['layer.annotate'],
            'color': self.formatter['color.annotate'],
            'size': self.formatter['text_size.annotate'],
            'va': 'top',
            'ha': 'center'
        }
        self.assertDictEqual(objs[1].styles, ref_style)
Example #26
0
    def test_gen_waveform_max_value(self):
        """Test gen_waveform_max_value."""
        iqx_pulse = pulse.Waveform(samples=[0, 0.1, 0.3, -0.2j], name="test")
        play = pulse.Play(iqx_pulse, pulse.DriveChannel(0))
        inst_data = create_instruction(play, 0, 0, 0, 0.1)

        objs = waveform.gen_waveform_max_value(inst_data,
                                               formatter=self.formatter,
                                               device=self.device)

        # type check
        self.assertEqual(type(objs[0]), drawings.TextData)
        self.assertEqual(type(objs[1]), drawings.TextData)

        # data check, real part, positive max
        self.assertListEqual(objs[0].channels, [pulse.DriveChannel(0)])
        self.assertEqual(objs[0].text, "0.30\n\u25BE")

        # style check
        ref_style = {
            "zorder": self.formatter["layer.annotate"],
            "color": self.formatter["color.annotate"],
            "size": self.formatter["text_size.annotate"],
            "va": "bottom",
            "ha": "center",
        }
        self.assertDictEqual(objs[0].styles, ref_style)

        # data check, imaginary part, negative max
        self.assertListEqual(objs[1].channels, [pulse.DriveChannel(0)])
        self.assertEqual(objs[1].text, "\u25B4\n-0.20")

        # style check
        ref_style = {
            "zorder": self.formatter["layer.annotate"],
            "color": self.formatter["color.annotate"],
            "size": self.formatter["text_size.annotate"],
            "va": "top",
            "ha": "center",
        }
        self.assertDictEqual(objs[1].styles, ref_style)