def test_pprint(): Lorentz = TensorIndexType('Lorentz') i0, i1, i2, i3, i4 = tensor_indices('i0:5', Lorentz) A = tensorhead('A', [Lorentz], [[1]]) assert pretty(A) == 'A(Lorentz)' assert pretty(A(i0)) == 'A(i0)'
def test_render(): ustr = \ """\ 3 5 \n\ x x ⎛ \n\ x - ── + ─── + O⎝x\n\ 6 120 \n\ \n\ \n\ 6⎞\n\ ⎠\n\ \ """ assert pretty(sin(x).series(x), num_columns=20, use_unicode=True) == ustr
def test_ncol(): res = pretty(sin(x).series(x, n=20), num_columns=0) ans = """\ 3 5 7 9 11 13 15 \n\ x x x x x x x x\n\ x - ── + ─── - ──── + ────── - ──────── + ────────── - ───────────── + ───────\n\ 6 120 5040 362880 39916800 6227020800 1307674368000 3556874\n\ \n\ 17 19 \n\ x ⎛ 20⎞\n\ ──────── - ────────────────── + O⎝x ⎠\n\ 28096000 121645100408832000 \ """ assert res == ans
def test_dumb_term(capsys): print(pretty(sin(x))) assert capsys.readouterr().out == 'sin(x)\n'