Пример #1
0
def test_to_latex_exact2():
    x = 0.12345
    y = la.to_latex(x, exact=.01)
    y_ = '\\begin{array}{*{1}{c}}\n  \\frac{1}{8}\n\\end{array}'
    assert_equal(y, y_)

    y = la.to_latex(x, exact=.001)
    y_ = '\\begin{array}{*{1}{c}}\n  \\frac{7}{57}\n\\end{array}'
    assert_equal(y, y_)
Пример #2
0
def test_to_latex_exact2():
    x = 0.12345
    y = la.to_latex(x, exact=.01)
    y_ = '\\begin{array}{*{1}{c}}\n  \\frac{1}{8}\n\\end{array}'
    assert y == y_

    y = la.to_latex(x, exact=.001)
    y_ = '\\begin{array}{*{1}{c}}\n  \\frac{7}{57}\n\\end{array}'
    assert y == y_
Пример #3
0
def test_to_latex4():
    x = np.array([
        -0.078, 0.480, 0.413, 0.830, 0.776, 0.102, 0.513, 0.462, 0.335, 0.712
    ])
    y = la.to_latex(x)
    y_ = '\\newcolumntype{X}{D{.}{.}{2,3}}\n\\begin{array}{*{10}{X}}\n  -0.078 & 0.480 & 0.413 & 0.830 & 0.776 & 0.102 & 0.513 & 0.462 & 0.335 & 0.712\n\\end{array}'
    assert y == y_
Пример #4
0
def test_to_latex1():
    x = np.array([1, 2, 3, 10])
    y = la.to_latex(x)
    y_ = '\\newcolumntype{X}{D{.}{.}{2,0}}\n\\begin{array}{*{4}{X}}\n  1 & 2 & 3 & 10\n\\end{array}'
    assert_equal(y, y_)
Пример #5
0
def test_to_latex5():
    np.random.seed(0)
    x = np.random.rand(12).reshape(4, 3) - 0.5
    y = la.to_latex(x, decimals=2)
    y_ = '\\newcolumntype{X}{D{.}{.}{2,2}}\n\\begin{array}{*{3}{X}}\n  0.05 & 0.22 & 0.10 \\\\\n  0.04 & -0.08 & 0.15 \\\\\n  -0.06 & 0.39 & 0.46 \\\\\n  -0.12 & 0.29 & 0.03\n\\end{array}'
    assert_equal(y, y_)
Пример #6
0
def test_to_latex4():
    x = x = np.array([-0.078, 0.480, 0.413, 0.830, 0.776, 0.102, 0.513, 0.462, 0.335, 0.712])
    y = la.to_latex(x)
    y_ = '\\newcolumntype{X}{D{.}{.}{2,3}}\n\\begin{array}{*{10}{X}}\n  -0.078 & 0.480 & 0.413 & 0.830 & 0.776 & 0.102 & 0.513 & 0.462 & 0.335 & 0.712\n\\end{array}'
    assert_equal(y, y_)
Пример #7
0
def test_to_latex_exact1():
    x = np.array([1, 2, 3, 10, .1])
    y = la.to_latex(x, exact=True)
    y_ = '\\begin{array}{*{5}{c}}\n  1 & 2 & 3 & 10 & \\frac{1}{10}\n\\end{array}'
    assert y == y_
Пример #8
0
def test_to_latex5():
    np.random.seed(0)
    x = np.random.rand(12).reshape(4, 3) - 0.5
    y = la.to_latex(x, decimals=2)
    y_ = '\\newcolumntype{X}{D{.}{.}{2,2}}\n\\begin{array}{*{3}{X}}\n  0.05 & 0.22 & 0.10 \\\\\n  0.04 & -0.08 & 0.15 \\\\\n  -0.06 & 0.39 & 0.46 \\\\\n  -0.12 & 0.29 & 0.03\n\\end{array}'
    assert y == y_
Пример #9
0
def test_to_latex2():
    x = np.array([1, 2, -3, 100])
    y = la.to_latex(x)
    y_ = '\\newcolumntype{X}{D{.}{.}{4,0}}\n\\begin{array}{*{4}{X}}\n  1 & 2 & -3 & 100\n\\end{array}'
    assert y == y_
Пример #10
0
def test_to_latex_exact1():
    x = np.array([1, 2, 3, 10, .1])
    y = la.to_latex(x, exact=True)
    y_ = '\\begin{array}{*{5}{c}}\n  1 & 2 & 3 & 10 & \\frac{1}{10}\n\\end{array}'
    assert_equal(y, y_)
Пример #11
0
def test_to_latex1():
    x = np.array([1, 2, 3, 10])
    y = la.to_latex(x)
    y_ = '\\newcolumntype{X}{D{.}{.}{2,0}}\n\\begin{array}{*{4}{X}}\n  1 & 2 & 3 & 10\n\\end{array}'
    assert_equal(y, y_)
Пример #12
0
def test_to_latex2():
    x = np.array([1, 2, -3, 100])
    y = la.to_latex(x)
    y_ = '\\newcolumntype{X}{D{.}{.}{4,0}}\n\\begin{array}{*{4}{X}}\n  1 & 2 & -3 & 100\n\\end{array}'
    assert y == y_