Example #1
0
    def test_gen_snapshot_name(self):
        """Test gen_snapshot_name."""
        snap_inst = pulse.instructions.Snapshot(label='test_snapshot',
                                                snapshot_type='statevector')
        inst_data = types.SnapshotInstruction(5, 0.1, snap_inst)

        obj = snapshot.gen_snapshot_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.channels.SnapshotChannel()])
        self.assertEqual(obj.text, 'test_snapshot')

        # style check
        ref_style = {
            'zorder': self.formatter['layer.snapshot'],
            'color': self.formatter['color.snapshot'],
            'size': self.formatter['text_size.annotate'],
            'va': 'center',
            'ha': 'center'
        }
        self.assertDictEqual(obj.styles, ref_style)
Example #2
0
    def test_gen_snapshot_name(self):
        """Test gen_snapshot_name."""
        snap_inst = pulse.instructions.Snapshot(label="test_snapshot",
                                                snapshot_type="statevector")
        inst_data = types.SnapshotInstruction(5, 0.1, snap_inst)

        obj = snapshot.gen_snapshot_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.channels.SnapshotChannel()])
        self.assertEqual(obj.text, "test_snapshot")

        # style check
        ref_style = {
            "zorder": self.formatter["layer.snapshot"],
            "color": self.formatter["color.snapshot"],
            "size": self.formatter["text_size.annotate"],
            "va": "center",
            "ha": "center",
        }
        self.assertDictEqual(obj.styles, ref_style)
Example #3
0
    def gen_snapshot_symbol(self):
        """Test gen_snapshot_symbol."""
        snap_inst = pulse.instructions.Snapshot(label='test_snapshot',
                                                snapshot_type='statevector')
        inst_data = types.SnapshotInstruction(5, 0.1, snap_inst)

        obj = snapshot.gen_snapshot_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.channels.SnapshotChannel()])
        self.assertEqual(obj.text, self.formatter['unicode_symbol.snapshot'])
        self.assertEqual(obj.latex, self.formatter['latex_symbol.snapshot'])

        # metadata check
        ref_meta = {'snapshot type': 'statevector',
                    't0 (cycle time)': 5,
                    't0 (sec)': 0.5,
                    'name': 'test_snapshot',
                    'label': 'test_snapshot'}
        self.assertDictEqual(obj.meta, ref_meta)

        # style check
        ref_style = {'zorder': self.formatter['layer.snapshot'],
                     'color': self.formatter['color.snapshot'],
                     'size': self.formatter['text_size.snapshot'],
                     'va': 'bottom',
                     'ha': 'center'}
        self.assertDictEqual(obj.styles, ref_style)
Example #4
0
    def gen_snapshot_symbol(self):
        """Test gen_snapshot_symbol."""
        snap_inst = pulse.instructions.Snapshot(label="test_snapshot",
                                                snapshot_type="statevector")
        inst_data = types.SnapshotInstruction(5, 0.1, snap_inst)

        obj = snapshot.gen_snapshot_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.channels.SnapshotChannel()])
        self.assertEqual(obj.text, self.formatter["unicode_symbol.snapshot"])
        self.assertEqual(obj.latex, self.formatter["latex_symbol.snapshot"])

        # metadata check
        ref_meta = {
            "snapshot type": "statevector",
            "t0 (cycle time)": 5,
            "t0 (sec)": 0.5,
            "name": "test_snapshot",
            "label": "test_snapshot",
        }
        self.assertDictEqual(obj.meta, ref_meta)

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