Path 1: 88 calls (0.58)

Console (88)

ConsoleOptions (88)

[5, 41, 5, 7] (12) [8, 25] (10) [6] (7) [22, 17, 5] (7) [3, 3] (6) [22, 17, 5, 10] (5) [14, 1] (4) [10] (4) [10, 24] (4) [10, 40] (3)

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths
            

Path 2: 28 calls (0.18)

Console (28)

ConsoleOptions (28)

[20, 9, 92, 19] (11) [20, 9, 93, 18] (4) [7, 59, 14] (3) [50, 50] (2) [43, 43] (2) [43, 42] (2) [5, 75] (1) [5, 35] (1) [20] (1) [23, 6] (1)

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths
            

Path 3: 13 calls (0.09)

Console (13)

ConsoleOptions (13)

[8, 40, 5, 7] (2) [14, 86] (1) [29, 71] (1) [25, 25, 25, 25] (1) [29, 57] (1) [22, 21, 22, 21] (1) [14, 34, 19, 16] (1) [29, 56] (1) [21, 21, 21, 22] ...

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths
            

Path 4: 11 calls (0.07)

Console (11)

ConsoleOptions (11)

[17, 0, 0, 0] (3) [6, 0, 0] (1) [11, 0, 0] (1) [16, 0, 0] (1) [21, 0, 0] (1) [22, 2, 2] (1) [22, 5, 4] (1) [22, 9, 5] (1) [22, 14, 5] (1)

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths
            

Path 5: 5 calls (0.03)

Console (5)

ConsoleOptions (5)

[15, 14] (1) [28, 22, 6] (1) [23, 18, 5] (1) [26, 20, 5] (1) [25, 19, 4, 9] (1)

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths
            

Path 6: 4 calls (0.03)

Console (4)

ConsoleOptions (4)

[30, 0, 30, 0] (3) [40, 0, 40, 0] (1)

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths
            

Path 7: 2 calls (0.01)

Console (2)

ConsoleOptions (2)

[28] (2)

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths
            

Path 8: 1 calls (0.01)

Console (1)

ConsoleOptions (1)

[10, 9, 0, 0] (1)

1def _calculate_column_widths(
2        self, console: "Console", options: "ConsoleOptions"
3    ) -> List[int]:
4        """Calculate the widths of each column, including padding, not including borders."""
5        max_width = options.max_width
6        columns = self.columns
7        width_ranges = [
8            self._measure_column(console, options, column) for column in columns
9        ]
10        widths = [_range.maximum or 1 for _range in width_ranges]
11        get_padding_width = self._get_padding_width
12        extra_width = self._extra_width
13        if self.expand:
14            ratios = [col.ratio or 0 for col in columns if col.flexible]
15            if any(ratios):
16                fixed_widths = [
17                    0 if column.flexible else _range.maximum
18                    for _range, column in zip(width_ranges, columns)
19                ]
20                flex_minimum = [
21                    (column.width or 1) + get_padding_width(column._index)
22                    for column in columns
23                    if column.flexible
24                ]
25                flexible_width = max_width - sum(fixed_widths)
26                flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
27                iter_flex_widths = iter(flex_widths)
28                for index, column in enumerate(columns):
29                    if column.flexible:
30                        widths[index] = fixed_widths[index] + next(iter_flex_widths)
31        table_width = sum(widths)
32
33        if table_width > max_width:
34            widths = self._collapse_widths(
35                widths,
36                [(column.width is None and not column.no_wrap) for column in columns],
37                max_width,
38            )
39            table_width = sum(widths)
40            # last resort, reduce columns evenly
41            if table_width > max_width:
42                excess_width = table_width - max_width
43                widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
44                table_width = sum(widths)
45
46            width_ranges = [
47                self._measure_column(console, options.update_width(width), column)
48                for width, column in zip(widths, columns)
49            ]
50            widths = [_range.maximum or 0 for _range in width_ranges]
51
52        if (table_width < max_width and self.expand) or (
53            self.min_width is not None and table_width < (self.min_width - extra_width)
54        ):
55            _max_width = (
56                max_width
57                if self.min_width is None
58                else min(self.min_width - extra_width, max_width)
59            )
60            pad_widths = ratio_distribute(_max_width - table_width, widths)
61            widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
62
63        return widths