Comment #15 on issue 2307 by smi...@gmail.com: Duplicate methods:
as_coeff_mul and as_coeff_Mul
http://code.google.com/p/sympy/issues/detail?id=2307
I forget that as_coeff_foo already has a built-in mechanism to consider
what is the dependent part and what is the coeff part:
>>> (3*y*(x+2)).as_coeff_mul(Number)
(y, (3, 2 + x))
>>> (3.*y*(x+2)).as_coeff_mul(Number)
(y, (3.00000000000000, 2 + x))
>>> (3.*y*(x+2)*z).as_coeff_mul(Number)
(y*z, (3.00000000000000, 2 + x))
So using the Number argument will put Number-containing terms as arg1 and
if the first argument of that is a number it is the leading number on the
expression.
The following also works:
>>> (3.*y*(x+2)*z*pi).as_coeff_mul(pi)
(3.0*y*z*(2 + x), (pi,))
>>> (3.*y*(x+2)*z*pi*(pi+1)).as_coeff_mul(pi)
(3.0*y*z*(2 + x), (pi, 1 + pi))
Do we ever really need to split and expr into its leading number and the
remaining Mul or Add? I needed it in _pi_coeff but is it needed elsewhere?
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.