Does anyone have a better idea for how to canonicalize the args for
Add (perhaps Mul, too).

    >>> from sympy.abc import *
    >>> from sympy import *
    >>> 3*x+6*y
    3*x + 6*y
    >>> _.args
    (3*x, 6*y)
    >>> (x+2*y).args
    (2*y, x)
    >>> (2*x+2*y+z).args
    (2*y, z, 2*x)
    >>>

See how the args are unsorted -- at least in the sorted_key sense?
Work that I did in https://github.com/sympy/sympy/pull/370 on
primitive would be easier if all coefficient-1 args appeared at the
end of the args in the way that the Rational appears first. (How they
get printed is another matter and immaterial to this request.)
Basically, if this were true -- that the coeff=1 args were last in the
args --  then those that get their coefficient cleared out in the
removal of the primitive could be simply appended one by one to the
end of the args which could then be rebuilt with _new_rawargs.

Here are some more permutations showing how the args shift around:

    >>> (4*x+y+2*z).args
    (y, 2*z, 4*x)
    >>> (4*x+z+2*y).args
    (2*y, 4*x, z)
    >>> (4*y+x+2*z).args
    (4*y, 2*z, x)
    >>> (4*y+z+2*x).args
    (4*y, z, 2*x)
    >>> (4*z+x+2*y).args
    (4*z, 2*y, x)
    >>> (4*z+y+2*x).args
    (4*z, y, 2*x)

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to