isympy -i in IPython

130 views
Skip to first unread message

Christophe Bal

unread,
Oct 2, 2014, 8:56:51 AM10/2/14
to sympy-list
Hello,
is there a way to have the features given by  isympy -i  in IPython ?

Christoohe BAL

Mateusz Paprocki

unread,
Oct 2, 2014, 9:35:23 AM10/2/14
to sympy
Hi,

On 2 October 2014 14:56, Christophe Bal <proj...@gmail.com> wrote:
> Hello,
> is there a way to have the features given by isympy -i in IPython ?

In [1]: from sympy.interactive.session import init_ipython_session

In [2]: init_ipython_session(auto_int_to_Integer=True)
Out[2]: <IPython.terminal.interactiveshell.TerminalInteractiveShell at
0x7f20752c6450>

In [3]: from sympy import *

In [4]: 1/3
Out[4]: 1/3

In [5]: type(_)
Out[5]: sympy.core.numbers.Rational

Mateusz

> Christoohe BAL
>
> --
> 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/CAAb4jGm91WLPuk0PPFtQ0nv%3DGzZJU58x9LgYm4Gh-mZ-MC-RQQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Jason Moore

unread,
Oct 2, 2014, 9:37:08 AM10/2/14
to sy...@googlegroups.com
import sympy
sympy.init_session(auto_symbols=True)

--

Jason Moore

unread,
Oct 2, 2014, 9:38:09 AM10/2/14
to sy...@googlegroups.com
Mateusz has the correct flag.

Christophe Bal

unread,
Oct 2, 2014, 9:45:18 AM10/2/14
to sympy-list

Christophe Bal

unread,
Oct 2, 2014, 4:53:12 PM10/2/14
to sympy-list
Sorry, indeed I was looking for a solution for IPython notebook. In that case, the solution dose not work. I have the following error message.

=====================

---------------------------------------------------------------------------
MultipleInstanceError                     Traceback (most recent call last)
<ipython-input-2-b987e63c4aaa> in <module>()
----> 1 init_ipython_session(auto_int_to_Integer=True)

//anaconda/lib/python3.4/site-packages/sympy/interactive/session.py in init_ipython_session(argv, auto_symbols, auto_int_to_Integer)
    287         # don't draw IPython banner during initialization:
    288         app.display_banner = False
--> 289         app.initialize(argv)
    290 
    291         if auto_symbols:

//anaconda/lib/python3.4/site-packages/IPython/terminal/ipapp.py in initialize(self, argv)

//anaconda/lib/python3.4/site-packages/IPython/config/application.py in catch_config_error(method, app, *args, **kwargs)
     90     """
     91     try:
---> 92         return method(app, *args, **kwargs)
     93     except (TraitError, ArgumentError) as e:
     94         app.print_help()

//anaconda/lib/python3.4/site-packages/IPython/terminal/ipapp.py in initialize(self, argv)
    330         self.init_path()
    331         # create the shell
--> 332         self.init_shell()
    333         # and draw the banner
    334         self.init_banner()

//anaconda/lib/python3.4/site-packages/IPython/terminal/ipapp.py in init_shell(self)
    346         self.shell = TerminalInteractiveShell.instance(parent=self,
    347                         display_banner=False, profile_dir=self.profile_dir,
--> 348                         ipython_dir=self.ipython_dir, user_ns=self.user_ns)
    349         self.shell.configurables.append(self)
    350 

//anaconda/lib/python3.4/site-packages/IPython/config/configurable.py in instance(cls, *args, **kwargs)
    363             raise MultipleInstanceError(
    364                 'Multiple incompatible subclass instances of '
--> 365                 '%s are being created.' % cls.__name__
    366             )
    367 

MultipleInstanceError: Multiple incompatible subclass instances of TerminalInteractiveShell are being created.

Mateusz Paprocki

unread,
Oct 2, 2014, 6:21:08 PM10/2/14
to sympy
Hi,

On 2 October 2014 22:53, Christophe Bal <proj...@gmail.com> wrote:
> Sorry, indeed I was looking for a solution for IPython notebook. In that
> case, the solution dose not work. I have the following error message.

init_ipython_session() works only with terminal, but
auto_int_to_Integer is generic. Terminal-only support is rather
artificial and it should be possible to add cases for other frontends,
like notebook (thought I didn't try this).

Mateusz
> --
> 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/CAAb4jGk%2BEA_EHTj1oJ0U2o0tOS73wfqux6aL4O%2BR8-ZZpvOR5w%40mail.gmail.com.

Aaron Meurer

unread,
Oct 4, 2014, 7:54:47 PM10/4/14
to sy...@googlegroups.com
Some relevant issues: https://github.com/sympy/sympy/issues/2839 and
https://github.com/sympy/sympy/issues/2921. That error message
indicates something that hasn't been updated to work with the newer
versions of IPython.

Aaron Meurer
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAGBZUCYLYKvcrHDtBskyg1PVkMwEJgR2bc%3Dri7tMCJqfhBNG1Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages