本文整理汇总了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>⁢</mo><mi>y</mi></mrow>'
assert mathml(expr, printer='presentation', mul_symbol=None) == '<mrow><mi>x</mi><mo>⁢</mo><mi>y</mi></mrow>'
assert mathml(expr, printer='presentation', mul_symbol='dot') == '<mrow><mi>x</mi><mo>·</mo><mi>y</mi></mrow>'
assert mathml(expr, printer='presentation', mul_symbol='ldot') == '<mrow><mi>x</mi><mo>․</mo><mi>y</mi></mrow>'
assert mathml(expr, printer='presentation', mul_symbol='times') == '<mrow><mi>x</mi><mo>×</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>φ</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 == 'ⅈ'
mml = mpp._print(E)
assert mml.childNodes[0].nodeValue == 'ⅇ'
mml = mpp._print(oo)
assert mml.childNodes[0].nodeValue == '∞'
mml = mpp._print(pi)
assert mml.childNodes[0].nodeValue == 'π'
assert mathml(GoldenRatio, printer='presentation') == '<mi>φ</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>∂</mo><mn>6</mn></msup></mrow><mrow><mo>∂</mo><mi>y</mi><msup><mo>∂</mo><mn>2</mn></msup><mi>z</mi><mo>∂</mo><mi>x</mi><mo>∂</mo><mi>z</mi><mo>∂</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;未经允许,请勿转载。 |
请发表评论