def vpprint(expr, **settings): r"""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 pretty print Examples ======== Use in the same way as pprint """ mp = VectorPrettyPrinter(settings) print(mp.doprint(expr))
def vpprint(expr, **settings): r"""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 pretty print Examples ======== Use in the same way as pprint """ mp = VectorPrettyPrinter(settings) print(mp.doprint(expr))
def test_vector_pretty_print(): # TODO : The unit vectors should print with subscripts but they just # print as `n_x` instead of making `x` a subscritp with unicode. # TODO : The pretty print division does not print correctly here: # w = alpha * N.x + sin(omega) * N.y + alpha / beta * N.z pp = VectorPrettyPrinter() expected = u(' 2\na n_x + b n_y + c\u22c5sin(\u03b1) n_z') assert expected == pp.doprint(v) assert expected == v._pretty().render() expected = u('\u03b1 n_x + sin(\u03c9) n_y + \u03b1\u22c5\u03b2 n_z') assert expected == pp.doprint(w) assert expected == w._pretty().render()
def test_vector_pretty_print(): # TODO : The unit vectors should print with subscripts but they just # print as `n_x` instead of making `x` a subscript with unicode. # TODO : The pretty print division does not print correctly here: # w = alpha * N.x + sin(omega) * N.y + alpha / beta * N.z pp = VectorPrettyPrinter() expected = u("""\ 2 a n_x + b n_y + c⋅sin(α) n_z\ """) assert expected == pp.doprint(v) assert expected == v._pretty().render() expected = u('α n_x + sin(ω) n_y + α⋅β n_z') assert expected == pp.doprint(w) assert expected == w._pretty().render()
def test_vector_pretty_print(): # TODO : The unit vectors should print with subscripts but they just # print as `n_x` instead of making `x` a subscript with unicode. # TODO : The pretty print division does not print correctly here: # w = alpha * N.x + sin(omega) * N.y + alpha / beta * N.z pp = VectorPrettyPrinter() expected = u("""\ 2 a n_x + b n_y + c⋅sin(α) n_z\ """) assert expected == pp.doprint(v) assert expected == v._pretty().render() expected = u('α n_x + sin(ω) n_y + α⋅β n_z') assert expected == pp.doprint(w) assert expected == w._pretty().render()
def test_vector_pretty_print(): # TODO : The unit vectors should print with subscripts but they just # print as `n_x` instead of making `x` a subscritp with unicode. # TODO : The pretty print division does not print correctly here: # w = alpha * N.x + sin(omega) * N.y + alpha / beta * N.z pp = VectorPrettyPrinter() expected = (u' 2\na \x1b[94m\x1b[1mn_x\x1b[0;0m\x1b[0;0m + b \x1b[94m' u'\x1b[1mn_y\x1b[0;0m\x1b[0;0m + c\u22c5sin(\u03b1) \x1b[9' u'4m\x1b[1mn_z\x1b[0;0m\x1b[0;0m') assert expected == pp.doprint(v) assert expected == v._pretty().render() expected = (u'\u03b1 \x1b[94m\x1b[1mn_x\x1b[0;0m\x1b[0;0m + sin(\u03c9' u') \x1b[94m\x1b[1mn_y\x1b[0;0m\x1b[0;0m + \u03b1\u22c5' u'\u03b2 \x1b[94m\x1b[1mn_z\x1b[0;0m\x1b[0;0m') assert expected == pp.doprint(w) assert expected == w._pretty().render()
def test_vector_pretty_print(): # TODO : The unit vectors should print with subscripts but they just # print as `n_x` instead of making `x` a subscritp with unicode. # TODO : The pretty print division does not print correctly here: # w = alpha * N.x + sin(omega) * N.y + alpha / beta * N.z pp = VectorPrettyPrinter() expected = u(' 2\na \x1b[94m\x1b[1mn_x\x1b[0;0m\x1b[0;0m + b \x1b[94m' '\x1b[1mn_y\x1b[0;0m\x1b[0;0m + c\u22c5sin(\u03b1) \x1b[9' '4m\x1b[1mn_z\x1b[0;0m\x1b[0;0m') assert expected == pp.doprint(v) assert expected == v._pretty().render() expected = u('\u03b1 \x1b[94m\x1b[1mn_x\x1b[0;0m\x1b[0;0m + sin(\u03c9' ') \x1b[94m\x1b[1mn_y\x1b[0;0m\x1b[0;0m + \u03b1\u22c5' '\u03b2 \x1b[94m\x1b[1mn_z\x1b[0;0m\x1b[0;0m') assert expected == pp.doprint(w) assert expected == w._pretty().render()