15 Jan 14:45 2015

InlineBackend.figure_formats

Hi all,

I see that you can set the figure format(s) shown by the inline backend
for matplotlib by assigning a set of appropriate strings to an IPython
Config instance's InlineBackend.figure_formats. I don't quite understand
what it means for there to be more than one member of the set. Which one
(I think it's just one) is actually displayed? Are the others rendered
but not displayed? How are they accessed? Or am I just missing the point?

Yours,

Andrew

9 Jan 05:43 2015

Re: trapping error thrown by line magics?

Dear Catherine,

certain magics swallow their exceptions, %cd in particular.  We made that decision to make them more human-friendly, since magics were originally conceived really as a pure human-driven convenience while working interactively, not as a library/programming construct.

In general, the magic system does *not* swallow all exceptions, though, so you could add your own versions of the ones you need with different behavior.

Not an ideal answer, but at least the system doesn't intrinsically prevent what you're looking for (which I was afraid we might, so I actually went looking a bit).

Cheers

f

On Tue, Jan 6, 2015 at 8:42 AM, Catherine Devlin wrote:
I really enjoy being able to build informal IPython scripts that include line magics.  Maybe too much.

When I do so, is there a way to trap errors thrown by line magics?  This doesn't work as I had hoped:
try: %cd directory_that_does_not_existexcept Exception as err: print('error trapped!')
[Errno 2] No such file or directory: 'directory_that_does_not_exist' /home/catherine/werk/openFEC/data/tuning

Thanks,

_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

--
Fernando Perez ( <at> fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

6 Jan 17:42 2015

trapping error thrown by line magics?

I really enjoy being able to build informal IPython scripts that include line magics.  Maybe too much.

When I do so, is there a way to trap errors thrown by line magics?  This doesn't work as I had hoped:
try: %cd directory_that_does_not_existexcept Exception as err: print('error trapped!')
[Errno 2] No such file or directory: 'directory_that_does_not_exist' /home/catherine/werk/openFEC/data/tuning

Thanks,
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

4 Jan 07:55 2015

ipython notebook kernel shows busy from start

I am having a problem whereby ipython notebook launches but the kernel shows as busy.  I haven't executed any commands at this point.  If i restart the kernel, the command line shows that this has happened but the message doesn't get through to the browser where the little red eye still stares at me.

It means that I can't run any code.  This is the first time I have installed using anaconda, and I wonder if that is related...

Anyway, any thoughts?  This is beginning to drive me crazy.  I can get it to function properly if I restart the computer on occasion, or after a period of time sometimes it goes away by itself...

warm regards,

Aaron
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

27 Dec 17:07 2014

embedding ipython, namespace question

Hello,

I'm working on embedding an ipython qtconsole in my applilcation as a dock widget. The https://github.com/ipython/ipython/blob/master/examples/Embedding/inprocess_qtconsole.py example was a helpful first step. As variables are created or updated in the main application, I'd like to be able to inspect them in the qtconsole. Is it possible for the qtconsole's namespace to be shared or linked with that of the main application? It seems like this should be possible, based on the documentation for http://ipython.org/ipython-doc/1/api/generated/IPython.terminal.embed.html#IPython.terminal.embed.InteractiveShellEmbed . I'm creating my kernel and client at the beginning of my module, and then wiring up the widget when my application's main window is about to show. But if I run dir() in the embedded ipython qt console, the list is identical to what I get if I run dir() in the standalone ipython qtconsole program.

Thanks,
Darren
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

24 Dec 06:45 2014

hiding code in ipython notebooks

There are situations where I would like to hide the code in a cell so that only the output
is visible. I've seen various posts (e.g., at http://blog.nextgenetics.net/?e=99) about hackish ways to accomplish this. Does anyone know if a better solution is in the works?

Phillip M. Feldman
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

16 Dec 12:28 2014

graph displayed twice while overloading _repr_svg_ for notebook


Hello,

I'm having trouble overloading _repr_svg_ for graph inlining in the notebook; my object is displayed
twice if I call plt.plot just before.
I assumed a figure was left open or something, but even if I call plt.close('all') between the matplotlib
calls, the result remains the same.

I did some imports first:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from scipy.stats import norm
import sys
import io
print('matplotlib version %s' % matplotlib.__version__)
import IPython
print('IPython version %s' % IPython.__version__)

Here'my object:
class NormGraph(object):
def __init__(self):
super(NormGraph, self).__init__()
def _repr_svg_(self):
if sys.version_info[0] >= 3:
output = io.StringIO()
else:
output = io.BytesIO()
self._fig = plt.figure()
axes_kwargs = {}
plot_kwargs = {}
self._ax = [self._fig.add_subplot(111, **axes_kwargs)]
x = np.arange(-10, 10, 0.001)
y = norm.pdf(x,0,2)
self._ax[0].plot(x, y, **plot_kwargs)
self._fig.savefig(output, format='svg')

return output.getvalue()

Then a basic call to pyplot:
%matplotlib inline
plt.plot(0, 1)

Then if I try to inline my object it's displayed twice:
NormGraph()

I atached the complete notebook.

--

--
Julien Schueller
Phimeca Engineering
www.phimeca.com

Attachment (Untitled0.ipynb): application/octet-stream, 53 KiB
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

11 Dec 05:18 2014

Trouble with configuration file in notebook

Hello,

I used

ipython profile create

to create the default configuration file, and then I uncommented a few lines in
.ipython/profile_default/ipython_notebook_config.py to set different configuration options, e.g.:

c.NotebookApp.open_browser = False
c.NotebookApp.log_level = 20

However, none of them seem to be actually changing:

ipython notebook —debug

2014-12-10 23:15:50.654 [NotebookApp] Config changed:
2014-12-10 23:15:50.654 [NotebookApp] {'Application': {'log_level': 10}}
2014-12-10 23:15:50.655 [NotebookApp] IPYTHONDIR set to: /Users/jzuhone/.ipython
2014-12-10 23:15:50.659 [NotebookApp] Using existing profile dir: u'/Users/jzuhone/.ipython/profile_default'
2014-12-10 23:15:50.660 [NotebookApp] Searching path [u'/Users/jzuhone',
u'/Users/jzuhone/.ipython/profile_default'] for config files
2014-12-10 23:15:50.660 [NotebookApp] Attempting to load config file: ipython_config.py
2014-12-10 23:15:50.661 [NotebookApp] Loaded config file: /Users/jzuhone/.ipython/profile_default/ipython_config.py
2014-12-10 23:15:50.661 [NotebookApp] Attempting to load config file: ipython_notebook_config.py
2014-12-10 23:15:50.662 [NotebookApp] Loaded config file: /Users/jzuhone/.ipython/profile_default/ipython_notebook_config.py
2014-12-10 23:15:50.669 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-12-10 23:15:50.684 [NotebookApp] The port 8888 is already in use, trying another random port.
2014-12-10 23:15:50.685 [NotebookApp] Serving notebooks from local directory: /Users/jzuhone
2014-12-10 23:15:50.685 [NotebookApp] 0 active kernels
2014-12-10 23:15:50.685 [NotebookApp] The IPython Notebook is running at: http://localhost:8889/
2014-12-10 23:15:50.685 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice
to skip confirmation).

The “config changed” message does not show up after loading the notebook config, and the change in the
config option does not even take place. Can anyone clarify what is going on here?

Best,

John ZuHone

_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

6 Dec 06:37 2014

Peculiar problem with requests module

On OSX 10.9.5, Python 2.7.8 (32 Bit), iPython 2.2.0

when I execute these lines in the iPython console (cmd prompt)
they execute normally

import requests

When I execute the requests.get() in the notebook, it throws a huge exception.
This makes no sense to me. How can it work in the console, but not in the notebook?

Here is the exception traceback

Would someone explain what happened, and if there is a way to fix it?

Thanks

_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

3 Dec 23:07 2014

Custom css through nbviewer

I'm trying to figure out if it's yet possible to use a custom css when displaying pages via nbviewer.ipython.org.

_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user

1 Dec 12:48 2014

Standard cells at the beginning of a new ipython notebook

Hi IPythoners,

I have a few standard cells that I like to put at the beginning of each new notebook. Mostly they're standard imports and a few definitions that I use a lot. (For example the first cell is always: %load_ext autoreload, %autoreload 2, %matplotlib inline).

Does anyone have any good suggestions for how to have this appear automatically in a new notebook? At the moment I just open an old one and copy over each cell individually....but it seems like maybe there's a better way....

Thanks!
Kx

--
Kirstie Whitaker, PhD
Research Associate

Department of Psychiatry
University of Cambridge

Brain Mapping Unit
Department of Psychiatry
Sir William Hardy Building
Downing Street
Cambridge CB2 3EB

Phone: +44 7583 535 307
Website: www.kirstiewhitaker.com
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user


Gmane