打印(Docstrings)#
- sympy.physics.vector.printing.init_vprinting(**kwargs)[源代码]#
初始化所有SymPy对象的时间导数打印,即任何时间函数都将以更紧凑的符号显示。这样做的主要好处是打印时间导数;而不是显示为
Derivative(f(t),t)
,它将显示f'
. 这实际上只在存在导数且不在物理.矢量.矢量或者物理.矢量.并矢对象。此函数是init_printing()
. 它的任何关键字参数在这里都是有效的。根据环境初始化打印机。
- 参数:
pretty_print : bool, default=True
If
True
, usepretty_print()
to stringify or the provided pretty printer; ifFalse
, usesstrrepr()
to stringify or the provided string printer.秩序 :string或None,default='lex'
There are a few different settings for this parameter:
'lex'
(default), which is lexographic order;'grlex'
, which is graded lexographic order;'grevlex'
, which is reversed graded lexographic order;'old'
, which is used for compatibility reasons and for long expressions;None
, which sets it to lex.use_unicode : bool or None, default=None
If
True
, use unicode characters; ifFalse
, do not use unicode characters; ifNone
, make a guess based on the environment.use_latex : string, bool, or None, default=None
If
True
, use default LaTeX rendering in GUI interfaces (png and mathjax); ifFalse
, do not use LaTeX rendering; ifNone
, make a guess based on the environment; if'png'
, enable LaTeX rendering with an external LaTeX compiler, falling back to matplotlib if external compilation fails; if'matplotlib'
, enable LaTeX rendering with matplotlib; if'mathjax'
, enable LaTeX text generation, for example MathJax rendering in IPython notebook or text rendering in LaTeX documents; if'svg'
, enable LaTeX rendering with an external latex compiler, no fallbackwrap_line : bool
如果为True,则行将在末尾换行;如果为False,则不会换行,而是作为一行继续。只有当
pretty_print
是True。num_columns :int或None,默认值为None
If
int
, number of columns before wrapping is set to num_columns; ifNone
, number of columns before wrapping is set to terminal width. This is only relevant ifpretty_print
isTrue
.no_global : bool, default=False
If
True
, the settings become system wide; ifFalse
, use just for this console/session.ip :交互式控制台
它可以是IPython的实例,也可以是从code.InteractiveConsole.
euler : bool, optional, default=False
Loads the euler package in the LaTeX preamble for handwritten style fonts (https://www.ctan.org/pkg/euler).
前色 :string或None,可选,默认值=None
DVI setting for foreground color.
None
means that either'Black'
,'White'
, or'Gray'
will be selected based on a guess of the IPython terminal color setting. See notes.背景色彩 :string,可选,default='Transparent'
背景色的DVI设置。见注释。
fontsize : string or int, optional, default='10pt'
要传递给前导中的LaTeX documentclass函数的字体大小。请注意,这些选项受documentclass的限制。考虑改用比例。
latex_mode :string,可选,default='plain'
The mode used in the LaTeX printer. Can be one of:
{'inline'|'plain'|'equation'|'equation*'}
.print_builtin :布尔值,可选,默认值=真
如果
True
然后将打印浮点和整数。如果False
打印机将只打印sypy类型。str_printer :函数,可选,默认值=无
A custom string printer function. This should mimic
sstrrepr()
.pretty_printer :函数,可选,默认值=无
A custom pretty printer. This should mimic
pretty()
.latex_printer :函数,可选,默认值=无
A custom LaTeX printer. This should mimic
latex()
.规模 :float,可选,默认值=1.0
Scale the LaTeX output when using the
'png'
or'svg'
backends. Useful for high dpi screens.设置:
的任何其他设置
latex
和pretty
命令可用于微调输出。
实例
>>> from sympy import Function, symbols >>> t, x = symbols('t, x') >>> omega = Function('omega') >>> omega(x).diff() Derivative(omega(x), x) >>> omega(t).diff() Derivative(omega(t), t)
现在使用字符串打印机:
>>> from sympy.physics.vector import init_vprinting >>> init_vprinting(pretty_print=False) >>> omega(x).diff() Derivative(omega(x), x) >>> omega(t).diff() omega'
- sympy.physics.vector.printing.vprint(expr, **settings)[源代码]#
用于打印在中生成的表达式的函数物理学矢量包。
扩展SymPy的StrPrinter,采用SymPy接受的相同设置
sstr()
,相当于print(sstr(foo))
.- 参数:
expr :有效的SymPy对象
要打印的SymPy表达式。
设置 :参数
与SymPy的sstr()接受的设置相同。
实例
>>> from sympy.physics.vector import vprint, dynamicsymbols >>> u1 = dynamicsymbols('u1') >>> print(u1) u1(t) >>> vprint(u1) u1
- sympy.physics.vector.printing.vpprint(expr, **settings)[源代码]#
函数,用于漂亮地打印在物理学矢量包。
主要用于不在向量内部的表达式;运行脚本和生成运动方程的输出。和辛比的选择一样
pretty_print()
;有关详细信息,请参见该函数。- 参数:
expr :有效的SymPy对象
漂亮的印刷品
设置 :参数
和辛普森漂亮的印刷品一样。
- sympy.physics.vector.printing.vlatex(expr, **settings)[源代码]#
胶乳印刷功能sympy.物理.矢量物体。
用于矢量、并矢和动态符号的 Latex 表示。和辛比的选择一样
latex()
;有关详细信息,请参见该函数;- 参数:
expr :有效的SymPy对象
以 Latex 形式表示的SymPy表达式
设置 :参数
与 Latex ()
实例
>>> from sympy.physics.vector import vlatex, ReferenceFrame, dynamicsymbols >>> N = ReferenceFrame('N') >>> q1, q2 = dynamicsymbols('q1 q2') >>> q1d, q2d = dynamicsymbols('q1 q2', 1) >>> q1dd, q2dd = dynamicsymbols('q1 q2', 2) >>> vlatex(N.x + N.y) '\\mathbf{\\hat{n}_x} + \\mathbf{\\hat{n}_y}' >>> vlatex(q1 + q2) 'q_{1} + q_{2}' >>> vlatex(q1d) '\\dot{q}_{1}' >>> vlatex(q1 * q2d) 'q_{1} \\dot{q}_{2}' >>> vlatex(q1dd * q1 / q1d) '\\frac{q_{1} \\ddot{q}_{1}}{\\dot{q}_{1}}'