Hi,

2011/5/5 Alexey U. Gudchenko <[email protected]>

> 06.05.2011 01:15, Mateusz Paprocki пишет:
> > Hi,
> >
> > On 5 May 2011 14:10, Tom Bachmann <[email protected]> wrote:
> >
> >> On 05.05.2011 21:52, Alexey U. Gudchenko wrote:
> >>
> >>> 05.05.2011 22:47, smichr пишет:
> >>>
> >>>> Can someone else test [ https://github.com/sympy/sympy/pull/87 ] and
> >>>> see if you get failures? There are two commits there. Failures when
> >>>> testing expr.py (and other files) show up for some but not for me
> >>>> (W32).
> >>>>
> >>>> Ronan thinks it might be related to keep_sign. That could be...but I
> >>>> don't see where in the code that I have used (including apart) that
> >>>> the value of keep_sign changes.
> >>>>
> >>>> Maybe someone else can see the problem.
> >>>>
> >>>> Thanks.
> >>>> /c
> >>>>
> >>>>
> >>> Yes, I observe the errors while running all test in various files :
> >>>
> >>>     $ ./bin/test
> >>>
> >>> And in particular in the test_expr.py file.
> >>>
> >>> But when I run only one
> >>>
> >>>     $ ./bin/test test_expr.py
> >>>
> >>> there is no errors.
> >>>
> >>> Therefore tests depends on the order of testing of files.
> >>>
> >>> I determined that it is related with test_sums_products.py. When I run
> >>>
> >>>     $ ./bin/test test_sums_products.py test_expr.py
> >>>
> >>> the errors begin fails.
> >>>
> >>> And precisely with this lines:
> >>>     assert Sum(1/x/(x - 1), (x, a, b)).doit() == -1/b - 1/(1 - a)
> >>>
> >>> When I comment it, then all tests in all files are passed without
> errors.
> >>>
> >>> It seems that it is related with caching.
> >>>
> >>> If I add at the `test_sums_products.py` after this (#174):
> >>>     assert Sum(1/x/(x - 1), (x, a, b)).doit() == -1/b - 1/(1 - a)
> >>>
> >>> this line
> >>>     clear_cache()
> >>> then all tests in all files are passed without errors.
> >>>
> >>> So this is a solution apparently.
> >>>
> >>>
> >> Not really. But that was a great start!
> >>
> >> Imho clearing the cache is never the solution. The underlying problem is
> >> that Basic.keep_sign is not being cached properly. Basic.keep_sign
> affects
> >> results, so it has to be part of the caching hash. This two-line patch
> >> removes the failures:
> >>
> >> diff --git a/sympy/core/cache.py b/sympy/core/cache.py
> >> index af20ce1..24b5ca1 100644
> >> --- a/sympy/core/cache.py
> >> +++ b/sympy/core/cache.py
> >> @@ -93,7 +93,8 @@ def wrapper(*args, **kw_args):
> >>             k = args + tuple(items)
> >>         else:
> >>             k = args
> >> -        k = k + tuple(map(lambda x: type(x), k))
> >> +        from sympy.core import Basic
> >> +        k = k + tuple(map(lambda x: type(x), k)) +
> >> tuple([Basic.keep_sign])
> >>         try:
> >>             return func_cache_it_cache[k]
> >>         except KeyError:
> >>
> >> There might be ways of doing this that are cleaner implementation-wise
> or
> >> conceptually. The underlying problem again is that there is global state
> >> affecting sympy computations that the cache does not know about.
> >>
> >>
> > There is a reason why we use cache -> speed, so clearing it "here and
> there"
> > is not a solution. Anyway, I hope that keep_sign will be gone this week,
> > unless there will be some severe test failures.
> >
> >
>
>
> Yes, I ment that it is a temporary solution (insert clear_cache() in
> pointed line) to avoid the influence of one test file to another ones.
>
> But I agree that this solution hide the problems with caching errors,
> which can be resolved too.
>

To see what cache does with SymPy, run bin/test as follows:

$ SYMPY_USE_CACHE=no bin/test

I got the following result:

________________________________________________________________________________
_________________ sympy/core/tests/test_eval.py:test_function
__________________
  File "/home/mateusz/repo/git/sympy/sympy/core/tests/test_eval.py", line
81, in test_function
    assert exp(l(x))*l(x)/exp(l(x)) == l(x)
AssertionError
________________________________________________________________________________
_____________ sympy/matrices/tests/test_matrices.py:test_simplify
______________
  File "/home/mateusz/repo/git/sympy/sympy/matrices/tests/test_matrices.py",
line 910, in test_simplify
    [   1 + y,       2*((1 - 1*cos(pi*n))/(pi*n)) ]])
AssertionError
________________________________________________________________________________
_______________ sympy/printing/tests/test_repr.py:test_Function
________________
  File "/home/mateusz/repo/git/sympy/sympy/printing/tests/test_repr.py",
line 38, in test_Function
    sT(Function("f")(x), "Function('f')(Symbol('x'))")
  File "/home/mateusz/repo/git/sympy/sympy/printing/tests/test_repr.py",
line 22, in sT
    assert eval(string, ENV) == expr
AssertionError
________________________________________________________________________________
_____________ sympy/simplify/tests/test_simplify.py:test_simplify
______________
  File "/home/mateusz/repo/git/sympy/sympy/simplify/tests/test_simplify.py",
line 131, in test_simplify
    assert simplify(e) == 1 + y
AssertionError
________________________________________________________________________________
_______________ sympy/test_external/test_numpy.py:test_symarray
________________
  File "/home/mateusz/repo/git/sympy/sympy/test_external/test_numpy.py",
line 256, in test_symarray
    assert s1[0] is s2[0]
AssertionError
________________________________________________________________________________
___________ sympy/utilities/tests/test_lambdify.py:test_sympy_lambda
___________
  File
"/home/mateusz/repo/git/sympy/sympy/utilities/tests/test_lambdify.py", line
77, in test_sympy_lambda
    assert f(x) is sin(x)
AssertionError

 tests finished: 2660 passed, 6 failed, 5 skipped, 53 expected to fail,
3 expected to fail but passed, in 1055.75 seconds
DO *NOT* COMMIT!

Most of those problems are already known and mostly related to Function. It
took 1056 seconds to run the whole test suit. With cache it takes only 210
seconds (Xeon 3.0 GHz).


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

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

Reply via email to