@@ -635,7 +635,7 @@ def _find_optimal(rlist, row_first=False, separator_size=2, displaywidth=80):
635635 if sumlength + separator_size * (ncols - 1 ) <= displaywidth :
636636 break
637637 return {'num_columns' : ncols ,
638- 'optimal_separator_width' : (displaywidth - sumlength ) / (ncols - 1 ) if (ncols - 1 ) else 0 ,
638+ 'optimal_separator_width' : (displaywidth - sumlength ) // (ncols - 1 ) if (ncols - 1 ) else 0 ,
639639 'max_rows' : max_rows ,
640640 'column_widths' : col_widths
641641 }
@@ -694,17 +694,12 @@ def compute_item_matrix(items, row_first=False, empty=None, *args, **kwargs) :
694694 ::
695695
696696 In [1]: l = ['aaa','b','cc','d','eeeee','f','g','h','i','j','k','l']
697- ...: compute_item_matrix(l, displaywidth=12)
698- Out[1]:
699- ([['aaa', 'f', 'k'],
700- ['b', 'g', 'l'],
701- ['cc', 'h', None],
702- ['d', 'i', None],
703- ['eeeee', 'j', None]],
704- {'num_columns': 3,
705- 'column_widths': [5, 1, 1],
706- 'optimal_separator_width': 2,
707- 'max_rows': 5})
697+ In [2]: list, info = compute_item_matrix(l, displaywidth=12)
698+ In [3]: list
699+ Out[3]: [['aaa', 'f', 'k'], ['b', 'g', 'l'], ['cc', 'h', None], ['d', 'i', None], ['eeeee', 'j', None]]
700+ In [4]: ideal = {'num_columns': 3, 'column_widths': [5, 1, 1], 'optimal_separator_width': 2, 'max_rows': 5}
701+ In [5]: all((info[k] == ideal[k] for k in ideal.keys()))
702+ Out[5]: True
708703 """
709704 info = _find_optimal (list (map (len , items )), row_first , * args , ** kwargs )
710705 nrow , ncol = info ['max_rows' ], info ['num_columns' ]
0 commit comments