Exemplo n.º 1
0
    def test_gen_formatted_phase(self):
        """Test gen_formatted_phase."""
        fcs = [
            pulse.ShiftPhase(np.pi / 2, pulse.DriveChannel(0)),
            pulse.ShiftFrequency(1e6, pulse.DriveChannel(0))
        ]
        inst_data = create_instruction(fcs, np.pi / 2, 1e6, 5, 0.1)

        obj = frame.gen_formatted_phase(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.latex, r'{\rm VZ}(-\pi/2)')
        self.assertEqual(obj.text, 'VZ(-pi/2)')

        # style check
        ref_style = {
            'zorder': self.formatter['layer.frame_change'],
            'color': self.formatter['color.frame_change'],
            'size': self.formatter['text_size.annotate'],
            'va': 'center',
            'ha': 'center'
        }
        self.assertDictEqual(obj.styles, ref_style)
Exemplo n.º 2
0
    def test_gen_formatted_phase(self):
        """Test gen_formatted_phase."""
        fcs = [
            pulse.ShiftPhase(np.pi / 2, pulse.DriveChannel(0)),
            pulse.ShiftFrequency(1e6, pulse.DriveChannel(0)),
        ]
        inst_data = create_instruction(fcs, np.pi / 2, 1e6, 5, 0.1)

        obj = frame.gen_formatted_phase(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.latex, r"{\rm VZ}(-\pi/2)")
        self.assertEqual(obj.text, "VZ(-pi/2)")

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