Updates:
Labels: smichr NeedsReview
Comment #7 on issue 2511 by smi...@gmail.com: Document how to use lambdas
in replace (was: Bug with replace)
http://code.google.com/p/sympy/issues/detail?id=2511
https://github.com/sympy/sympy/pull/2062
In addition to updating the docstring, I rewrote replace so it works all
the way from the bottom up. replace and xreplace have similar limitations
but in different directions: from the bottom up, replace used to stop
making changes once sub-expression were changed, so x*(x*y + 1), though it
contains 2 Muls, would allow only changes to the x*y Mul; in xreplace,
which essentially works from the top down, processing stops once a change
is made, so the x*y would not be processed.
e = x*(x*y+1)
e.replace(lambda x: x.is_Mul, lambda x: 2*x)
x*(2*x*y + 1)
e.xreplace(Transform(lambda x: 2*x, lambda x: x.is_Mul))
2*x*(x*y + 1)
Now replace acts more as it advertises -- completely from the bottom up and
it does so in a simultaneous manner so it is not processing a changing
expression tree as it progresses from the bottom up. So with the PR below,
e.replace(lambda x: x.is_Mul, lambda x: 2*x)
2*x*(2*x*y + 1)
https://github.com/sympy/sympy/pull/2062
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.