Comment #4 on issue 1220 by asmeurer: w = Wild("coeff") fails
http://code.google.com/p/sympy/issues/detail?id=1220
This fails only on certain Python versions and architectures. The
name "coeff" doesn't seem to matter. It appears what matters is the
alphabetical order with respect to "rest":
In [1]: p = -x*(S(1)/8-y)
In [2]: p.match(Wild("coeff", exclude=[x])*x+Wild("rest"))
Out[2]: {coeff: 0, rest: -x⋅(1/8 - y)}
In [3]: p.match(Wild("w", exclude=[x])*x+Wild("rest"))
Out[3]: {rest: 0, w: -1/8 + y}
In [4]: p.match(Wild("e", exclude=[x])*x+Wild("rest"))
Out[4]: {e: -1/8 + y, rest: 0}
In [5]: p.match(Wild("ress", exclude=[x])*x+Wild("rest"))
Out[5]: {ress: -1/8 + y, rest: 0}
In [6]: p.match(Wild("resu", exclude=[x])*x+Wild("rest"))
Out[6]: {rest: -x⋅(1/8 - y), resu: 0}
I'm tempted to mark this as WontFix, since both are technically correct.
The result is non-unique. The exclude keyword should be used in
Wild("rest") (as in Wild("rest", exclude=[x])) to make the output unique:
In [7]: p.match(Wild("resu", exclude=[x])*x+Wild("rest", exclude=[x]))
Out[7]: {rest: 0, resu: -1/8 + y}
In [8]: p.match(Wild("ress", exclude=[x])*x+Wild("rest", exclude=[x]))
Out[8]: {ress: -1/8 + y, rest: 0}
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.