How to use the tabulate.LATEX_ESCAPE_RULES function in tabulate

To help you get started, we’ve selected a few tabulate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TQRG / physalia / physalia / analytics.py View on Github external
mean = np.mean(sample)
        row = OrderedDict((
            ("N", len(sample)),
            ("$\\bar{{x}}$ ({})".format(unit), mean),
            ("$s$", np.std(sample)),
        ))
        if loop_count:
            #row["Iter."] = loop_count
            row["Single ({})".format(unit)] = mean/loop_count
        if show_ranking:
            row["Rank"] = int(ranking[index]+1)
            if row["Rank"] == 1 and table_fmt == 'latex':
                names[index] = "\\textbf{"+names[index]+"}"
        table.append(row)
    old_escape_rules = T.LATEX_ESCAPE_RULES
    T.LATEX_ESCAPE_RULES = {}
    out.write(T.tabulate(
        table,
        headers='keys', showindex=names,
        tablefmt=table_fmt, floatfmt=float_fmt
    ))
    T.LATEX_ESCAPE_RULES = old_escape_rules
    out.write("\n")
    return table
github TQRG / physalia / physalia / analytics.py View on Github external
for index, sample in enumerate(consumption_samples):
        mean = np.mean(sample)
        row = OrderedDict((
            ("N", len(sample)),
            ("$\\bar{{x}}$ ({})".format(unit), mean),
            ("$s$", np.std(sample)),
        ))
        if loop_count:
            #row["Iter."] = loop_count
            row["Single ({})".format(unit)] = mean/loop_count
        if show_ranking:
            row["Rank"] = int(ranking[index]+1)
            if row["Rank"] == 1 and table_fmt == 'latex':
                names[index] = "\\textbf{"+names[index]+"}"
        table.append(row)
    old_escape_rules = T.LATEX_ESCAPE_RULES
    T.LATEX_ESCAPE_RULES = {}
    out.write(T.tabulate(
        table,
        headers='keys', showindex=names,
        tablefmt=table_fmt, floatfmt=float_fmt
    ))
    T.LATEX_ESCAPE_RULES = old_escape_rules
    out.write("\n")
    return table
github TQRG / physalia / physalia / analytics.py View on Github external
if loop_count:
            #row["Iter."] = loop_count
            row["Single ({})".format(unit)] = mean/loop_count
        if show_ranking:
            row["Rank"] = int(ranking[index]+1)
            if row["Rank"] == 1 and table_fmt == 'latex':
                names[index] = "\\textbf{"+names[index]+"}"
        table.append(row)
    old_escape_rules = T.LATEX_ESCAPE_RULES
    T.LATEX_ESCAPE_RULES = {}
    out.write(T.tabulate(
        table,
        headers='keys', showindex=names,
        tablefmt=table_fmt, floatfmt=float_fmt
    ))
    T.LATEX_ESCAPE_RULES = old_escape_rules
    out.write("\n")
    return table
github IncOQ / incoq / experiments / view_stats.py View on Github external
def latexrow_with_rowfunc(rowfunc):
    """Return a version of tabulate._latex_row() that dispatches to
    a custom function in place of tabulate._build_simple_row().
    """
    from tabulate import LATEX_ESCAPE_RULES, DataRow
    my_escape_rules = dict(LATEX_ESCAPE_RULES)
    del my_escape_rules['~']
    
    def _latex_row(cell_values, colwidths, colaligns):
        """Version of tabulate._latex_row() that dispatches to a local
        hook instead of tabulate()._build_simple_row().
        """
        def escape_char(c):
            return my_escape_rules.get(c, c)
        escaped_values = ["".join(map(escape_char, cell))
                          for cell in cell_values]
        rowfmt = DataRow("", "&", "\\\\")
        return rowfunc(escaped_values, rowfmt)
    
    return _latex_row