• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mathml.mathml函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_mul_symbol_print

def test_mul_symbol_print():
    expr = x * y
    assert mathml(expr, printer='presentation') == '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mi>y</mi></mrow>'
    assert mathml(expr, printer='presentation', mul_symbol=None) == '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mi>y</mi></mrow>'
    assert mathml(expr, printer='presentation', mul_symbol='dot') == '<mrow><mi>x</mi><mo>&#xB7;</mo><mi>y</mi></mrow>'
    assert mathml(expr, printer='presentation', mul_symbol='ldot') == '<mrow><mi>x</mi><mo>&#x2024;</mo><mi>y</mi></mrow>'
    assert mathml(expr, printer='presentation', mul_symbol='times') == '<mrow><mi>x</mi><mo>&#xD7;</mo><mi>y</mi></mrow>'
开发者ID:nicoguaro,项目名称:sympy,代码行数:7,代码来源:test_mathml.py


示例2: test_mathml_constants

def test_mathml_constants():
    mml = mp._print(I)
    assert mml.nodeName == 'imaginaryi'

    mml = mp._print(E)
    assert mml.nodeName == 'exponentiale'

    mml = mp._print(oo)
    assert mml.nodeName == 'infinity'

    mml = mp._print(pi)
    assert mml.nodeName == 'pi'

    assert mathml(GoldenRatio) == '<cn>&#966;</cn>'

    mml = mathml(EulerGamma)
    assert mml == '<eulergamma/>'
开发者ID:A-turing-machine,项目名称:sympy,代码行数:17,代码来源:test_mathml.py


示例3: print_gtk

def print_gtk(x):
    """Print to Gtkmathview, a gtk widget capable of rendering MathML.
    Needs libgtkmathview-bin"""
    from sympy.utilities.mathml import c2p

    tmp = tempfile.mktemp() # create a temp file to store the result
    file = open(tmp, 'wb')
    file.write( c2p(mathml(x), simple=True) )
    file.close()

    os.system("mathmlviewer " + tmp)
开发者ID:certik,项目名称:sympy-oldcore,代码行数:11,代码来源:gtk.py


示例4: print_gtk

def print_gtk(x, start_viewer=True):
    """Print to Gtkmathview, a gtk widget capable of rendering MathML.

    Needs libgtkmathview-bin
    """
    from sympy.utilities.mathml import c2p

    tmp = tempfile.mkstemp()  # create a temp file to store the result
    with open(tmp, 'wb') as file:
        file.write(c2p(mathml(x), simple=True))

    if start_viewer:
        os.system("mathmlviewer " + tmp)
开发者ID:asmeurer,项目名称:sympy,代码行数:13,代码来源:gtk.py


示例5: test_presentation_mathml_constants

def test_presentation_mathml_constants():
    mml = mpp._print(I)
    assert mml.childNodes[0].nodeValue == '&ImaginaryI;'

    mml = mpp._print(E)
    assert mml.childNodes[0].nodeValue == '&ExponentialE;'

    mml = mpp._print(oo)
    assert mml.childNodes[0].nodeValue == '&#x221E;'

    mml = mpp._print(pi)
    assert mml.childNodes[0].nodeValue == '&pi;'

    assert mathml(GoldenRatio, printer='presentation') == '<mi>&#966;</mi>'
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:14,代码来源:test_mathml.py


示例6: _sympy_format

 def _sympy_format(self, method, variables, backend, default, **kwargs):
     variables = variables or {}
     if backend in (None, math):
         backend = sympy
     variables = defaultkeydict(
         None if default is None else (lambda k: backend.Symbol(default(k))),
         {k: v if isinstance(v, Expr) else (backend.Symbol(v) if isinstance(v, str) else backend.Float(v))
          for k, v in variables.items()})
     expr = self(variables, backend=backend, **kwargs).simplify()
     if method == 'latex':
         return backend.latex(expr)
     elif method == 'str':
         return str(expr)
     elif method == 'unicode':
         return backend.pretty(expr, use_unicode=True)
     elif method == 'mathml':
         from sympy.printing.mathml import mathml
         return mathml(expr)
     else:
         raise NotImplementedError("Unknown method: %s" % method)
开发者ID:bjodah,项目名称:chempy,代码行数:20,代码来源:_expr.py


示例7: test_settings

def test_settings():
    raises(TypeError, lambda: mathml(Symbol("x"), method="garbage"))
开发者ID:A-turing-machine,项目名称:sympy,代码行数:2,代码来源:test_mathml.py


示例8: test_presentation_settings

def test_presentation_settings():
    raises(TypeError, lambda: mathml(Symbol("x"), printer='presentation',method="garbage"))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:2,代码来源:test_mathml.py


示例9: test_print_matrix_symbol

def test_print_matrix_symbol():
    A = MatrixSymbol('A', 1, 2)
    assert mpp.doprint(A) == '<mi>A</mi>'
    assert mp.doprint(A) == '<ci>A</ci>'
    assert mathml(A, printer='presentation', mat_symbol_style="bold" )== '<mi mathvariant="bold">A</mi>'
    assert mathml(A, mat_symbol_style="bold" )== '<ci>A</ci>' # No effect in content printer
开发者ID:nicoguaro,项目名称:sympy,代码行数:6,代码来源:test_mathml.py


示例10: test_root_notation_print

def test_root_notation_print():
    assert mathml(x**(S(1)/3), printer='presentation') == '<mroot><mi>x</mi><mn>3</mn></mroot>'
    assert mathml(x**(S(1)/3), printer='presentation', root_notation=False) == '<msup><mi>x</mi><mfrac><mn>1</mn><mn>3</mn></mfrac></msup>'
    assert mathml(x**(S(1)/3), printer='content') == '<apply><root/><degree><ci>3</ci></degree><ci>x</ci></apply>'
    assert mathml(x**(S(1)/3), printer='content', root_notation=False) == '<apply><power/><ci>x</ci><apply><divide/><cn>1</cn><cn>3</cn></apply></apply>'
开发者ID:nicoguaro,项目名称:sympy,代码行数:5,代码来源:test_mathml.py


示例11: test_ln_notation_print

def test_ln_notation_print():
    expr = log(x)
    assert mathml(expr, printer='presentation') == '<mrow><mi>log</mi><mfenced><mi>x</mi></mfenced></mrow>'
    assert mathml(expr, printer='presentation', ln_notation=False) == '<mrow><mi>log</mi><mfenced><mi>x</mi></mfenced></mrow>'
    assert mathml(expr, printer='presentation', ln_notation=True) == '<mrow><mi>ln</mi><mfenced><mi>x</mi></mfenced></mrow>'
开发者ID:nicoguaro,项目名称:sympy,代码行数:5,代码来源:test_mathml.py


示例12: test_mat_delim_print

def test_mat_delim_print():
    expr = Matrix([[1, 2], [3, 4]])
    assert mathml(expr, printer='presentation', mat_delim='[') == '<mfenced close="]" open="["><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable></mfenced>'
    assert mathml(expr, printer='presentation', mat_delim='(') == '<mfenced><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable></mfenced>'
    assert mathml(expr, printer='presentation', mat_delim='') == '<mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable>'
开发者ID:nicoguaro,项目名称:sympy,代码行数:5,代码来源:test_mathml.py


示例13: test_print_derivative

def test_print_derivative():
    f = Function('f')
    z = Symbol('z')
    d = Derivative(f(x, y, z), x, z, x, z, z, y)
    assert mathml(d) == r'<apply><partialdiff/><bvar><ci>y</ci><ci>z</ci><degree><cn>2</cn></degree><ci>x</ci><ci>z</ci><ci>x</ci></bvar><apply><f/><ci>x</ci><ci>y</ci><ci>z</ci></apply></apply>'
    assert mathml(d, printer='presentation') == r'<mrow><mfrac><mrow><msup><mo>&#x2202;</mo><mn>6</mn></msup></mrow><mrow><mo>&#x2202;</mo><mi>y</mi><msup><mo>&#x2202;</mo><mn>2</mn></msup><mi>z</mi><mo>&#x2202;</mo><mi>x</mi><mo>&#x2202;</mo><mi>z</mi><mo>&#x2202;</mo><mi>x</mi></mrow></mfrac><mrow><mi>f</mi><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow></mrow>'
开发者ID:nicoguaro,项目名称:sympy,代码行数:6,代码来源:test_mathml.py


示例14: test_root_notation_print

def test_root_notation_print():
    assert mathml(x**(S(1)/3), printer='presentation') == '<mroot><mi>x</mi><mn>3</mn></mroot>'
    assert mathml(x**(S(1)/3), printer='presentation', root_notation=False) == '<msup><mi>x</mi><mfrac><mn>1</mn><mn>3</mn></mfrac></msup>'
开发者ID:cklb,项目名称:sympy,代码行数:3,代码来源:test_mathml.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python precedence.precedence函数代码示例发布时间:2022-05-27
下一篇:
Python latex.LatexPrinter类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap