What is the canonical replacement for --profile="sympy"

15 views
Skip to first unread message

oli...@member.ams.org

unread,
Aug 1, 2017, 4:27:12 AM8/1/17
to Project Jupyter
After upgrading my Fedora installation to F26, I notice that ipython now seems to call jupyter directly which does not have the concept of profiles any more, as can be found via google relatively quickly.

What I miss, however, is a canonical replacement for --profile="sympy" as a standard profile.  It used to set up pretty printing, loading sympy and pre-define a few variable names, all pretty convenient.  However, the profile is now completely gone from my system.  I could probably dig up some old version on the internet or try to handwrite one myself, but there should be a standard replacement mechanism for this?

Unfortunately, both the jypter and the sympy documentation does not say anything about this...

Any hints appreciated,
thanks,
Marcel

Thomas Kluyver

unread,
Aug 1, 2017, 5:50:36 AM8/1/17
to Project Jupyter
Hi Marcel,

On 1 August 2017 at 09:27, <oli...@member.ams.org> wrote:
After upgrading my Fedora installation to F26, I notice that ipython now seems to call jupyter directly which does not have the concept of profiles any more, as can be found via google relatively quickly.

IPython, the terminal interface, still works the way it used to: you should be able to use your profile there. I don't think we ship a sympy profile any more (I had forgotten we ever did that), but if you work out the configuration it needs, you should be able to make a profile with 'ipython profile create sympy', and modify the config file it creates.

The IPython frontends which talk to a kernel (the notebook, qtconsole and two-process terminal console) all became Jupyter applications, so they don't directly support profiles.
 
What I miss, however, is a canonical replacement for --profile="sympy" as a standard profile.  It used to set up pretty printing, loading sympy and pre-define a few variable names, all pretty convenient.  However, the profile is now completely gone from my system.  I could probably dig up some old version on the internet or try to handwrite one myself, but there should be a standard replacement mechanism for this?

Sympy has some functions you can call at the start of a session to set up some amount of integration:
http://docs.sympy.org/latest/tutorial/printing.html#setting-up-pretty-printing

We recommend this kind of approach for use in notebooks particularly, because notebooks which rely on things configured on your computer won't be easily runnable for anyone without that config.

But if that's not enough for you, and you have your sympy profile set up, you can create a dedicated sympy kernel which will launch IPython with your sympy profile. You'll need to install a kernelspec (http://ipython.readthedocs.io/en/stable/install/kernel_install.html), and then manually modify the kernel.json file to add --profile sympy to the argv.

Best wishes,
Thomas

oli...@member.ams.org

unread,
Aug 1, 2017, 6:45:17 AM8/1/17
to Project Jupyter
Hi Thomas, thanks for your quick reply!

Indeed, your link contains what I think the sympy profile was doing:


In [1]: from sympy import init_session


In [2]: init_session()


and this works just fine in jupyter. Still, it would be nice if there was some shortcut for it as it takes more effort than necessary to remember and to type this. In the past, I had a shell alias for sympy which asks for the sympy profile, but obviously this is not supported any longer. Creating a dedicated sympy kernel as you suggest seems possible but a bit heavy-handed for such a simple thing (and nothing I can tell my students in order to lower the barrier of entry...).


Yes, I do need to switch profiles as I am using both pylab and sympy interactively. Funny enough, ipython has a builtin magic for pylab, but none for sympy. I am not sure how much this forum is connected to ipython, but that would be an obvious trivial thing to add that would more or less solve the issue of getting a working sympy console quickly in the most obvious way.


Regards,

Marcel

Thomas Kluyver

unread,
Aug 1, 2017, 7:24:51 AM8/1/17
to Project Jupyter
On 1 August 2017 at 11:45, <oli...@member.ams.org> wrote:
In the past, I had a shell alias for sympy which asks for the sympy profile, but obviously this is not supported any longer.

I think sympy still has 'isympy' to launch an IPython console with sympy already set up.
 
Creating a dedicated sympy kernel as you suggest seems possible but a bit heavy-handed for such a simple thing (and nothing I can tell my students in order to lower the barrier of entry...).

It's very light in computer terms - just a couple of tiny files on your disk. I agree it's not very convenient for students, though. I can't think of anything you can do to make it simpler for them than importing and calling a function.
 

Yes, I do need to switch profiles as I am using both pylab and sympy interactively. Funny enough, ipython has a builtin magic for pylab, but none for sympy. I am not sure how much this forum is connected to ipython, but that would be an obvious trivial thing to add that would more or less solve the issue of getting a working sympy console quickly in the most obvious way.


The %pylab magic is gently deprecated, and I doubt we'd go for a new magic command to integrate with a particular module - sorry!

oli...@member.ams.org

unread,
Aug 1, 2017, 7:54:49 AM8/1/17
to Project Jupyter
On Tuesday, August 1, 2017 at 1:24:51 PM UTC+2, takowl wrote:
On 1 August 2017 at 11:45, <oli...@member.ams.org> wrote:
In the past, I had a shell alias for sympy which asks for the sympy profile, but obviously this is not supported any longer.

I think sympy still has 'isympy' to launch an IPython console with sympy already set up.

Indeed, it exists.  But it only does terminal console as far as I can tell, so no LaTeX-based pretty-printing...
 
Creating a dedicated sympy kernel as you suggest seems possible but a bit heavy-handed for such a simple thing (and nothing I can tell my students in order to lower the barrier of entry...).

It's very light in computer terms - just a couple of tiny files on your disk. I agree it's not very convenient for students, though. I can't think of anything you can do to make it simpler for them than importing and calling a function.

It's not just students, it's also myself.  I am a working Mathematician and I don't do this every day.  The starting up of sympy (in the most user-friendly environment) seems very non-discoverable and non-intuitive.  Even about one hour after my last mail I could not remember the package to load on top of my head without scrolling back up to my previous message to check.  When I need to fire up sympy to check some computation, I have my mind on the math and don't want to be distracted by remembering some relatively arbitrary start-up magic.  In fact, after my first post I simply fired up Mathematica to get the work done as that's a command I can remember... 

Installing a dedicated sympy kernel makes me feel uneasy, I want something that works on any machine, any account from a canonical base installation.  Even my shell alias is something I don't really like to do (the current breaking at inconvenient time is a case in point), I'd prefer using a supported method if one existed.
 

Yes, I do need to switch profiles as I am using both pylab and sympy interactively. Funny enough, ipython has a builtin magic for pylab, but none for sympy. I am not sure how much this forum is connected to ipython, but that would be an obvious trivial thing to add that would more or less solve the issue of getting a working sympy console quickly in the most obvious way.


The %pylab magic is gently deprecated, and I doubt we'd go for a new magic command to integrate with a particular module - sorry!

This is unfortunate.  Not that I like magic commands very much, but they are useful.  So if you deprecate them, please make sure that things don't get much more heavy-handed and undiscoverable.

The main competitors are Matlab and Mathematica (from my point of view).  So if simple things like getting a convenient environment for one-off quick computations get too inaccessible, then the python-based solutions simply don't get used.

Best regards,
Marcel
 
Reply all
Reply to author
Forward
0 new messages