Ejemplo n.º 1
0
def test_latexmap():
    ltt = LatexTable(data=[['alpha',10.123,20],['alpha_s',30,40]],
                     latex_map={'alpha':'beta'})
    assert_equal(
        ltt._format('alpha'),
        'beta'
        )
Ejemplo n.º 2
0
def test_table_color():
    ltt = LatexTable(data=[['alpha', 10.123], ['alpha_s', 30]])
    ltt.set_cell_color(0, 0, (111, 123, 95))
    assert_equal(
        str(ltt),
        '%\\usepackage[table]{xcolor} % include this for color\n%\\usepackage{rotating} % include this for rotate header\n%\\documentclass[xcolor=table]{beamer} % for beamer\n\\begin{tabular}{|c|c|}\n\\hline\n\\cellcolor[RGB]{111,123,95} $\\alpha$ &     10.123\\\\\n\\hline\n$\\alpha_{s}$ & 30\\\\\n\\hline\n\\end{tabular}'
    )
Ejemplo n.º 3
0
def test_format():
    ltt = LatexTable(data=[['alpha', 10.123, 20], ['alpha_s', 30, 40]],
                     smart_latex=False)
    assert ltt._format('a_b') == r'a\_b'
    ltt2 = LatexTable(data=[['alpha', 10.123, 20], ['alpha_s', 30, 40]],
                      smart_latex=False, escape_under_score=False)
    assert ltt2._format('a_b') == r'a_b'
Ejemplo n.º 4
0
def test_table_color():
    ltt = LatexTable(data=[["alpha", 10.123], ["alpha_s", 30]])
    ltt.set_cell_color(0, 0, (111, 123, 95))
    expected = """%\\usepackage[table]{xcolor} % include this for color
%\\usepackage{rotating} % include this for rotate header
%\\documentclass[xcolor=table]{beamer} % for beamer
\\begin{tabular}{|c|c|}
\\hline
\\cellcolor[RGB]{111,123,95} $\\alpha$ &     10.123\\\\
\\hline
$\\alpha_{s}$ & 30\\\\
\\hline
\\end{tabular}"""
    assert str(ltt) == expected
Ejemplo n.º 5
0
def test_smartlatex():
    ltt = LatexTable(data=[['alpha', 10.123, 20], ['alpha_s', 30, 40]])
    assert ltt._convert_smart_latex('alpha') == r'$\alpha$'
    assert ltt._convert_smart_latex('alpha_beta') == r'$\alpha_{\beta}$'
    assert ltt._convert_smart_latex('a_b') == r'$a_{b}$'
    assert ltt._convert_smart_latex('a_b_c') == r'a $b_{c}$'
    assert ltt._convert_smart_latex('a') == r'a'
    assert ltt._convert_smart_latex('a_alpha_beta') == r'a $\alpha_{\beta}$'
Ejemplo n.º 6
0
def test_smartlatex():
    ltt = LatexTable(data=[["alpha", 10.123, 20], ["alpha_s", 30, 40]])
    assert ltt._convert_smart_latex("alpha") == r"$\alpha$"
    assert ltt._convert_smart_latex("alpha_beta") == r"$\alpha_{\beta}$"
    assert ltt._convert_smart_latex("a_b") == r"$a_{b}$"
    assert ltt._convert_smart_latex("a_b_c") == r"a $b_{c}$"
    assert ltt._convert_smart_latex("a") == r"a"
    assert ltt._convert_smart_latex("a_alpha_beta") == r"a $\alpha_{\beta}$"
Ejemplo n.º 7
0
def test_empty_table_with_headers():
    ltt = LatexTable(data=[], headers=["Foo", "Bar"])
    expected = """\\begin{tabular}{|c|c|}
\\hline
Foo & Bar\\\\
\\hline
\\end{tabular}"""
    assert str(ltt) == expected
Ejemplo n.º 8
0
def test_empty_table():
    ltt = LatexTable(data=[])
    expected = '\n'.join([
        r'\begin{tabular}{|c|}',
        r'\hline',
        r'\end{tabular}',
    ])
    assert str(ltt) == expected
Ejemplo n.º 9
0
def test_smartlatex():
    ltt = LatexTable(data=[['alpha',10.123,20],['alpha_s',30,40]])
    assert_equal(
        ltt._convert_smart_latex('alpha'),
        r'$\alpha$'
        )
    assert_equal(
        ltt._convert_smart_latex('alpha_beta'),
        r'$\alpha_{\beta}$'
        )
    assert_equal(
        ltt._convert_smart_latex('a_b'),
        r'$a_{b}$'
        )
    assert_equal(
        ltt._convert_smart_latex('a_b_c'),
        r'a $b_{c}$'
        )
    assert_equal(
        ltt._convert_smart_latex('a'),
        r'a'
        )
    assert_equal(
        ltt._convert_smart_latex('a_alpha_beta'),
        r'a $\alpha_{\beta}$'
        )
Ejemplo n.º 10
0
def test_empty_table_with_headers():
    ltt = LatexTable(data=[], headers=['Foo', 'Bar'])
    expected = '\n'.join([
        r'\begin{tabular}{|c|c|}',
        r'\hline',
        r'Foo & Bar\\',
        r'\hline',
        r'\end{tabular}',
    ])
    assert str(ltt) == expected
Ejemplo n.º 11
0
def test_table():
    ltt = LatexTable(data=[["alpha", 10.123], ["alpha_s", 30]])
    expected = """\\begin{tabular}{|c|c|}
\\hline
$\\alpha$ &     10.123\\\\
\\hline
$\\alpha_{s}$ & 30\\\\
\\hline
\\end{tabular}"""
    assert str(ltt) == expected
Ejemplo n.º 12
0
def test_empty_table_with_headers():
    ltt = LatexTable(data=[], headers=["Foo", "Bar"])
    expected = "\n".join([
        r"\begin{tabular}{|c|c|}",
        r"\hline",
        r"Foo & Bar\\",
        r"\hline",
        r"\end{tabular}",
    ])
    assert str(ltt) == expected
Ejemplo n.º 13
0
def test_format():
    ltt = LatexTable(data=[['alpha', 10.123, 20], ['alpha_s', 30, 40]],
                     smart_latex=False)
    assert_equal(ltt._format('a_b'), r'a\_b')
    ltt2 = LatexTable(data=[['alpha', 10.123, 20], ['alpha_s', 30, 40]],
                      smart_latex=False,
                      escape_under_score=False)
    assert_equal(ltt2._format('a_b'), r'a_b')
Ejemplo n.º 14
0
def test_format():
    ltt = LatexTable(data=[["alpha", 10.123, 20], ["alpha_s", 30, 40]],
                     smart_latex=False)
    assert ltt._format("a_b") == r"a\_b"
    ltt2 = LatexTable(
        data=[["alpha", 10.123, 20], ["alpha_s", 30, 40]],
        smart_latex=False,
        escape_under_score=False,
    )
    assert ltt2._format("a_b") == r"a_b"
Ejemplo n.º 15
0
def test_latexmap():
    ltt = LatexTable(data=[["alpha", 10.123, 20], ["alpha_s", 30, 40]],
                     latex_map={"alpha": "beta"})
    assert ltt._format("alpha") == "beta"
Ejemplo n.º 16
0
def test_table_color():
    ltt = LatexTable(data=[['alpha', 10.123], ['alpha_s', 30]])
    ltt.set_cell_color(0, 0, (111, 123, 95))
    expected = '%\\usepackage[table]{xcolor} % include this for color\n%\\usepackage{rotating} % include this for rotate header\n%\\documentclass[xcolor=table]{beamer} % for beamer\n\\begin{tabular}{|c|c|}\n\\hline\n\\cellcolor[RGB]{111,123,95} $\\alpha$ &     10.123\\\\\n\\hline\n$\\alpha_{s}$ & 30\\\\\n\\hline\n\\end{tabular}'
    assert str(ltt) == expected
Ejemplo n.º 17
0
def test_table():
    ltt = LatexTable(data=[['alpha', 10.123], ['alpha_s', 30]])
    assert_equal(
        str(ltt),
        '\\begin{tabular}{|c|c|}\n\\hline\n$\\alpha$ &     10.123\\\\\n\\hline\n$\\alpha_{s}$ & 30\\\\\n\\hline\n\\end{tabular}'
    )
Ejemplo n.º 18
0
def test_latexmap():
    ltt = LatexTable(data=[['alpha', 10.123, 20], ['alpha_s', 30, 40]],
                     latex_map={'alpha': 'beta'})
    assert_equal(ltt._format('alpha'), 'beta')
Ejemplo n.º 19
0
def test_empty_table():
    ltt = LatexTable(data=[])
    expected = """\\begin{tabular}{|c|}
\\hline
\\end{tabular}"""
    assert str(ltt) == expected
Ejemplo n.º 20
0
def test_table():
    ltt = LatexTable(data=[['alpha', 10.123], ['alpha_s', 30]])
    expected = '\\begin{tabular}{|c|c|}\n\\hline\n$\\alpha$ &     10.123\\\\\n\\hline\n$\\alpha_{s}$ & 30\\\\\n\\hline\n\\end{tabular}'
    assert str(ltt) == expected
Ejemplo n.º 21
0
def test_empty_table():
    ltt = LatexTable(data=[])
    expected = "\n".join(
        [r"\begin{tabular}{|c|}", r"\hline", r"\end{tabular}"])
    assert str(ltt) == expected