Example #1
0
    def test_display_display_columns_a(self):

        config_columns_8 = sf.DisplayConfig.from_default(display_columns=8,
                                                         type_color=False)
        config_columns_5 = sf.DisplayConfig.from_default(display_columns=5,
                                                         type_color=False)

        columns = list(''.join(x)
                       for x in combinations(string.ascii_lowercase, 2))
        f = FrameGO(index=range(4))
        for i, col in enumerate(columns):
            f[col] = Series(i, index=range(4))

        self.assertEqual(
            f.display(config_columns_8).to_rows(), [
                '<FrameGO>',
                '<IndexGO> ab      ac      ... xz      yz      <<U2>',
                '<Index>                   ...',
                '0         0       1       ... 323     324',
                '1         0       1       ... 323     324',
                '2         0       1       ... 323     324',
                '3         0       1       ... 323     324',
                '<int64>   <int64> <int64> ... <int64> <int64>'
            ])

        self.assertEqual(
            f.display(config_columns_5).to_rows(), [
                '<FrameGO>', '<IndexGO> ab      ... yz      <<U2>',
                '<Index>           ...', '0         0       ... 324',
                '1         0       ... 324', '2         0       ... 324',
                '3         0       ... 324', '<int64>   <int64> ... <int64>'
            ])
Example #2
0
    def test_display_cell_fill_width_a(self) -> None:

        config_width_12 = sf.DisplayConfig.from_default(
            cell_max_width=12, cell_max_width_leftmost=12, type_color=False)
        config_width_6 = sf.DisplayConfig.from_default(
            cell_max_width=6, cell_max_width_leftmost=6, type_color=False)

        def chunks(size: int, count: int) -> tp.Iterator[str]:
            pos = 0
            for _ in range(count):
                yield LONG_SAMPLE_STR[pos:pos + size]
                pos = pos + size

        s = Series(chunks(20, 3), index=('a', 'b', 'c'))

        self.assertEqual(
            s.display(config=config_width_12).to_rows(), [
                '<Series>', '<Index>', 'a        Lorem ips...',
                'b        t amet, c...', 'c        adipiscin...',
                '<<U1>    <<U20>'
            ])

        self.assertEqual(
            s.display(config=config_width_6).to_rows(), [
                '<Se...', '<In...', 'a      Lor...', 'b      t a...',
                'c      adi...', '<<U1>  <<U20>'
            ])

        config = sf.DisplayConfig.from_default(type_color=False,
                                               cell_max_width_leftmost=20)

        row_count = 2
        index = [str(chr(x)) for x in range(97, 97 + row_count)]
        f = FrameGO(index=index)

        for i in range(4):
            chunker = iter(chunks(10, row_count))
            s = Series((x for x in chunker), index=index)
            f[i] = s

        f.columns._update_array_cache()

        self.assertEqual(
            f.display(config=config).to_rows(), [
                '<FrameGO>',
                '<IndexGO> 0          1          2          3          <int64>',
                '<Index>',
                'a         Lorem ipsu Lorem ipsu Lorem ipsu Lorem ipsu',
                'b         m dolor si m dolor si m dolor si m dolor si',
                '<<U1>     <<U10>     <<U10>     <<U10>     <<U10>'
            ])

        self.assertEqual(
            f.display(config=config_width_6).to_rows(), [
                '<Fr...', '<In... 0      1      2      3      <in...',
                '<In...', 'a      Lor... Lor... Lor... Lor...',
                'b      m d... m d... m d... m d...',
                '<<U1>  <<U10> <<U10> <<U10> <<U10>'
            ])