def test_pretty_unicode_defaults(): use_unicode = pprint_use_unicode(True) assert xpretty(Symbol('alpha')) == u'\u03b1' pprint_use_unicode(False) assert xpretty(Symbol('alpha')) == 'alpha' pprint_use_unicode(use_unicode)
def test_pretty_unicode_defaults(): use_unicode = pprint_use_unicode(True) assert xpretty(Symbol("alpha")) == u"\u03b1" pprint_use_unicode(False) assert xpretty(Symbol("alpha")) == "alpha" pprint_use_unicode(use_unicode)
def test_full_prec(): assert xpretty(S("0.3"), full_prec=True) == "0.300000000000000" assert xpretty(S("0.3"), full_prec="auto") == "0.300000000000000" assert xpretty(S("0.3"), full_prec=False) == "0.3" assert xpretty(S("0.3") * x, full_prec=True, use_unicode=False) in ["0.300000000000000*x", "x*0.300000000000000"] assert xpretty(S("0.3") * x, full_prec="auto", use_unicode=False) in ["0.3*x", "x*0.3"] assert xpretty(S("0.3") * x, full_prec=False, use_unicode=False) in ["0.3*x", "x*0.3"]
def test_pretty_unicode(): assert xpretty(oo, use_unicode=True) == u"\u221e" assert xpretty(pi, use_unicode=True) == u"\u03c0" assert xpretty(pi + 2 * x, use_unicode=True) in [u"\u03c0 + 2⋅x", u"2⋅x + \u03c0"] assert xpretty(pi ** 2 + exp(x), use_unicode=True) in [u" 2 x\n\u03c0 + \u212f ", u" x 2\n\u212f + \u03c0 "] assert xpretty(Ne(x, y), use_unicode=True) == u"x \u2260 y" assert xpretty(gamma(x), use_unicode=True) == u"\u0393(x)"
def test_pretty_unicode(): assert xpretty(oo, True) == u'\u221e' assert xpretty(pi, True) == u'\u03c0' assert xpretty(pi + 2 * x, True) in [u'\u03c0 + 2⋅x', u'2⋅x + \u03c0'] assert xpretty(pi**2 + exp(x), True) in [ u' 2 x\n\u03c0 + \u212f ', u' x 2\n\u212f + \u03c0 ' ] assert xpretty(Ne(x, y), True) == u'x \u2260 y' assert xpretty(gamma(x), True) == u'\u0393(x)'
def test_pretty_unicode(): assert xpretty( oo, use_unicode=True ) == u'\u221e' assert xpretty( pi, use_unicode=True ) == u'\u03c0' assert xpretty( pi+2*x, use_unicode=True ) in [u'\u03c0 + 2⋅x', u'2⋅x + \u03c0'] assert xpretty( pi**2+exp(x), use_unicode=True ) in [ u' 2 x\n\u03c0 + \u212f ', u' x 2\n\u212f + \u03c0 '] assert xpretty( Ne(x, y), use_unicode=True ) == u'x \u2260 y' assert xpretty( gamma(x), use_unicode=True ) == u'\u0393(x)'
def test_pretty_prec(): assert xpretty(S("0.3"), full_prec=True) == "0.300000000000000" assert xpretty(S("0.3"), full_prec="auto") == "0.300000000000000" assert xpretty(S("0.3"), full_prec=False) == "0.3" assert xpretty(S("0.3") * x, full_prec=True, use_unicode=False) in [ "0.300000000000000*x", "x*0.300000000000000" ] assert xpretty(S("0.3") * x, full_prec="auto", use_unicode=False) in ["0.3*x", "x*0.3"] assert xpretty(S("0.3") * x, full_prec=False, use_unicode=False) in ["0.3*x", "x*0.3"]
def pretty(expr): """ASCII pretty-printing""" return xpretty(expr, use_unicode=False, wrap_line=False)
def upretty(expr, order=None): """Unicode pretty-printing""" return xpretty(expr, order=order, use_unicode=True)
def pretty(expr, order=None): """ASCII pretty-printing""" return xpretty(expr, order=order, use_unicode=False)
def test_pretty_no_wrap_line(): huge_expr = 0 for i in range(20): huge_expr += i * sin(i + x) assert xpretty(huge_expr).find('\n') != -1 assert xpretty(huge_expr, wrap_line=False).find('\n') == -1
def test_pretty_no_wrap_line(): huge_expr = 0 for i in range(20): huge_expr += i*sin(i+x) assert xpretty(huge_expr ).find('\n') != -1 assert xpretty(huge_expr, wrap_line=False).find('\n') == -1
def upretty(expr): """Unicode pretty-printing""" return xpretty(expr, use_unicode=True, wrap_line=False)
def pretty(expr, order=None): # ascii-pretty by default return xpretty(expr, order=order, use_unicode=False)
def upretty(expr): """Unicode pretty-printing""" return xpretty(expr, use_unicode=True)
def test_pretty_str(): assert xpretty('a\nb') == 'a\nb'
def pretty(expr): # ascii-pretty by default return xpretty(expr, use_unicode=False)
def pretty(expr): # ascii-pretty by default return xpretty(expr, False)
def test_pretty_str(): assert xpretty("a\nb") == "a\nb"