Helper to create column of row ids for printing
763735
function makeRowIds(numRows, maxLines) {
  var printVec = jd.seq(numRows)._toTruncatedPrintVector(maxLines);
  return printVec.map(function(str) {
    return str === _SKIP_MARKER ? str : str + _ROW_ID_SUFFIX;
  });
}
167606
def print_row(self, **kwargs):
        '''
        
        '''
        meta_string = '|'
        for key in self.column_names:
            float_specifier = ''
            if isinstance(kwargs[key], float):
                float_specifier = '.3f'
            meta_string += " {%s:<{width}%s}|" % (key, float_specifier)
        kwargs['width'] = self.column_width - 1

        print(meta_string.format(**kwargs))
        print(self.hr)
897987
def _idx_col2rowm(d):
    """"""
    if 0 == len(d):
        return 1
    if 1 == len(d):
        return np.arange(d[0])
    # order='F' indicates column-major ordering
    idx = np.array(np.arange(np.prod(d))).reshape(d, order='F').T
    return idx.flatten(order='F')
210261
def pprint_cell(self, row, col):
        
        if col > 2:
            raise Exception("Only two columns available in a ItemTable.")
        elif row >= self.rows:
            raise Exception("Maximum row index is %d" % self.rows-1)
        elif col == 0:
            return self.dimensions('value')[row].pprint_label
        else:
            dim = self.get_dimension(row)
            heading = self.vdims[row]
            return dim.pprint_value(self.data.get(heading.name, np.NaN))
806635
def row_factory(cursor, row):
    """"""
    d = {}
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d
588505
def table_repr(columns, rows, data, padding=2):
    """"""
    padding = ' ' * padding
    column_lengths = [len(column) for column in columns]
    for row in rows:
        for i, column in enumerate(columns):
            item = str(data[row][column])
            column_lengths[i] = max(len(item), column_lengths[i])
    max_row_length = max(len(row) for row in rows) if len(rows) else 0
    table_row = ' ' * max_row_length
    for i, column in enumerate(columns):
        table_row += padding + column.rjust(column_lengths[i])
    table_rows = [table_row]
    for row in rows:
        table_row = row.rjust(max_row_length)
        for i, column in enumerate(columns):
            item = str(data[row][column])
            table_row += padding + item.rjust(column_lengths[i])
        table_rows.append(table_row)
    return '\n'.join(table_rows)
23591
def print_results_adj(results, indent=False, prt=sys.stdout):
        """"""
        # Print column headers if there are results to be printed
        if results:
            prt.write("{R}\n".format(R="\t".join(GOEnrichmentStudy.get_prtflds_default(results))))
        # Print the GOEA results
        for rec in results:
            prt.write("{R}\n".format(R=rec.__str__(indent=indent)))
496649
def printDeadCells(self):
    
    columnCasualties = numpy.zeros(self.numberOfColumns())
    for cell in self.deadCells:
      col = self.columnForCell(cell)
      columnCasualties[col] += 1
    for col in range(self.numberOfColumns()):
      print col, columnCasualties[col]
288944
def print(self):
        
        print(tabulate(
            ((i, *row) for i, row in enumerate(self.results, 1)),
            headers=self.headers,
        ))
51211
def set_rows(self, ids):
        """"""
        # NOTE: make sure we have integers and not np.generic objects.
        assert all(isinstance(i, int) for i in ids)

        # Determine the sort column and dir to set after the rows.
        sort_col, sort_dir = self.current_sort
        default_sort_col, default_sort_dir = self.default_sort

        sort_col = sort_col or default_sort_col
        sort_dir = sort_dir or default_sort_dir or 'desc'

        # Set the rows.
        logger.log(5, "Set %d rows in the table.", len(ids))
        items = [self._get_row(id) for id in ids]
        # Sort the rows before passing them to the widget.
        # if sort_col:
        #     items = sorted(items, key=itemgetter(sort_col),
        #                    reverse=(sort_dir == 'desc'))
        data = _create_json_dict(items=items,
                                 cols=self.column_names,
                                 )
        self.eval_js('table.setData({});'.format(data))

        # Sort.
        if sort_col:
            self.sort_by(sort_col, sort_dir)
17198
def pprint2columns(llist, max_length=60):
    
    if len(llist) == 0:
        return None

    col_width = max(len(word) for word in llist) + 2  # padding

    # llist length must be even, otherwise splitting fails
    if not len(llist) % 2 == 0:
        llist += [' ']  # add a fake element

    if col_width > max_length:
        for el in llist:
            print(el)
    else:
        column1 = llist[:int(len(llist) / 2)]
        column2 = llist[int(len(llist) / 2):]
        for c1, c2 in zip(column1, column2):
            space = " " * (col_width - len(c1))
            print("%s%s%s" % (c1, space, c2))
1173127
def pretty_print(rows, keyword, domain):
    
    if isinstance(rows, dict):
        pretty_print_domain(rows, keyword, domain)
    elif isinstance(rows, list):
        pretty_print_zones(rows)
1118607
def _print_table(rows, header=True):
    
    border = "="
    # vertical delimiter
    vdelim = " | "
    # padding nr. of spaces are left around the longest element in the
    # column
    padding = 1
    # may be left,center,right
    justify = 'right'
    justify = {'left'   : str.ljust,
               'center' : str.center,
               'right'  : str.rjust}[justify.lower()]
    # calculate column widths (longest item in each col
    # plus "padding" nr of spaces on both sides)
    cols = zip(*rows)
    colWidths = [max([len(str(item))+2*padding for item in col]) for col in cols]
    borderline = vdelim.join([w*border for w in colWidths])
    for row in rows:
        print(vdelim.join([justify(str(item),width) for (item,width) in zip(row,colWidths)]))
        if header:
            print(borderline)
            header=False
978489
def print_table(graph, tails, node_id_map):
    """"""
    node_count = len(tails)

    # Get the width of the table columns
    num_col_width = max(
        floor(log(max(get_heights(tails)), 10)) + 1,
        len("NUM"))
    node_col_width = max(
        floor(log(node_count, 10)) + 1,
        8)

    # Construct the output format string
    format_str = ''
    format_str += '{:<' + str(num_col_width) + '} '
    for _ in range(node_count):
        format_str += '{:<' + str(node_col_width) + '} '

    nodes_header = ["NODE " + str(node_id_map[i]) for i in range(node_count)]
    header = format_str.format("NUM", *nodes_header)
    print(header)
    print('-' * len(header))

    prev_block_num = -1
    node_list = [''] * node_count
    for block_num, _, siblings in graph.walk():
        if block_num != prev_block_num:
            # Need to skip the first one
            if prev_block_num != -1:
                print(format_str.format(prev_block_num, *node_list))

            node_list.clear()
            node_list.extend([''] * node_count)
            prev_block_num = block_num

        for block_id, node_ids in siblings.items():
            for node_id in node_ids:
                node_list[node_id] = block_id[:8]

    # Print the last one
    print(format_str.format(prev_block_num, *node_list))
413083
def print_table(rows, override_headers=None, uppercase_headers=True):
    """"""
    if len(rows) == 0:
        return
    keys = list(rows[0].keys())
    headers = override_headers or keys
    if uppercase_headers:
        rows = [dict(zip(keys,
                         map(lambda x: x.upper(), headers))), None] + rows
    else:
        rows = [dict(zip(keys, headers)), None] + rows

    lengths = [max(len(str(row[k]))
                   for row in rows if hasattr(row, '__iter__')) for k in keys]
    tmp = ['{%s:%i}' % (h, l) for h, l in zip(keys[: -1], lengths[: -1])]
    tmp.append('{%s}' % keys[-1])
    template = (' ' * 4).join(tmp)

    for row in rows:
        if type(row) == str:
            print(row)
        elif row is None:
            print()
        elif isinstance(row, dict): 
            row = {k: v if v is not None else 'None' for k, v in row.items()}
            print(template.format(**row))
        else:
            print("Unhandled row type:", row)
120278
def pprint_cell(self, row, col):
        
        ndims = self.ndims
        if col >= self.cols:
            raise Exception("Maximum column index is %d" % self.cols-1)
        elif row >= self.rows:
            raise Exception("Maximum row index is %d" % self.rows-1)
        elif row == 0:
            if col >= ndims:
                if self.vdims:
                    return self.vdims[col - ndims].pprint_label
                else:
                    return ''
            return self.kdims[col].pprint_label
        else:
            dim = self.get_dimension(col)
            return dim.pprint_value(self.iloc[row-1, col])
866032
def __print_table(table):
        """"""

        col_width = [max(len(x) for x in col) for col in zip(*table)]
        print("| " + " | ".join("{:{}}".format(x, col_width[i])
                                for i, x in enumerate(table[0])) + " |")
        print("| " + " | ".join("{:{}}".format('-' * col_width[i], col_width[i])
                                for i, x in enumerate(table[0])) + " |")
        for line in table[1:]:
            print("| " + " | ".join("{:{}}".format(x, col_width[i])
                                    for i, x in enumerate(line)) + " |")