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. > > >> Another question that it seems that `./bin/test` utility doesn't clear >> caching before file testings. I think it must to do it. So I create an >> issue for it. >> >> >> >> > -- > 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.
