Testing question

112 views
Skip to first unread message

Kate MacInnis

unread,
Sep 28, 2015, 4:31:43 PM9/28/15
to sympy
I just want to make sure I understand how testing is supposed to work, before I start going through the code looking for the source of (what I think is) weirdness.

If I run `sympy.test('test_frame')` and get:

sympy/physics/vector/tests/test_frame.py[4] .EE.                               [FAIL]

_____________________________________________________________________________________
_______________ sympy
/physics/vector/tests/test_frame.py:test_ang_vel _______________
 
File "/users/kate/devstuff/sympy/sympy/physics/vector/tests/test_frame.py", line 65, in test_ang_vel
...


then I should be able to do
>>> from sympy.physics.vector.tests.test_frame import test_ang_vel
>>> test_ang_vel()

and get the same error, right?  Or is that not what is supposed to happen?

Aaron Meurer

unread,
Sep 28, 2015, 4:44:50 PM9/28/15
to sy...@googlegroups.com
I think that should work. Usually when a test fails, I open the file
and take a look at it, and run the code manually if I need to, but the
test runner doesn't do anything more than just import the modules and
run all the functions that start with "test_".

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/70260765-bde6-424f-9cb1-1b813f6ef671%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jason Moore

unread,
Sep 28, 2015, 5:11:53 PM9/28/15
to sy...@googlegroups.com
Kate,

Could you paste in more of the traceback from the test run?

Kate MacInnis

unread,
Sep 28, 2015, 6:57:49 PM9/28/15
to sympy
Sure:

In [7]: test('test_frame.py')
================================ test process starts ================================
executable
:         /Users/kate/.virtualenvs/symp/bin/python  (3.5.0-final-0) [CPython]
architecture
:       64-bit
cache
:              yes
ground types
:       python
random seed
:        41896037
hash randomization
: on (PYTHONHASHSEED=938978246)


sympy
/physics/vector/tests/test_frame.py[4] .EE.                               [FAIL]

_____________________________________________________________________________________
_______________ sympy
/physics/vector/tests/test_frame.py:test_ang_vel _______________
 
File "/users/kate/devstuff/sympy/sympy/physics/vector/tests/test_frame.py", line 65, in
test_ang_vel
    A
= N.orientnew('A', 'Axis', [q1, N.z])
 
File "/Users/kate/devstuff/sympy/sympy/physics/vector/frame.py", line 640, in orientnew
    newframe
.orient(self, rot_type, amounts, rot_order)
 
File "/Users/kate/devstuff/sympy/sympy/physics/vector/frame.py", line 523, in orient
   
[-axis[1], axis[0], 0]]) * sin(theta) + axis * axis.T)
 
File "/Users/kate/devstuff/sympy/sympy/core/cache.py", line 93, in wrapper
    retval
= cfunc(*args, **kwargs)
 
File "/Users/kate/devstuff/sympy/sympy/core/function.py", line 376, in __new__
    result
= super(Function, cls).__new__(cls, *args, **options)
 
File "/Users/kate/devstuff/sympy/sympy/core/cache.py", line 93, in wrapper
    retval
= cfunc(*args, **kwargs)
 
File "/Users/kate/devstuff/sympy/sympy/core/function.py", line 200, in __new__
    evaluated
= cls.eval(*args)
 
File "/Users/kate/devstuff/sympy/sympy/functions/elementary/trigonometric.py", line 469, in eval
   
if arg.could_extract_minus_sign():
 
File "/Users/kate/devstuff/sympy/sympy/core/expr.py", line 2088, in could_extract_minus_sign
    negative_self
= -self
 
File "/Users/kate/devstuff/sympy/sympy/core/expr.py", line 112, in __neg__
   
return Mul(S.NegativeOne, self)
 
File "/Users/kate/devstuff/sympy/sympy/core/cache.py", line 93, in wrapper
    retval
= cfunc(*args, **kwargs)
KeyError: (<class 'sympy.core.add.Add'>, A_z, -A_z, <class 'sympy.core.assumptions.ManagedProperties'>, <class 'sympy.physics.vector.frame.CoordinateSym'>, <class 'sympy.core.mul.Mul'>)
_____________________________________________________________________________________
_________________ sympy
/physics/vector/tests/test_frame.py:test_dcm _________________
 
File "/users/kate/devstuff/sympy/sympy/physics/vector/tests/test_frame.py", line 130, in test_dcm
    A
= N.orientnew('A', 'Axis', [q1, N.z])
 
File "/Users/kate/devstuff/sympy/sympy/physics/vector/frame.py", line 640, in orientnew
    newframe
.orient(self, rot_type, amounts, rot_order)
 
File "/Users/kate/devstuff/sympy/sympy/physics/vector/frame.py", line 523, in orient
   
[-axis[1], axis[0], 0]]) * sin(theta) + axis * axis.T)
 
File "/Users/kate/devstuff/sympy/sympy/core/cache.py", line 93, in wrapper
    retval
= cfunc(*args, **kwargs)
 
File "/Users/kate/devstuff/sympy/sympy/core/function.py", line 376, in __new__
    result
= super(Function, cls).__new__(cls, *args, **options)
 
File "/Users/kate/devstuff/sympy/sympy/core/cache.py", line 93, in wrapper
    retval
= cfunc(*args, **kwargs)
 
File "/Users/kate/devstuff/sympy/sympy/core/function.py", line 200, in __new__
    evaluated
= cls.eval(*args)
 
File "/Users/kate/devstuff/sympy/sympy/functions/elementary/trigonometric.py", line 469, in eval
   
if arg.could_extract_minus_sign():
 
File "/Users/kate/devstuff/sympy/sympy/core/expr.py", line 2088, in could_extract_minus_sign
    negative_self
= -self
 
File "/Users/kate/devstuff/sympy/sympy/core/expr.py", line 112, in __neg__
   
return Mul(S.NegativeOne, self)
 
File "/Users/kate/devstuff/sympy/sympy/core/cache.py", line 93, in wrapper
    retval
= cfunc(*args, **kwargs)
KeyError: (<class 'sympy.core.mul.Mul'>, A_x, 1, <class 'sympy.core.assumptions.ManagedProperties'>, <class 'sympy.physics.vector.frame.CoordinateSym'>, <class 'sympy.core.numbers.One'>)

============== tests finished: 2 passed, 2 exceptions, in 2.28 seconds ==============
DO
*NOT* COMMIT!
Out[7]: False


This is running the current master branch on Python 3.5.

Kate MacInnis

unread,
Sep 28, 2015, 7:17:26 PM9/28/15
to sympy
Alright, I might try to delve into the test runner then.  I'm running this on Python 3.5, and there are several oddities, including an error that interrupts the test running process if you run `test("vector")` but not `test('sympy/physics/vector/tests/test_functions')` -- but if you comment out the entire file sympy/physics/vector/tests/test_functions.py, then `test("vector")` completes.

Aaron Meurer

unread,
Sep 28, 2015, 8:15:12 PM9/28/15
to sy...@googlegroups.com
I think this might have to do with fastcache. If I install it, the
test passes, but if I remove it, it fails.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/1c016950-a16f-46df-875d-6b4fa229b86f%40googlegroups.com.

Kate MacInnis

unread,
Sep 28, 2015, 8:42:08 PM9/28/15
to sympy
Awesome.  That fixes all 7 errors in physics/vector and vector.  So in 3.4 it works with or without fastcache, in 3.5 it works only with fastcache.

The only other problem I got was in sympify, where the expected error for "lambda *args: args" changes from a SyntaxError to a TypeError, because of the changes to sequence unpacking in 3.5.  So that's a simple fix.

Aaron Meurer

unread,
Sep 28, 2015, 8:43:58 PM9/28/15
to sy...@googlegroups.com
This does need to be fixed, though. I suspect it's a bug in fastcache.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/a500f9f0-aeb8-4619-af7d-ec733b078ff0%40googlegroups.com.

Kate MacInnis

unread,
Sep 28, 2015, 9:06:53 PM9/28/15
to sympy
Oh, sure.  Didn't mean to imply that it doesn't, I'm just happy that I can start my next project using sympy and python 3.5.

Although, I am confused-- how can it be a bug in fastcache if it only shows up when fastcache isn't installed?

Francesco Bonazzi

unread,
Sep 29, 2015, 4:36:59 AM9/29/15
to sympy


On Tuesday, 29 September 2015 03:06:53 UTC+2, Kate MacInnis wrote:
Oh, sure.  Didn't mean to imply that it doesn't, I'm just happy that I can start my next project using sympy and python 3.5.

Although, I am confused-- how can it be a bug in fastcache if it only shows up when fastcache isn't installed?


Just trying a blind guess: maybe it's the order of dicts and sets which was varied in Python 3.5?

I mean, there might be some code which relies on the order of elements in  a dict or set, which of course is a bug, as those data structures are supposed to be unordered. A slight change the data structures for dict/set between Python versions might cause such a bug.

Peter Brady

unread,
Sep 29, 2015, 8:40:22 AM9/29/15
to sympy
3.5 also introduced an lru_cache in c.

Peter Brady

unread,
Sep 29, 2015, 11:17:10 AM9/29/15
to sympy
The tests pass using the 3.5 lru_cache if we make it unbounded:

$ SYMPY_CACHE_SIZE=none /usr/local/python-3.5.0/bin/python3
Python 3.5.0 (default, Sep 23 2015, 14:54:30)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import test
>>> test("test_frame")
============================= test process starts ==============================
executable
:         /usr/local/python-3.5.0/bin/python3  (3.5.0-final-0) [CPython]

architecture
:       64-bit
cache
:              yes
ground types
:
      python
random seed
:        3721264
hash randomization
: on (PYTHONHASHSEED=117906637)


sympy
/physics/vector/tests/test_frame.py[4] ....                            [OK]


================== tests finished: 4 passed, in 3.21 seconds ===================
True


Seems like a bug in the new 3.5 lru_cache

Aaron Meurer

unread,
Sep 29, 2015, 12:27:47 PM9/29/15
to sy...@googlegroups.com
On Mon, Sep 28, 2015 at 8:06 PM, Kate MacInnis <macin...@gmail.com> wrote:
> Oh, sure. Didn't mean to imply that it doesn't, I'm just happy that I can
> start my next project using sympy and python 3.5.
>
> Although, I am confused-- how can it be a bug in fastcache if it only shows
> up when fastcache isn't installed?

Oh, I guess I got that backwards. Peter's assessment that it's a bug
in lru_cache sounds right. We should determine if it really is a bug
in lru_cache and not just in the way we are using it, and if so,
report this to upstream CPython.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/1d00e4ec-0aac-46a8-9f67-da4dbfd823c4%40googlegroups.com.

Peter Brady

unread,
Sep 30, 2015, 1:19:41 PM9/30/15
to sy...@googlegroups.com
Any ideas on how to test this and turn it into a reasonable bug report?

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/AnwYTJGRBB4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

Aaron Meurer

unread,
Sep 30, 2015, 2:29:48 PM9/30/15
to sy...@googlegroups.com
I guess if you have the time you can debug it and try to figure out
what is going on. I guess you could also just submit a bug report to
bugs.python.org with steps to reproduce it.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/CALoNiQctpgNG0rYtS9_e9Z2FZGc9eBKhS9mwuhfzCp2Hb%3D6NJQ%40mail.gmail.com.

Kate MacInnis

unread,
Oct 1, 2015, 10:45:26 PM10/1/15
to sympy
I don't have any previous experience with caching (and I don't have tons of time to spend on this), so I'm of no help with debugging lru_cache, but this change fixes all the broken cache-related tests. Are there any problems caused by catching KeyError here? 

Peter Brady

unread,
Oct 1, 2015, 11:31:04 PM10/1/15
to sy...@googlegroups.com
The big concern is that we shouldn't ever trigger a KeyError.  I suspect the new lru_cache in 3.5 was not supposed to change this behavior but was simply supposed to be more performant than the 3.4 version 

On Thu, Oct 1, 2015 at 8:45 PM, Kate MacInnis <macin...@gmail.com> wrote:
I don't have any previous experience with caching (and I don't have tons of time to spend on this), so I'm of no help with debugging lru_cache, but this change fixes all the broken cache-related tests. Are there any problems caused by catching KeyError here? 

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/AnwYTJGRBB4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

Peter Brady

unread,
Oct 2, 2015, 12:00:40 AM10/2/15
to sympy


On Thursday, October 1, 2015 at 9:31:04 PM UTC-6, Peter Brady wrote:
The big concern is that we shouldn't ever trigger a KeyError.  I suspect the new lru_cache in 3.5 was not supposed to change this behavior but was simply supposed to be more performant than the 3.4 version 
On Thu, Oct 1, 2015 at 8:45 PM, Kate MacInnis <macin...@gmail.com> wrote:
I don't have any previous experience with caching (and I don't have tons of time to spend on this), so I'm of no help with debugging lru_cache, but this change fixes all the broken cache-related tests. Are there any problems caused by catching KeyError here? 

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/AnwYTJGRBB4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+unsubscribe@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages