sympy / sympy

A computer algebra system written in pure Python
https://sympy.org/
Other
12.96k stars 4.43k forks source link

Wrong printing in SymPy Live #6971

Open asmeurer opened 11 years ago

asmeurer commented 11 years ago
Try playing with the example at http://docs.sympy.org/tutorial/tutorial/simplification.html#example-continued-fractions , particularly the part at the very bottom.  The frac object prints as one thing in LaTeX, but if you do "print frac", you get what it actually is, which is different.  I've uploaded a screenshot. Notice how the printed expression is different from the LaTeX one (the apart expression is different, which you can verify is not the same as the first one).

My guess is that this has something to do with pickling, similar to issue 5686 .

Original issue for #6971: http://code.google.com/p/sympy/issues/detail?id=3872 Original author: https://code.google.com/u/asmeurer@gmail.com/ Referenced issues: #5686

asmeurer commented 11 years ago
If you remove the "del l", and then print what l is, it corresponds to the wrong result. So maybe something was done incorrectly in the mutation fix from issue 6963 .

**Cc:** li.david...@gmail.com  

Referenced issues: #6963 Original comment: http://code.google.com/p/sympy/issues/detail?id=3872#c1 Original author: https://code.google.com/u/asmeurer@gmail.com/

lidavidm commented 11 years ago
At least with the shuffle...Every time you execute "l", a different result returns, making me think an unpicklable is making Live reevaluate the shuffle for each request. Before it just didn't notice that l changed.

Original comment: http://code.google.com/p/sympy/issues/detail?id=3872#c2 Original author: https://code.google.com/u/112898427768461421869/

lidavidm commented 11 years ago
There's another bug, if a print statement is part of a statement that creates an unpicklable, when that statement is reevaluated, the print statement executes and outputs to the browser, causing a parse error (at least on the dev server).

At least on the dev server, for some reason Live is seeing '__builtin__' as an unpicklable and storing every statement as an unpicklable. Also, what's happening is the 'old_globals' is reinitialized along with the statement globals dictionary; this means that they share mutable values that came from unpickling. So that's the issue (there are a couple issues at play here), I'll have a PR tonight.

Original comment: http://code.google.com/p/sympy/issues/detail?id=3872#c3 Original author: https://code.google.com/u/112898427768461421869/