Exemple #1
0
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)
Exemple #3
0
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)"
Exemple #6
0
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)'
Exemple #7
0
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)'
Exemple #8
0
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"]
Exemple #9
0
def pretty(expr):
    """ASCII pretty-printing"""
    return xpretty(expr, use_unicode=False, wrap_line=False)
Exemple #10
0
def upretty(expr, order=None):
    """Unicode pretty-printing"""
    return xpretty(expr, order=order, use_unicode=True)
Exemple #11
0
def pretty(expr, order=None):
    """ASCII pretty-printing"""
    return xpretty(expr, order=order, use_unicode=False)
Exemple #12
0
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
Exemple #13
0
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
Exemple #14
0
def upretty(expr):
    """Unicode pretty-printing"""
    return xpretty(expr, use_unicode=True, wrap_line=False)
Exemple #15
0
def upretty(expr):
    """Unicode pretty-printing"""
    return xpretty(expr, use_unicode=True, wrap_line=False)
Exemple #16
0
def pretty(expr, order=None):
    # ascii-pretty by default
    return xpretty(expr, order=order, use_unicode=False)
Exemple #17
0
def upretty(expr):
    """Unicode pretty-printing"""
    return xpretty(expr, use_unicode=True)
Exemple #18
0
def test_pretty_str():
    assert xpretty('a\nb') == 'a\nb'
Exemple #19
0
def pretty(expr):
    # ascii-pretty by default
    return xpretty(expr, use_unicode=False)
Exemple #20
0
def pretty(expr):
    # ascii-pretty by default
    return xpretty(expr, False)
Exemple #21
0
def pretty(expr):
    """ASCII pretty-printing"""
    return xpretty(expr, use_unicode=False, wrap_line=False)
def test_pretty_str():
    assert xpretty("a\nb") == "a\nb"
Exemple #23
0
def pretty(expr):
    # ascii-pretty by default
    return xpretty(expr, use_unicode=False)
Exemple #24
0
def upretty(expr):
    """Unicode pretty-printing"""
    return xpretty(expr, use_unicode=True)
Exemple #25
0
def test_pretty_str():
    assert xpretty('a\nb') == 'a\nb'
Exemple #26
0
def pretty(expr, order=None):
    """ASCII pretty-printing"""
    return xpretty(expr, order=order, use_unicode=False)
Exemple #27
0
def upretty(expr, order=None):
    """Unicode pretty-printing"""
    return xpretty(expr, order=order, use_unicode=True)
Exemple #28
0
def pretty(expr):
    # ascii-pretty by default
    return xpretty(expr, False)