On Wed, Jan 28, 2009 at 5:23 AM,  <[email protected]> wrote:
>
> From: Fabian Seoane <[email protected]>
>
> The bug caused a wrong result when collect was called with
> a product as second argument, for example:
>
> collect(1+x*(y**2), x*y)
>
> Added some test for this also
>
> Some doctests were changed because multiple answers where correct:
>    - z*(1 + a) + x**2*y**4*(1 + z) (old behaviour)
>    - z*(1 + a + x**2*y**4) + x**2*y**4 (new behaviour)
> This test was however added to test_symplify.py
>
> Also, some doctests were uncommented since they work now ok
> ---
>  sympy/simplify/simplify.py            |   26 +++++++++++++--------
>  sympy/simplify/tests/test_simplify.py |   41 +++++++++++++++++++++++++++++++-
>  2 files changed, 55 insertions(+), 12 deletions(-)
>
> diff --git a/sympy/simplify/simplify.py b/sympy/simplify/simplify.py
> index 4ccc886..97eaf49 100644
> --- a/sympy/simplify/simplify.py
> +++ b/sympy/simplify/simplify.py
> @@ -1,4 +1,6 @@
>
> +from sympy import SYMPY_DEBUG
> +
>  from sympy.core import Basic, S, C, Add, Mul, Pow, Rational, Integer, \
>         Derivative, Wild, Symbol, sympify
>
> @@ -393,16 +395,13 @@ def collect(expr, syms, evaluate=True, exact=False):
>        >>> collect(x**2 + y*x**2 + x*y + y + a*y, [x, y])
>        x*y + y*(1 + a) + x**2*(1 + y)
>
> -       >>> collect(x**2*y**4 + z*(x*y**2)**2 + z + a*z, [x*y**2, z])
> -       z*(1 + a) + x**2*y**4*(1 + z)
> -
>        Also more complicated expressions can be used as patterns:
>
>        >>> collect(a*sin(2*x) + b*sin(2*x), sin(2*x))
>        (a + b)*sin(2*x)
>
> -       >>> collect(a*x**2*log(x)**2 + b*(x*log(x))**2, x*log(x))
> -       x**2*log(x)**2*(a + b)
> +       >>> collect(a*x*log(x) + b*(x*log(x)), x*log(x))
> +       x*(a + b)*log(x)


Looks good, only this new doctest tests a different thing than the old
one (e.g. log(x) vs log(x)**2). Let's add both cases to our regular
tests? Otherwise +1. E.g. This patch is +1, only the tests should be
improved in the later patch for example.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" 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-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to