return a dictionary of {col -> width}
185039
def _get_column_widths(self):
        """"""
        col_widths = {}
        for table, (row, col) in self.__tables.values():
            for colname, width in table.column_widths.items():
                ic = col + table.get_column_offset(colname)
                current_width = col_widths.setdefault(ic, width)
                col_widths[ic] = max(width, current_width)
        return col_widths
521192
def _raw_dimensions(self):
        """"""
        return tuple(
            _RawDimension(dimension_dict, self._dimension_dicts)
            for dimension_dict in self._dimension_dicts
        )
1296307
def shape(self):
        ""
        num = len(self)
        if num <= self._max_cols:
            return (1, num)
        nrows = num // self._max_cols
        last_row_cols = num % self._max_cols
        return nrows+(1 if last_row_cols else 0), min(num, self._max_cols)
698287
def to_dict(self):
        ''''''
        return {'x': self.x,
                'y': self.y,
                'height': self.height,
                'width': self.width,
                'direction': dir.to_string(self.direction)}
679132
def get_col_width(self, col, tab):
        """"""

        try:
            return self.col_widths[(col, tab)]

        except KeyError:
            return config["default_col_width"]
1094528
def rank_width(self):
        
        rank_width = defaultdict(int)
        node_rank = self.node_rank()
        for rank in node_rank.values():
            rank_width[rank] += 1
        return dict(rank_width)
1320043
def justify_token(tok, col_width):
    
    get_len = tools.display_len if PY3 else len
    tok_len = get_len(tok)
    diff_len = tok_len - len(tok) if PY3 else 0

    cols = (int(math.ceil(float(tok_len) / col_width))
            if col_width < tok_len + 4 else 1)

    if cols > 1:
        return tok.ljust((col_width * cols) + (4 * cols) - diff_len)
    else:
        return tok.ljust(col_width + 4 - diff_len)
414381
def get_widths(self, estimation):
        
        widths = estimation[self.map_offset[1]:self.map_offset[2]]\
            .reshape(self.K, 1)
        return widths
548272
def fits_recarray_to_dict(table):
    """"""

    cols = {}
    for icol, col in enumerate(table.columns.names):

        col_data = table.data[col]
        if type(col_data[0]) == np.float32:
            cols[col] = np.array(col_data, dtype=float)
        elif type(col_data[0]) == np.float64:
            cols[col] = np.array(col_data, dtype=float)
        elif type(col_data[0]) == str:
            cols[col] = np.array(col_data, dtype=str)
        elif type(col_data[0]) == np.string_:
            cols[col] = np.array(col_data, dtype=str)
        elif type(col_data[0]) == np.int16:
            cols[col] = np.array(col_data, dtype=int)
        elif type(col_data[0]) == np.ndarray:
            cols[col] = np.array(col_data)
        else:
            raise Exception(
                'Unrecognized column type: %s %s' % (col, str(type(col_data))))

    return cols
577980
def get_dimensions(self):
        """"""
        return FrozenOrderedDict((k, len(v)) for k, v in self.ds.dimensions.items())
144573
def guess_width(self):
        """"""
        if len(self.header) <= 4:
            nspace = 6
        elif len(self.header) <= 6:
            nspace = 5
        else:
            nspace = 4
        ncol = len(self.header)
        self._width = [nspace] * ncol
        width = [0] * ncol

        # set initial width from header
        for idx, item in enumerate(self.header):
            width[idx] = len(str(item))

        # guess width of each column from first 10 lines of data
        samples = min(len(self.data), 10)
        for col in range(ncol):
            for idx in range(samples):
                data = self.data[idx][col]
                if not isinstance(data, (float, int)):
                    temp = len(data)
                else:
                    temp = 10
                if temp > width[col]:
                    width[col] = temp

        for col in range(ncol):
            self._width[col] += width[col]
805112
def _label_columns_json(self, cols=None):
        
        ret = {}
        cols = cols or []
        d = {k: v for (k, v) in self.label_columns.items() if k in cols}
        for key, value in d.items():
            ret[key] = as_unicode(_(value).encode("UTF-8"))
        return ret
1285162
def columnise(rows, padding=2):
    """"""
    strs = []
    maxwidths = {}

    for row in rows:
        for i, e in enumerate(row):
            se = str(e)
            nse = len(se)
            w = maxwidths.get(i, -1)
            if nse > w:
                maxwidths[i] = nse

    for row in rows:
        s = ''
        for i, e in enumerate(row):
            se = str(e)
            if i < len(row) - 1:
                n = maxwidths[i] + padding - len(se)
                se += ' ' * n
            s += se
        strs.append(s)
    return strs
373100
def _get_column_width(self, complete_state):
        
        return max(get_cwidth(c.display) for c in complete_state.current_completions) + 1
256933
def get_columns (fp):
    """"""
    if not is_tty(fp):
        return 80
    if os.name == 'nt':
        return colorama.get_console_size().X
    if has_curses:
        import curses
        try:
            curses.setupterm(os.environ.get("TERM"), fp.fileno())
            return curses.tigetnum("cols")
        except curses.error:
           pass
    return 80
860432
public int[] colWidths() {
        int cols = columnCount();
        int[] widths = new int[cols];

        for (int i = 0; i < columnCount(); i++) {
            widths[i] = columns().get(i).columnWidth();
        }
        return widths;
    }
52739
def _xls2col_widths(self, worksheet, tab):
        """"""

        for col in xrange(worksheet.ncols):
            try:
                xls_width = worksheet.colinfo_map[col].width
                pys_width = self.xls_width2pys_width(xls_width)
                self.code_array.col_widths[col, tab] = pys_width

            except KeyError:
                pass