Pretty printing
Thanks to a patch by Jurjen Bos (with some additions & modifications by me) we now got pretty printing in sympy. To see some examples, running it from isympy (you need sympy from svn):
In [1]: pprint x**2 +x +1 ——> pprint(x**2 +x +1) 2 1+x+x In [2]: pprint limit(x, x, oo, evaluate=False) ——> pprint(limit(x, x, oo, evaluate=False)) lim x x->oo In [3]: pprint sqrt(2) ——> pprint(sqrt(2)) ___ \/ 2Still nesting doesn’t work well and it certainly needs some polishing , but at least it works for simple things.
note that pprint is just a function defined in sympy.modules.printing.pretty , and there’s nothing specific about isympy, only that you can call it without the parenthesis because that’s a feature of ipython.
For the implementation details: following SAGE, we have agreed to put the code for creating a pretty picture into a classmethod called __pretty__(), and pretty, pprint is just a wrapper around that method.
I also commited initial latex support, this time using the same principle as __pretty__ (called __latex__), instead of using xsl on the mathml.
More things: we moved the hash algorithm to use MD5 hashes so that we get the same hashes in different platforms. Now all tests should pass ok in all architectures
April 29th, 2007 at 12:41 pm
Looks really good. Could you please put some info about prettyprinting into the tutorial?
Just a suggestion:
In [9]: pprint limit((5**x+3**x)**(1/x), x, oo, evaluate = False)
——> pprint(limit((5**x+3**x)**(1/x), x, oo, evaluate = False))
lim / -1\
x->oo \x /
/ x x\
\5 +3 /
Maybe the “lim” should be on the same base line as 5^x+3^x (and not at 1/x).
April 29th, 2007 at 12:42 pm
Well, the formatting got wrong.
April 29th, 2007 at 2:23 pm
yes, that’s a bug. You’re right, i’ll try to fix it in the afternoon.
April 29th, 2007 at 10:07 pm
Hey Fabian, I uploaded a patch for the nested square roots on the issues page, if you haven’t already fixed it!
April 29th, 2007 at 10:11 pm
cool. Thanks, it’s commited. The print thing is also fixed now