Sympy Live Shell

86 views
Skip to first unread message

gadha007

unread,
Dec 20, 2012, 3:13:27 AM12/20/12
to sy...@googlegroups.com
I was just trying to run 'physics.mechanics' in the sympy live shell on the documentation page but I got timed out. Any idea why this is happening? And could someone tell me if there is there a fix for the issue?

Thanks
Angadh

Aaron Meurer

unread,
Dec 20, 2012, 4:02:04 AM12/20/12
to sy...@googlegroups.com
Unfortunately, whenever SymPy Live gets any error at all, it says
"Time limit exceeded". The actual error in this case is that
ReferenceFrame is not pickable. You can reproduce this in regular
SymPy with

import pickle
from sympy.physics.mechanics import ReferenceFrame
pickle.load(pickle.dumps(ReferenceFrame("N")))

I opened https://code.google.com/p/sympy/issues/detail?id=3570 and
https://code.google.com/p/sympy/issues/detail?id=3569 for these
respective issues.

And an aside: we really should look at better ways to serialize
objects in SymPy live than pickle. It causes tons of problems,
because SymPy objects are very complex, and tend to be not pickable or
almost not pickable. The last time this happened, it showed up in a
very bizarre way, and ended up being very difficult to track down, and
very difficult to fix (see
https://code.google.com/p/sympy/issues/detail?id=2587). Also, some
fundamental SymPy objects (namely Function) are still not pickable,
and it would require a fundamental rewrite to make them so (see
https://code.google.com/p/sympy/issues/detail?id=1198; hopefully
ReferenceFrame doesn't have the same issue). And from my memory, there
are also issues with limitations in pickle (you can't send keyword
arguments to __new__ or something like that).

Does anyone know of a more general way we can serialize our data? I
thought marshal would be it, but apparently it is even more limited
than pickle. Otherwise, we just need to fight the good fight for
pickablility, just like we did for hash randomization and .args
reconstruction, until we are confidant that everything in the library
works. Unfortunately, unlike making obj.__class__(obj.args) == obj or
even fixing hash difference errors, making things pickable is *very*
difficult in general, and requires some pretty hefty knowledge of how
Python classes work and how we use them.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/wYVT2vucOvYJ.
> 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.

Matthew Rocklin

unread,
Dec 20, 2012, 9:19:51 AM12/20/12
to sy...@googlegroups.com
In many cases we can serialize and reconstruct through str.  Is this not an option?  If obj.__class__(*obj.args) works then why can't we serialize through

str(type(obj)) + "(" + ", ".join(map(str, obj.args)) " + ")"

Aaron Meurer

unread,
Dec 20, 2012, 5:03:55 PM12/20/12
to sy...@googlegroups.com
For SymPy Live to work, serialization needs to be perfect, because
literally all data is saved and reloaded between sessions. String
serialization works even less often than pickle. There is srepr,
which gets closer, but it has known issues too (like the fact that it
doesn't include assumptions).

Aaron Meurer
Reply all
Reply to author
Forward
0 new messages