Pretty printing with latest sympy

30 views
Skip to first unread message

Gael Varoquaux

unread,
Apr 9, 2008, 3:39:03 PM4/9/08
to sy...@googlegroups.com
Hi guys,

I am being stupid (and not reading the manual :->): I want to show the
nice pretty printing of sympy in ipython. To get the nicest I check out
the hg trunk.

But I can't get it working (no multiline output). I must be missing some
switch.

On a side note, I must be missing some dependency for isympy:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
~ $ isympy
---------------------------------------------------------------------------
ImportError Traceback (most recent call
last)

/home/varoquau/dev/<input> in <module>()
----> 1
2
3
4
5

ImportError: No module named interactive
Python 2.5.1 console for SymPy 0.4.2

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z = symbols('xyz')
>>> k, m, n = symbols('kmn', integer=True)
>>> f = Function("f")

Documentation can be found at http://sympy.org/

In [1]:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Cheers,

Gaël

Mateusz Paprocki

unread,
Apr 9, 2008, 3:50:49 PM4/9/08
to sy...@googlegroups.com
Hi Gael,

it seems that your are mixing old SymPy 0.4.2 with latest isympy.

isympy will import globally availably sympy module (eg.
/usr/share/python2.5/ ...). However if you would cd to hg root
directory and run ./bin/isympy then it will import locally available
module tree, eg.:

matt@neutrino ~ $ cd hg/sympy
matt@neutrino ~/hg/sympy $ ./bin/isympy -q
Python 2.5.1 console for SymPy 0.5.13-hg

In [1]:
Do you really want to exit ([y]/n)?
Exiting ...
matt@neutrino ~/hg/sympy $ cd bin/
matt@neutrino ~/hg/sympy/bin $ ./isympy -q


---------------------------------------------------------------------------
ImportError Traceback (most recent call last)

/home/matt/hg/sympy/bin/<input> in <module>()


----> 1
2
3
4
5

ImportError: No module named interactive

Python 2.5.1 console for SymPy 0.5.13

In [1]:
Do you really want to exit ([y]/n)?
Exiting ...
matt@neutrino ~/hg/sympy/bin $

Mateusz

2008/4/9, Gael Varoquaux <gael.va...@normalesup.org>:

Gael Varoquaux

unread,
Apr 9, 2008, 4:12:57 PM4/9/08
to sy...@googlegroups.com
On Wed, Apr 09, 2008 at 09:50:49PM +0200, Mateusz Paprocki wrote:
> it seems that your are mixing old SymPy 0.4.2 with latest isympy.

Strange. I am probably getting all mixed up with virtualenv again. You
are probably right that the wrong versions get imported, but I don't
undestand where.

> isympy will import globally availably sympy module (eg.
> /usr/share/python2.5/ ...). However if you would cd to hg root
> directory and run ./bin/isympy then it will import locally available
> module tree, eg.:

That does solve the problem. I won't try to look further.

My original question remains, though, how can I enable multiline pretty
printing in vanilly ipython? It does work in isympy.

Cheers,

Gaėl

Mateusz Paprocki

unread,
Apr 9, 2008, 4:22:01 PM4/9/08
to sy...@googlegroups.com
> My original question remains, though, how can I enable multiline pretty
> printing in vanilly ipython? It does work in isympy.

There are two ways to achieve this:

[1] init_ipython() from sympy.interactive

[2] ipythonrc-sympy from data/IPython
(you will need to copy it manually into ~/.ipython)

(both were added in 0.5.13-hg so you will need latest repo).

Examples:

matt@neutrino ~/hg/sympy $ ipython -nobanner

In [1]: from sympy.interactive import *

In [2]: init_ipython()

In [3]: solve([x+y-z, x-y+2*z],[x,y])
Out[3]:
⎧ 3*z -z⎫
⎨y: ───, x: ──⎬
⎩ 2 2 ⎭

In [4]:


Do you really want to exit ([y]/n)?
Exiting ...

matt@neutrino ~/hg/sympy $ ipython -p sympy


Python 2.5.1 console for SymPy 0.5.13-hg

In [1]: solve([x+y-z,x-y+2*z], [x,y])
Out[1]:
⎧ 3*z -z⎫
⎨y: ───, x: ──⎬
⎩ 2 2 ⎭

In [2]:

Mateusz

2008/4/9, Gael Varoquaux <gael.va...@normalesup.org>:
>

> Gaël
>
> >
>

Gael Varoquaux

unread,
Apr 9, 2008, 4:26:23 PM4/9/08
to sy...@googlegroups.com
On Wed, Apr 09, 2008 at 10:22:01PM +0200, Mateusz Paprocki wrote:
> matt@neutrino ~/hg/sympy $ ipython -nobanner

> In [1]: from sympy.interactive import *

> In [2]: init_ipython()

> In [3]: solve([x+y-z, x-y+2*z],[x,y])
> Out[3]:
> ⎧ 3*z -z⎫
> ⎨y: ───, x: ──⎬
> ⎩ 2 2 ⎭

Rocks! Fantastic.

Cheers,

Gaël

Reply all
Reply to author
Forward
0 new messages