IPython 8.4.0 Pypi GitHub Homepage
Other Docs
ParametersReturns
compute_item_matrix(items, row_first=False, empty=None, *args, **kwargs)

Parameters

items :

list of strings to columize

row_first : (default False)

Whether to compute columns for a row-first matrix instead of column-first (default).

empty : (default None)

default value to fill list if needed

separator_size : int (default=2)

How much characters will be used as a separation between each columns.

displaywidth : int (default=80)

The width of the area onto which the columns should enter

Returns

strings_matrix

nested list of string, the outer most list contains as many list as rows, the innermost lists have each as many element as columns. If the total number of elements in :None:None:`items` does not equal the product of rows*columns, the last element of some lists are filled with :None:None:`None`.

dict_info

some info to make columnize easier:

num_columns

number of columns

max_rows

maximum number of rows (final number may be less)

column_widths

list of with of each columns

optimal_separator_width

best separator width between columns

Returns a nested list, and info to columnize items

Examples

In [1]: l = ['aaa','b','cc','d','eeeee','f','g','h','i','j','k','l'] In [2]: list, info = compute_item_matrix(l, displaywidth=12) In [3]: list Out[3]: [['aaa', 'f', 'k'], ['b', 'g', 'l'], ['cc', 'h', None], ['d', 'i', None], ['eeeee', 'j', None]] In [4]: ideal = {'num_columns': 3, 'column_widths': [5, 1, 1], 'optimal_separator_width': 2, 'max_rows': 5} In [5]: all((info[k] == ideal[k] for k in ideal.keys())) Out[5]: True

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /IPython/utils/text.py#637
type: <class 'function'>
Commit: