details: http://hg.sympy.org/sympy/rev/82b2b88d0332 changeset: 1785:82b2b88d0332 user: Hubert Tsang <[EMAIL PROTECTED]> date: Thu Oct 09 00:08:31 2008 +0200 description: Fixes polynomial order in LaTeX printing (#1126).
diffs (61 lines): diff -r 1b3bc62700cf -r 82b2b88d0332 sympy/printing/latex.py --- a/sympy/printing/latex.py Wed Oct 08 23:59:02 2008 +0200 +++ b/sympy/printing/latex.py Thu Oct 09 00:08:31 2008 +0200 @@ -28,9 +28,12 @@ return expr def _print_Add(self, expr): - tex = str(self._print(expr.args[0])) + args = list(expr.args) + args.sort(Basic._compare_pretty) - for term in expr.args[1:]: + tex = str(self._print(args[0])) + + for term in args[1:]: coeff = term.as_coeff_terms()[0] if coeff.is_negative: diff -r 1b3bc62700cf -r 82b2b88d0332 sympy/printing/tests/test_latex.py --- a/sympy/printing/tests/test_latex.py Wed Oct 08 23:59:02 2008 +0200 +++ b/sympy/printing/tests/test_latex.py Thu Oct 09 00:08:31 2008 +0200 @@ -10,14 +10,15 @@ k,n = symbols('kn', integer=True) def test_latex_basic(): - assert latex(1+x) in ["$1 + x$", '$x + 1$'] + assert latex(1+x) == "$1 + x$" assert latex(x**2) == "${x}^{2}$" - assert latex(x**(1+x)) in ["${x}^{1 + x}$", '${x}^{x + 1}$'] + assert latex(x**(1+x)) == "${x}^{1 + x}$" + assert latex(x**3+x+1+x**2) == "$1 + x + {x}^{2} + {x}^{3}$" def test_latex_symbols(): Gamma, lmbda, rho = map(Symbol, ('Gamma', 'lambda', 'rho')) mass, volume = map(Symbol, ('mass', 'volume')) - assert latex(Gamma + lmbda) in [r"$\Gamma + \lambda$", '$\lambda + \Gamma$'] + assert latex(Gamma + lmbda) == r"$\Gamma + \lambda$" assert latex(Gamma * lmbda) == r"$\Gamma \lambda$" assert latex(Symbol('q21')) == r"$q_{21}$" assert latex(Symbol('epsilon0')) == r"$\epsilon_{0}$" @@ -31,7 +32,7 @@ def test_latex_functions(): assert latex(exp(x)) == "${e}^{x}$" - assert latex(exp(1)+exp(2)) in ["${e}^{2} + e$", '$e + {e}^{2}$'] + assert latex(exp(1)+exp(2)) == "$e + {e}^{2}$" f = Function('f') assert latex(f(x)) == '$\\operatorname{f}\\left(x\\right)$' @@ -56,9 +57,8 @@ def test_latex_derivatives(): assert latex(diff(x**3, x, evaluate=False)) == \ r"$\frac{\partial}{\partial x} {x}^{3}$" - assert latex(diff(sin(x)+x**2, x, evaluate=False)) in [ - r"$\frac{\partial}{\partial x}\left({x}^{2} + \operatorname{sin}\left(x\right)\right)$", - r'$\frac{\partial}{\partial x}\left(\operatorname{sin}\left(x\right) + {x}^{2}\right)$'] + assert latex(diff(sin(x)+x**2, x, evaluate=False)) == \ + r"$\frac{\partial}{\partial x}\left(\operatorname{sin}\left(x\right) + {x}^{2}\right)$" def test_latex_integrals(): assert latex(Integral(log(x), x)) == r"$\int \operatorname{log}\left(x\right)\,dx$" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-commits" group. To post to this group, send email to sympy-commits@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-commits?hl=en -~----------~----~----~----~------~----~------~--~---