当前位置: 首页>>代码示例>>Python>>正文


Python latex.latex函数代码示例

本文整理汇总了Python中sympy.printing.latex.latex函数的典型用法代码示例。如果您正苦于以下问题:Python latex函数的具体用法?Python latex怎么用?Python latex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了latex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_commutator

def test_commutator():
    A = Operator('A')
    B = Operator('B')
    c = Commutator(A, B)
    c_tall = Commutator(A**2, B)
    assert str(c) == '[A,B]'
    assert pretty(c) == '[A,B]'
    assert upretty(c) == u('[A,B]')
    assert latex(c) == r'\left[A,B\right]'
    sT(c, "Commutator(Operator(Symbol('A')),Operator(Symbol('B')))")
    assert str(c_tall) == '[A**2,B]'
    ascii_str = \
"""\
[ 2  ]\n\
[A ,B]\
"""
    ucode_str = \
u("""\
⎡ 2  ⎤\n\
⎣A ,B⎦\
""")
    assert pretty(c_tall) == ascii_str
    assert upretty(c_tall) == ucode_str
    assert latex(c_tall) == r'\left[\left(A\right)^{2},B\right]'
    sT(c_tall, "Commutator(Pow(Operator(Symbol('A')), Integer(2)),Operator(Symbol('B')))")
开发者ID:B-Rich,项目名称:sympy,代码行数:25,代码来源:test_printing.py

示例2: test_commutator

def test_commutator():
    A = Operator("A")
    B = Operator("B")
    c = Commutator(A, B)
    c_tall = Commutator(A ** 2, B)
    assert str(c) == "[A,B]"
    assert pretty(c) == "[A,B]"
    assert upretty(c) == u"[A,B]"
    assert latex(c) == r"\left[A,B\right]"
    sT(c, "Commutator(Operator(Symbol('A')),Operator(Symbol('B')))")
    assert str(c_tall) == "[A**2,B]"
    ascii_str = """\
[ 2  ]\n\
[A ,B]\
"""
    ucode_str = u(
        """\
⎡ 2  ⎤\n\
⎣A ,B⎦\
"""
    )
    assert pretty(c_tall) == ascii_str
    assert upretty(c_tall) == ucode_str
    assert latex(c_tall) == r"\left[A^{2},B\right]"
    sT(c_tall, "Commutator(Pow(Operator(Symbol('A')), Integer(2)),Operator(Symbol('B')))")
开发者ID:scopatz,项目名称:sympy,代码行数:25,代码来源:test_printing.py

示例3: test_anticommutator

def test_anticommutator():
    A = Operator("A")
    B = Operator("B")
    ac = AntiCommutator(A, B)
    ac_tall = AntiCommutator(A ** 2, B)
    assert str(ac) == "{A,B}"
    assert pretty(ac) == "{A,B}"
    assert upretty(ac) == u"{A,B}"
    assert latex(ac) == r"\left\{A,B\right\}"
    sT(ac, "AntiCommutator(Operator(Symbol('A')),Operator(Symbol('B')))")
    assert str(ac_tall) == "{A**2,B}"
    ascii_str = """\
/ 2  \\\n\
<A ,B>\n\
\\    /\
"""
    ucode_str = u(
        """\
⎧ 2  ⎫\n\
⎨A ,B⎬\n\
⎩    ⎭\
"""
    )
    assert pretty(ac_tall) == ascii_str
    assert upretty(ac_tall) == ucode_str
    assert latex(ac_tall) == r"\left\{A^{2},B\right\}"
    sT(ac_tall, "AntiCommutator(Pow(Operator(Symbol('A')), Integer(2)),Operator(Symbol('B')))")
开发者ID:scopatz,项目名称:sympy,代码行数:27,代码来源:test_printing.py

示例4: test_latex

def test_latex():
    assert latex((2*tau)**Rational(7,2)) == "8 \\sqrt{2} \\tau^{\\frac{7}{2}}"
    assert latex((2*mu)**Rational(7,2), mode='equation*') == \
            "\\begin{equation*}8 \\sqrt{2} \\mu^{\\frac{7}{2}}\\end{equation*}"
    assert latex((2*mu)**Rational(7,2), mode='equation', itex=True) == \
            "$$8 \\sqrt{2} \\mu^{\\frac{7}{2}}$$"
    assert latex([2/x, y]) =="\\begin{bmatrix}\\frac{2}{x}, & y\\end{bmatrix}"
开发者ID:101man,项目名称:sympy,代码行数:7,代码来源:test_latex.py

示例5: test_latex

def test_latex():
    assert latex((2 * tau) ** Rational(7, 2)) == "$8 \\sqrt{2} \\sqrt[7]{\\tau}$"
    assert (
        latex((2 * mu) ** Rational(7, 2), inline=False)
        == "\\begin{equation*}8 \\sqrt{2} \\sqrt[7]{\\mu}\\end{equation*}"
    )
    assert latex([2 / x, y]) == "$\\begin{bmatrix}\\frac{2}{x}, & y\\end{bmatrix}$"
开发者ID:hazelnusse,项目名称:sympy-old,代码行数:7,代码来源:test_latex.py

示例6: test_latex_Matrix

def test_latex_Matrix():
    M = Matrix([[1 + x, y], [y, x - 1]])
    assert latex(M) == "$\\left(\\begin{smallmatrix}1 + x & y\\\\y & -1 + " "x\\end{smallmatrix}\\right)$"
    profile = {"mat_str": "bmatrix"}
    assert latex(M, profile) == "$\\left(\\begin{bmatrix}1 + x & y\\\\y & -1 + " + "x\\end{bmatrix}\\right)$"
    profile["mat_delim"] = None
    assert latex(M, profile) == "$\\begin{bmatrix}1 + x & y\\\\y & -1 + " "x\\end{bmatrix}$"
开发者ID:hazelnusse,项目名称:sympy-old,代码行数:7,代码来源:test_latex.py

示例7: test_latex

def test_latex():
    assert latex((2*tau)**Rational(7,2)) == "$8 \\sqrt{2} \\tau^{\\frac{7}{2}}$"
    assert latex((2*mu)**Rational(7,2), inline=False) == \
            "\\begin{equation*}8 \\sqrt{2} \\mu^{\\frac{7}{2}}\\end{equation*}"
    assert latex((2*mu)**Rational(7,2), inline=False, itex=True) == \
            "$$8 \\sqrt{2} \\mu^{\\frac{7}{2}}$$"
    assert latex([2/x, y]) =="$\\begin{bmatrix}\\frac{2}{x}, & y\\end{bmatrix}$"
开发者ID:Praveen-Ramanujam,项目名称:MobRAVE,代码行数:7,代码来源:test_latex.py

示例8: clean_up_zeros

def clean_up_zeros(matrix_spec, label="", colors={}, 
                    environment="equation", cancel_zeros=True, diagonal_col_offset=None):

    matrix, indexed_sym = matrix_spec
    if diagonal_col_offset is None: diagonal_col_offset = 1

    tex_code = r"\begin{" + environment + r"}" + "\n" if environment else ""
    tex_code += r"\left[\begin{array}{" + ('c' * matrix.cols) + r'}' + "\n"

    for r in range(matrix.rows):
        for c in range(matrix.cols):
            
            space = "" if c == 0 else " "

            if r*diagonal_col_offset < c: coeff_str = ""
            elif cancel_zeros: coeff_str = latex(matrix[r,c]) if matrix[r,c] != 0 else ""
            else: coeff_str = latex(matrix[r,c])

            if (r,c) in colors: coeff_str = r'\textcolor{' + colors[(r,c)] + r'}{' + coeff_str + "}"
            tex_code += "{}{} {}".format(space, coeff_str, r'\\' if c == matrix.cols-1 else r'&') 

        tex_code += "" if r == matrix.rows - 1 else "\n"

    label = "\n{}".format(r'\label{eq:' + label + r'}' + "\n" if label else "")
    tex_code += "\n" + r'\end{array}\right]' 
    tex_code += label + r'\end{' + environment + '}' if environment else ""

    return tex_code
开发者ID:massimo-nocentini,项目名称:recurrences-unfolding,代码行数:28,代码来源:doubly-indexed-recurrences.py

示例9: test_anticommutator

def test_anticommutator():
    A = Operator('A')
    B = Operator('B')
    ac = AntiCommutator(A, B)
    ac_tall = AntiCommutator(A**2, B)
    assert str(ac) == '{A,B}'
    assert pretty(ac) == '{A,B}'
    assert upretty(ac) == u('{A,B}')
    assert latex(ac) == r'\left\{A,B\right\}'
    sT(ac, "AntiCommutator(Operator(Symbol('A')),Operator(Symbol('B')))")
    assert str(ac_tall) == '{A**2,B}'
    ascii_str = \
"""\
/ 2  \\\n\
<A ,B>\n\
\\    /\
"""
    ucode_str = \
u("""\
⎧ 2  ⎫\n\
⎨A ,B⎬\n\
⎩    ⎭\
""")
    assert pretty(ac_tall) == ascii_str
    assert upretty(ac_tall) == ucode_str
    assert latex(ac_tall) == r'\left\{\left(A\right)^{2},B\right\}'
    sT(ac_tall, "AntiCommutator(Pow(Operator(Symbol('A')), Integer(2)),Operator(Symbol('B')))")
开发者ID:B-Rich,项目名称:sympy,代码行数:27,代码来源:test_printing.py

示例10: test_latex_fresnel

def test_latex_fresnel():
    from sympy.functions.special.error_functions import (fresnels, fresnelc)
    from sympy.abc import z
    assert latex(fresnels(z)) == r'S\left(z\right)'
    assert latex(fresnelc(z)) == r'C\left(z\right)'
    assert latex(fresnels(z)**2) == r'S^{2}\left(z\right)'
    assert latex(fresnelc(z)**2) == r'C^{2}\left(z\right)'
开发者ID:Tarang1993,项目名称:sympy,代码行数:7,代码来源:test_latex.py

示例11: test_latex_product

def test_latex_product():
    assert (
        latex(Product(x * y ** 2, (x, -2, 2), (y, -5, 5)))
        == r"\prod_{\substack{-2 \leq x \leq 2\\-5 \leq y \leq 5}} x y^{2}"
    )
    assert latex(Product(x ** 2, (x, -2, 2))) == r"\prod_{x=-2}^{2} x^{2}"
    assert latex(Product(x ** 2 + y, (x, -2, 2))) == r"\prod_{x=-2}^{2} \left(x^{2} + y\right)"
开发者ID:kushal124,项目名称:sympy,代码行数:7,代码来源:test_latex.py

示例12: test_latex_sum

def test_latex_sum():
    assert latex(Sum(x*y**2, (x, -2, 2), (y, -5, 5))) == \
        r"\sum_{\substack{-2 \leq x \leq 2\\-5 \leq y \leq 5}} x y^{2}"
    assert latex(Sum(x**2, (x, -2, 2))) == \
        r"\sum_{x=-2}^{2} x^{2}"
    assert latex(Sum(x**2 + y, (x, -2, 2))) == \
        r"\sum_{x=-2}^{2} \left(x^{2} + y\right)"
开发者ID:101man,项目名称:sympy,代码行数:7,代码来源:test_latex.py

示例13: test_QuotientRing

def test_QuotientRing():
    from sympy.polys.domains import QQ

    R = QQ[x] / [x ** 2 + 1]

    assert latex(R) == r"\frac{\mathbb{Q}\left[x\right]}{\left< {x^{2} + 1} \right>}"
    assert latex(R.one) == r"{1} + {\left< {x^{2} + 1} \right>}"
开发者ID:kushal124,项目名称:sympy,代码行数:7,代码来源:test_latex.py

示例14: test_latex_intervals

def test_latex_intervals():
    a = Symbol('a', real=True)
    assert latex(Interval(0, a)) == r"\left[0, a\right]"
    assert latex(Interval(0, a, False, False)) == r"\left[0, a\right]"
    assert latex(Interval(0, a, True, False)) == r"\left(0, a\right]"
    assert latex(Interval(0, a, False, True)) == r"\left[0, a\right)"
    assert latex(Interval(0, a, True, True)) == r"\left(0, a\right)"
开发者ID:101man,项目名称:sympy,代码行数:7,代码来源:test_latex.py

示例15: test_Hadamard

def test_Hadamard():
    from sympy.matrices import MatrixSymbol, HadamardProduct

    X = MatrixSymbol("X", 2, 2)
    Y = MatrixSymbol("Y", 2, 2)
    assert latex(HadamardProduct(X, Y * Y)) == r"X \circ \left(Y Y\right)"
    assert latex(HadamardProduct(X, Y) * Y) == r"\left(X \circ Y\right) Y"
开发者ID:kushal124,项目名称:sympy,代码行数:7,代码来源:test_latex.py


注:本文中的sympy.printing.latex.latex函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。