Printing (Docstrings)

init_printing

sympy.physics.vector.printing.init_printing(pretty_print=True, order=None, use_unicode=None, use_latex=None, wrap_line=None, num_columns=None, no_global=False, ip=None, euler=False, forecolor='Black', backcolor='Transparent', fontsize='10pt', latex_mode='equation*', print_builtin=True, str_printer=None, pretty_printer=None, latex_printer=None, **settings)[source]

Initializes pretty-printer depending on the environment.

Parameters

pretty_print: boolean

If True, use pretty_print to stringify or the provided pretty printer; if False, use sstrrepr to stringify or the provided string printer.

order: string or None

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: boolean or None

If True, use unicode characters; if False, do not use unicode characters.

use_latex: string, boolean, or None

If True, use default latex rendering in GUI interfaces (png and mathjax); if False, do not use latex rendering; 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

wrap_line: boolean

If True, lines will wrap at the end; if False, they will not wrap but continue as one line. This is only relevant if \(pretty_print\) is True.

num_columns: int or None

If int, number of columns before wrapping is set to num_columns; if None, number of columns before wrapping is set to terminal width. This is only relevant if \(pretty_print\) is True.

no_global: boolean

If True, the settings become system wide; if False, use just for this console/session.

ip: An interactive console

This can either be an instance of IPython, or a class that derives from code.InteractiveConsole.

euler: boolean, optional, default=False

Loads the euler package in the LaTeX preamble for handwritten style fonts (http://www.ctan.org/pkg/euler).

forecolor: string, optional, default=’Black’

DVI setting for foreground color.

backcolor: string, optional, default=’Transparent’

DVI setting for background color.

fontsize: string, optional, default=’10pt’

A font size to pass to the LaTeX documentclass function in the preamble.

latex_mode: string, optional, default=’equation*’

The mode used in the LaTeX printer. Can be one of: {‘inline’|’plain’|’equation’|’equation*’}.

print_builtin: boolean, optional, default=True

If true then floats and integers will be printed. If false the printer will only print SymPy types.

str_printer: function, optional, default=None

A custom string printer function. This should mimic sympy.printing.sstrrepr().

pretty_printer: function, optional, default=None

A custom pretty printer. This should mimic sympy.printing.pretty().

latex_printer: function, optional, default=None

A custom LaTeX printer. This should mimic sympy.printing.latex().

Examples

>>> from sympy.interactive import init_printing
>>> from sympy import Symbol, sqrt
>>> from sympy.abc import x, y
>>> sqrt(5)
sqrt(5)
>>> init_printing(pretty_print=True) 
>>> sqrt(5) 
  ___
\/ 5
>>> theta = Symbol('theta') 
>>> init_printing(use_unicode=True) 
>>> theta 
\u03b8
>>> init_printing(use_unicode=False) 
>>> theta 
theta
>>> init_printing(order='lex') 
>>> str(y + x + y**2 + x**2) 
x**2 + x + y**2 + y
>>> init_printing(order='grlex') 
>>> str(y + x + y**2 + x**2) 
x**2 + x + y**2 + y
>>> init_printing(order='grevlex') 
>>> str(y * x**2 + x * y**2) 
x**2*y + x*y**2
>>> init_printing(order='old') 
>>> str(x**2 + y**2 + x + y) 
x**2 + x + y**2 + y
>>> init_printing(num_columns=10) 
>>> x**2 + x + y**2 + y 
x + y +
x**2 + y**2

vprint

sympy.physics.vector.printing.vprint(expr, **settings)[source]

Function for printing of expressions generated in the sympy.physics vector package.

Extends SymPy’s StrPrinter, takes the same setting accepted by SymPy’s \(sstr()\), and is equivalent to \(print(sstr(foo))\).

Parameters

expr : valid SymPy object

SymPy expression to print.

settings : args

Same as the settings accepted by SymPy’s sstr().

Examples

>>> from sympy.physics.vector import vprint, dynamicsymbols
>>> u1 = dynamicsymbols('u1')
>>> print(u1)
u1(t)
>>> vprint(u1)
u1

vpprint

sympy.physics.vector.printing.vpprint(expr, **settings)[source]

Function for pretty printing of expressions generated in the sympy.physics vector package.

Mainly used for expressions not inside a vector; the output of running scripts and generating equations of motion. Takes the same options as SymPy’s pretty_print(); see that function for more information.

Parameters

expr : valid SymPy object

SymPy expression to pretty print

settings : args

Same as those accepted by SymPy’s pretty_print.

vlatex

sympy.physics.vector.printing.vlatex(expr, **settings)[source]

Function for printing latex representation of sympy.physics.vector objects.

For latex representation of Vectors, Dyadics, and dynamicsymbols. Takes the same options as SymPy’s latex(); see that function for more information;

Parameters

expr : valid SymPy object

SymPy expression to represent in LaTeX form

settings : args

Same as latex()

Examples

>>> 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}}'