odd failures need another eye

9 views
Skip to first unread message

smichr

unread,
May 5, 2011, 2:47:38 PM5/5/11
to sympy
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

Alexey U. Gudchenko

unread,
May 5, 2011, 4:52:34 PM5/5/11
to sy...@googlegroups.com
05.05.2011 22:47, smichr пишет:

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.


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.

--
Alexey U.

Tom Bachmann

unread,
May 5, 2011, 5:10:17 PM5/5/11
to sy...@googlegroups.com

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.

Mateusz Paprocki

unread,
May 5, 2011, 5:15:26 PM5/5/11
to sy...@googlegroups.com
Hi,

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 sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.


Mateusz

Alexey U. Gudchenko

unread,
May 5, 2011, 5:30:38 PM5/5/11
to sy...@googlegroups.com
06.05.2011 01:15, Mateusz Paprocki пишет:


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.

--
Alexey U.

Mateusz Paprocki

unread,
May 5, 2011, 5:54:57 PM5/5/11
to sy...@googlegroups.com
Hi,

2011/5/5 Alexey U. Gudchenko <pr...@goodok.ru>
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 sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.


Mateusz

Alexey U. Gudchenko

unread,
May 5, 2011, 6:33:13 PM5/5/11
to sy...@googlegroups.com
06.05.2011 01:54, Mateusz Paprocki пишет:

Well, I forget about $SYMPY_USE_CACHE, and that the cache system can be
hard tested with the help of this environment variable.

But when I wrote about the clearing of cache (new issue 2341 created
just now) I ment that it will be better to isolate some groups of tests
(which are grouped in the files "test_something.py") from the other
groups, therefore to clear cache only after the every test file, and do
not switch off the entire cache system for every calculation at whole as
the $SYMPY_USE_CACHE variable does.

In this case the slowing down is not so significant:

(a) - do not clear cache for every file: 276.15 - 277.72 seconds.
(b) - clear cache after every test (test function): 273.70 - 274.49
seconds.
(c) - clear cache after every test file: 264.04 seconds.

P.S. I specially carried out twice, because I noticed that (b) is
insignificantly faster then (a) unexpectedly.

--
Alexey U.

smichr

unread,
May 5, 2011, 10:28:44 PM5/5/11
to sympy
So can we put Tom's patch in if even for a week? That will mean that
my other work can get pushed.

Alexey U. Gudchenko

unread,
May 7, 2011, 5:27:47 AM5/7/11
to sy...@googlegroups.com
06.05.2011 06:28, smichr пишет:

> So can we put Tom's patch in if even for a week? That will mean that
> my other work can get pushed.
>

We - can. (I can't becouse I have not enough knowlage about
Basic.keep_sign problem exactly).

In this thread we discover three problems:

(1) Hanging of your branch, which do not pass the tests.

(2) The influence of the tests to another, dependency of test utility
result on they order - becouse cache is not clearing while we test a set
of files (and while we are logicaly group them by test files)

(3) Basic.keep_sign

The (1) can be resolved with the help of (2) or (3) (those are
independent issues in any case), or even manually, as I wrote above, by
the adding clear_cashe() after pointed line, but it is turned out that
it is not quite good solution and only temporary to resolve (1)
immediately though.

And I suppose, of cause, that the Basic.keep_sign is changed in the sum
telescope procedure validly and with the reasons.

P.S. clearing of the cache is resolved in

[1] https://github.com/sympy/sympy/pull/293

--
Alexey U.

Reply all
Reply to author
Forward
0 new messages